1 |
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/queen3d/queen/osgAnimation/Bone.js","webpack:///./src/queen3d/queen/osg/PooledArray.js","webpack:///./src/queen3d/queen/osg/MatrixTransform.js","webpack:///./src/queen3d/queen/osg/Projection.js","webpack:///./src/queen3d/queen/osg/KdTree.js","webpack:///./src/queen3d/queen/osgAnimation/MorphAttribute.js","webpack:///./src/queen3d/queen/osg/BufferArray.js","webpack:///./src/queen3d/queen/osgDB/options.js","webpack:///./src/queen3d/queen/osgDB/Input.js","webpack:///./src/queen3d/queen/osg/WebGLCaps.js","webpack:///./src/queen3d/queen/osg/primitiveFunctor.js","webpack:///./src/queen3d/queen/osgShader/node/Node.js","webpack:///./src/queen3d/queen/osgDB/fileHelper.js","webpack:///./src/queen3d/queen/osg/StateAttribute.js","webpack:///./src/queen3d/queen/osg/CullSettings.js","webpack:///./src/queen3d/queen/osg/GLObject.js","webpack:///./src/queen3d/queen/osg/primitiveSet.js","webpack:///./src/queen3d/queen/osg/Plane.js","webpack:///./src/queen3d/queen/osg/math.js","webpack:///./src/queen3d/queen/osgAnimation/SkinningAttribute.js","webpack:///./src/queen3d/queen/osg/Timer.js","webpack:///./src/queen3d/queen/osg/BillboardAttribute.js","webpack:///./src/queen3d/queen/osg/ColorMask.js","webpack:///./src/queen3d/queen/osg/EllipsoidModel.js","webpack:///./src/queen3d/queen/osg/ImageStream.js","webpack:///./src/queen3d/queen/osg/LineWidth.js","webpack:///./src/queen3d/queen/osg/PointSizeAttribute.js","webpack:///./src/queen3d/queen/osg/TextureCubeMap.js","webpack:///./src/queen3d/queen/osg/TriangleIndexFunctor.js","webpack:///./src/queen3d/queen/osg/osg.js","webpack:///./src/queen3d/queen/osg/PooledResource.js","webpack:///./src/queen3d/queen/osg/primitiveIndexFunctor.js","webpack:///./src/queen3d/queen/osg/StateSet.js","webpack:///./src/queen3d/queen/osg/Transform.js","webpack:///./src/queen3d/queen/osg/Uniform.js","webpack:///./src/queen3d/queen/osgAnimation/AnimationUpdateCallback.js","webpack:///./src/queen3d/queen/osgViewer/Renderer.js","webpack:///./src/queen3d/queen/osg/FrameStamp.js","webpack:///./src/queen3d/queen/osgShader/ShaderGenerator.js","webpack:///./src/queen3d/queen/osg/Shader.js","webpack:///./src/queen3d/queen/comm/events.js","webpack:///./src/queen3d/queen/application/Config.js","webpack:///./src/queen3d/queen/application/shaders/baseShaderChunks.js","webpack:///./src/queen3d/queen/application/shaders/postProcessShaderChunks.js","webpack:///./src/queen3d/queen/osgGA/Manipulator.js","webpack:///./src/queen3d/queen/osgGA/Controller.js","webpack:///./src/queen3d/queen/osgViewer/input/InputConstants.js","webpack:///./src/queen3d/queen/osgGA/FirstPersonManipulatorDeviceOrientationController.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulatorDeviceOrientationController.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulatorGamePadController.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulatorHammerController.js","webpack:///./src/queen3d/queen/osgGA/orbitManipulatorEnums.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulatorStandardMouseKeyboardController.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulatorWebVRController.js","webpack:///./src/queen3d/queen/osgUtil/DelayInterpolator.js","webpack:///./src/queen3d/queen/osgGA/OrbitManipulator.js","webpack:///./src/queen3d/queen/osgViewer/webgl-debug.js","webpack:///./src/queen3d/queen/osgStats/Graph.js","webpack:///./src/queen3d/queen/osgStats/BufferStats.js","webpack:///./src/queen3d/queen/osgStats/Counter.js","webpack:///./src/queen3d/queen/osgStats/TextGenerator.js","webpack:///./src/queen3d/queen/osgStats/Stats.js","webpack:///./src/queen3d/queen/osgStats/defaultStats.js","webpack:///./src/queen3d/queen/osgStats/glStats.js","webpack:///./src/queen3d/queen/osgStats/browserStats.js","webpack:///./src/queen3d/queen/osgViewer/input/InputManager.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSource.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceMouse.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceKeyboard.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceWebVR.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceGamePad.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceDeviceOrientation.js","webpack:///./src/queen3d/queen/osgViewer/input/source/InputSourceTouchScreen.js","webpack:///./src/queen3d/queen/osgViewer/Viewer.js","webpack:///./src/queen3d/queen/osgViewer/osgViewer.js","webpack:///./src/queen3d/queen/application/FeatureEventManager.js","webpack:///./src/queen3d/queen/application/RenderDetail.js","webpack:///./src/queen3d/queen/application/GLState.js","webpack:///./src/queen3d/queen/application/PickMask.js","webpack:///./src/queen3d/queen/osgUtil/ComposerPostProcess.js","webpack:///./src/queen3d/queen/osgUtil/gizmoGeometry.js","webpack:///./src/queen3d/queen/osgUtil/debug.js","webpack:///./src/queen3d/queen/osgUtil/NodeGizmo.js","webpack:///./src/queen3d/queen/osgUtil/PolytopeIntersectFunctor.js","webpack:///./src/queen3d/queen/osgUtil/PolytopeIntersector.js","webpack:///./src/queen3d/queen/osgUtil/SphereIntersectFunctor.js","webpack:///./src/queen3d/queen/osgUtil/SphereIntersector.js","webpack:///./src/queen3d/queen/osgUtil/TangentSpaceGenerator.js","webpack:///./src/queen3d/queen/osgUtil/WebVRCustom.js","webpack:///./src/queen3d/queen/osgUtil/WebVR.js","webpack:///./src/queen3d/queen/osgUtil/osgUtil.js","webpack:///./src/queen3d/queen/application/NodeGizmo.js","webpack:///./src/queen3d/queen/application/ComputeBoundsVisitor.js","webpack:///./src/queen3d/queen/application/BoundingComputer.js","webpack:///./src/queen3d/queen/application/ShaderMaker.js","webpack:///./src/queen3d/queen/application/WorldGrid.js","webpack:///./src/queen3d/queen/application/FeatureManager.js","webpack:///./src/queen3d/queen/application/PresetLights.js","webpack:///./src/queen3d/queen/application/GeometryCreator.js","webpack:///./src/queen3d/queen/application/DummyTexture.js","webpack:///./src/queen3d/queen/application/CreatePromise.js","webpack:///./src/queen3d/queen/application/TextureCubeMap.js","webpack:///./src/queen3d/queen/application/ResourceManager.js","webpack:///./src/queen3d/queen/application/StateAttributeRegister.js","webpack:///./src/queen3d/queen/application/EditorLight.js","webpack:///./src/queen3d/queen/osgShadow/ShadowCastAttribute.js","webpack:///./src/queen3d/queen/osgShadow/ShadowCasterVisitor.js","webpack:///./src/queen3d/queen/osgShadow/ShadowFrustumIntersection.js","webpack:///./src/queen3d/queen/osgShadow/ShadowReceiveAttribute.js","webpack:///./src/queen3d/queen/osgShadow/ShadowTechnique.js","webpack:///./src/queen3d/queen/osgShadow/ShadowTexture.js","webpack:///./src/queen3d/queen/osgShadow/ShadowMap.js","webpack:///./src/queen3d/queen/osgShadow/ShadowTextureAtlas.js","webpack:///./src/queen3d/queen/osgShadow/ShadowMapAtlas.js","webpack:///./src/queen3d/queen/osgShadow/ShadowSettings.js","webpack:///./src/queen3d/queen/osgShadow/ShadowedScene.js","webpack:///./src/queen3d/queen/osgShadow/osgShadow.js","webpack:///./src/queen3d/queen/application/MaxTextureUnit.js","webpack:///./src/queen3d/queen/application/material/PBRMaterial.js","webpack:///./src/queen3d/queen/application/ChangeColorAttribute.js","webpack:///./src/queen3d/queen/application/DiamondAttribute.js","webpack:///./src/queen3d/module/objects/Env3d/defaultEnv3d.ts","webpack:///./src/queen3d/queen/application/UVTransformAttribute.js","webpack:///./src/queen3d/queen/application/objects/GeomNodeVisitor.js","webpack:///./src/queen3d/queen/application/objects/GeomNodeVisitorV3.js","webpack:///./src/queen3d/queen/application/UVProjectionAttribute.js","webpack:///./src/queen3d/queen/application/objects/ModelLoader.js","webpack:///./src/queen3d/queen/application/material/UrlResolver.js","webpack:///./src/queen3d/queen/application/material/MaterialUtils.js","webpack:///./src/queen3d/queen/application/features/Lighting.js","webpack:///./src/queen3d/queen/application/CullVisitor.js","webpack:///./src/queen3d/queen/application/RenderPassEnum.js","webpack:///./src/queen3d/queen/application/RenderStage.js","webpack:///./src/queen3d/queen/application/ColorHelper.js","webpack:///./src/queen3d/queen/application/PostProcessNode.js","webpack:///./src/queen3d/queen/application/features/PostProcess.js","webpack:///./src/queen3d/queen/application/BackgroundNode.js","webpack:///./src/queen3d/queen/application/TextureEnvironment.js","webpack:///./src/queen3d/queen/application/EnvironmentNode.js","webpack:///./src/queen3d/queen/application/features/Environment.js","webpack:///./src/queen3d/queen/application/features/Background.js","webpack:///./src/queen3d/queen/application/features/ScreenShot.js","webpack:///./src/queen3d/queen/application/StickerAttribute.js","webpack:///./src/queen3d/queen/application/features/StickerFeature.js","webpack:///./src/queen3d/queen/osgAnimation/channel.js","webpack:///./src/queen3d/queen/osgAnimation/animation.js","webpack:///./src/queen3d/queen/osgAnimation/interpolator.js","webpack:///./src/queen3d/queen/osgAnimation/CollectAnimationUpdateCallbackVisitor.js","webpack:///./src/queen3d/queen/osgAnimation/BasicAnimationManager.js","webpack:///./src/queen3d/queen/osgAnimation/easing.js","webpack:///./src/queen3d/queen/osgAnimation/StackedMatrix.js","webpack:///./src/queen3d/queen/osgAnimation/StackedQuaternion.js","webpack:///./src/queen3d/queen/osgAnimation/StackedRotateAxis.js","webpack:///./src/queen3d/queen/osgAnimation/StackedScale.js","webpack:///./src/queen3d/queen/osgAnimation/StackedTranslate.js","webpack:///./src/queen3d/queen/osgAnimation/osgAnimation.js","webpack:///./src/queen3d/queen/application/UpdateCallbackChecker.js","webpack:///./src/queen3d/queen/application/features/Outline.js","webpack:///./src/queen3d/queen/application/FrameManager.js","webpack:///./src/queen3d/queen/application/SuperSample.js","webpack:///./src/queen3d/queen/osgGA/CADManipulatorStandardMouseKeyboardController.js","webpack:///./src/queen3d/queen/osgGA/CADManipulatorHammerController.js","webpack:///./src/queen3d/queen/osgGA/CADManipulator.js","webpack:///./src/queen3d/queen/osgGA/FirstPersonManipulatorHammerController.js","webpack:///./src/queen3d/queen/osgGA/FirstPersonManipulatorWebVRController.js","webpack:///./src/queen3d/queen/osgGA/FirstPersonManipulatorStandardMouseKeyboardController.js","webpack:///./src/queen3d/queen/osgGA/FirstPersonManipulator.js","webpack:///./src/queen3d/queen/osgGA/SwitchManipulator.js","webpack:///./src/queen3d/queen/osgGA/osgGA.js","webpack:///./src/queen3d/queen/application/OrbitManipulator.js","webpack:///./src/queen3d/queen/application/FirstPersonManipulator.js","webpack:///./src/queen3d/queen/application/SwitchManipulator.js","webpack:///./src/queen3d/queen/application/Material.js","webpack:///./src/queen3d/queen/application/EditorCompiler.js","webpack:///./src/queen3d/queen/application/isMobile.js","webpack:///./src/queen3d/queen/application/shaders/auto_diamond.js","webpack:///./src/queen3d/queen/application/PBRCompiler.js","webpack:///./src/queen3d/queen/application/OutlineCompiler.js","webpack:///./src/queen3d/queen/application/EarlyZCompiler.js","webpack:///./src/queen3d/queen/application/ShadowCastCompiler.js","webpack:///./src/queen3d/queen/application/EditorShaderGenerator.js","webpack:///./src/queen3d/queen/application/CanvasPixelRatio.js","webpack:///./src/queen3d/queen/application/shaders/earlyZFrag.glsl","webpack:///./src/queen3d/queen/application/shaders/cubemapFragment.glsl","webpack:///./src/queen3d/queen/application/shaders/cubemapSampler.glsl","webpack:///./src/queen3d/queen/application/shaders/cubemapVertex.glsl","webpack:///./src/queen3d/queen/application/shaders/math.glsl","webpack:///./src/queen3d/queen/application/shaders/changeColor.glsl","webpack:///./src/queen3d/queen/application/shaders/panoramaSampler.glsl","webpack:///./src/queen3d/queen/application/shaders/pbr_ue4.glsl","webpack:///./src/queen3d/queen/application/shaders/pbrFrag.glsl","webpack:///./src/queen3d/queen/application/shaders/baseVert.glsl","webpack:///./src/queen3d/queen/application/shaders/sphericalHarmonics.glsl","webpack:///./src/queen3d/queen/application/shaders/sphericalHarmonicsFragment.glsl","webpack:///./src/queen3d/queen/application/shaders/sphericalHarmonicsVertex.glsl","webpack:///./src/queen3d/queen/application/shaders/triplanar_projection.glsl","webpack:///./src/queen3d/queen/application/shaders/shadowCastFrag.glsl","webpack:///./src/queen3d/queen/application/shaders/sticker.glsl","webpack:///./src/queen3d/queen/application/objects/Scene.js","webpack:///./src/queen3d/queen/application/Explode.js","webpack:///./src/queen3d/queen/application/application.js","webpack:///./src/queen3d/queen/comm/bus.js","webpack:///./src/queen3d/queen/osgWrappers/serializers/osg.js","webpack:///./src/queen3d/queen/osgWrappers/serializers/osgAnimation.js","webpack:///./src/queen3d/queen/osgText/Text.js","webpack:///./src/queen3d/queen/osgWrappers/serializers/osgText.js","webpack:///./src/queen3d/queen/osgDB/osgDB.js","webpack:///./src/queen3d/queen/application/objects/ShoeNodeVisitor.js","webpack:///./src/queen3d/util/useMaterial.ts","webpack:///./src/queen3d/util/scenePackageEn3d.ts","webpack:///./src/queen3d/util/scenepack.ts","webpack:///./src/queen3d/module/objects/Env3d/index.ts","webpack:///./src/queen3d/module/objects/picker.ts","webpack:///./src/queen3d/module/objects/Application.ts","webpack:///./src/queen3d/module/objects/Mat/index.ts","webpack:///./src/queen3d/module/objects/Mesh/index.ts","webpack:///./src/queen3d/module/objects/Mesh/loader.ts","webpack:///./src/queen3d/module/objects/ResController.ts","webpack:///./src/queen3d/queen/application/GroundShadow.js","webpack:///./src/queen3d/index.ts","webpack:///./src/pages/website/routes/preview/productObj.ts","webpack:///./src/pages/website/routes/preview/actions/defaultEnv3d.ts","webpack:///./src/pages/website/routes/preview/actions/env.ts","webpack:///./src/pages/website/routes/preview/actions/geom.ts","webpack:///./src/pages/website/routes/preview/objects/ColorReplacer/index.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/create.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/PackEnvBackground.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/extends.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/PackEnv.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/PackMat.ts","webpack:///./src/pages/website/routes/preview/objects/Pack/sources/PackProductComp.ts","webpack:///./src/pages/website/routes/preview/objects/defaultMat.ts","webpack:///./src/pages/website/routes/preview/objects/material.ts","webpack:///./src/pages/website/routes/preview/Queen3dCtrl.ts","webpack:///./src/pages/website/routes/preview/MeshOsgjs.tsx","webpack:///./src/pages/website/routes/preview/Mesh.tsx","webpack:///./src/pages/website/routes/preview/utils.ts","webpack:///./src/pages/website/routes/preview/SceneOsgjs.tsx","webpack:///./src/pages/website/routes/preview/Scene.tsx","webpack:///./src/pages/website/routes/preview/MatOsgjs.tsx","webpack:///./src/pages/website/routes/preview/Mat.tsx","webpack:///./src/pages/website/routes/preview/Image.tsx","webpack:///./src/pages/website/routes/preview/index.tsx","webpack:///./src/queen3d/queen/osgPlugins/ReaderWriterGLTF.js","webpack:///./src/queen3d/queen/osgPlugins/ReaderWriterZIP.js","webpack:///./src/queen3d/queen/osgPlugins/ReaderWriterQueen.js","webpack:///./src/queen3d/queen/osgPlugins/osgPlugins.js","webpack:///./src/pages/website/routes/dotqueen/test.ts","webpack:///./src/pages/website/routes/dotqueen/index.tsx","webpack:///./src/pages/website/routes/index.ts","webpack:///./src/pages/website/App.tsx","webpack:///./src/pages/website/main.ts","webpack:///./src/queen3d/queen/osg/PooledMap.js","webpack:///./src/queen3d/queen/osg/Node.js","webpack:///./src/queen3d/queen/osg/LightSource.js","webpack:///./src/queen3d/queen/osgUtil/DisplayGeometryVisitor.js","webpack:///./src/queen3d/queen/osg/Camera.js","webpack:///./src/queen3d/queen/config.js","webpack:///./src/queen3d/queen/osg/glMatrix.js","webpack:///./src/queen3d/queen/osgAnimation/channelType.js","webpack:///./src/queen3d/queen/osg/Viewport.js","webpack:///./src/queen3d/queen/osgUtil/DisplayNormalVisitor.js","webpack:///./src/queen3d/queen/osgDB/zlib.js","webpack:///./src/queen3d/queen/osg/RenderStage.js","webpack:///./src/queen3d/queen/osg/Object.js","webpack:///./src/queen3d/queen/osg/polyfill.js","webpack:///./src/queen3d/queen/osg/Lod.js","webpack:///./src/queen3d/queen/osg/Image.js","webpack:///./src/queen3d/queen/osgShadow/ShadowCastCompiler.js","webpack:///./src/queen3d/queen/osg/NodeVisitor.js","webpack:///./src/queen3d/queen/osgShader/ShaderGeneratorProxy.js","webpack:///./src/queen3d/queen/osgShader/ShaderProcessor.js","webpack:///./src/queen3d/queen/osgShader/osgShader.js","webpack:///./src/queen3d/queen/osg/Polytope.js","webpack:///./src/queen3d/queen/osg/shape.js","webpack:///./src/queen3d/queen/osgViewer/webgl-utils.js","webpack:///./src/queen3d/queen/osg/TimerGPU.js","webpack:///./src/queen3d/queen/osg/BufferArrayProxy.js","webpack:///./src/queen3d/queen/osg/CullingSet.js","webpack:///./src/queen3d/queen/osg/BlendColor.js","webpack:///./src/queen3d/queen/osg/Material.js","webpack:///./src/queen3d/queen/osgDB/Registry.js","webpack:///./src/queen3d/queen/osgAnimation/UpdateBone.js","webpack:///./src/queen3d/queen/osg/AutoTransform.js","webpack:///./src/queen3d/queen/osg/DrawArrays.js","webpack:///./src/queen3d/queen/osgDB/readerParser.js","webpack:///./src/queen3d/queen/osg/FrontFace.js","webpack:///./src/queen3d/queen/osgUtil/IntersectFunctor.js","webpack:///./src/queen3d/queen/osg/TextureManager.js","webpack:///./src/queen3d/queen/osg/Texture.js","webpack:///./src/queen3d/queen/osgShadow/ShadowCastShaderGenerator.js","webpack:///./src/queen3d/queen/osg/UpdateVisitor.js","webpack:///./src/queen3d/queen/osg/CullStack.js","webpack:///./src/queen3d/queen/osgDB/DatabasePager.js","webpack:///./src/queen3d/queen/osg/Light.js","webpack:///./src/queen3d/queen/osgShader/NextShaderProcessor.js","webpack:///./src/queen3d/queen/osg/VertexArrayObject.js","webpack:///./src/queen3d/queen/osgViewer/View.js","webpack:///./src/queen3d/queen/osg/DrawElements.js","webpack:///./src/queen3d/queen/osg/KdTreeBuilder.js","webpack:///./src/queen3d/queen/osgAnimation/MorphGeometry.js","webpack:///./src/queen3d/queen/osg/Geometry.js","webpack:///./src/queen3d/queen/osg/Options.js","webpack:///./src/queen3d/queen/osg/Depth.js","webpack:///./src/queen3d/queen/osgUtil/IntersectionVisitor.js","webpack:///./src/queen3d/queen/osg/notify.js","webpack:///./src/queen3d/queen/osgShader/node/data.js","webpack:///./src/queen3d/queen/osgShader/node/operations.js","webpack:///./src/queen3d/queen/osgShader/nodeFactory.js","webpack:///./src/queen3d/queen/osgShader/node/common.glsl","webpack:///./src/queen3d/queen/osgShader/node/functions.glsl","webpack:///./src/queen3d/queen/osgShader/node/lightCommon.glsl","webpack:///./src/queen3d/queen/osgShader/node/lights.glsl","webpack:///./src/queen3d/queen/osgShader/node/skinning.glsl","webpack:///./src/queen3d/queen/osgShader/node/morphing.glsl","webpack:///./src/queen3d/queen/osgShader/node/textures.glsl","webpack:///./src/queen3d/queen/osgShader/node/colorEncode.glsl","webpack:///./src/queen3d/queen/osgShader/node/billboard.glsl","webpack:///./src/queen3d/queen/osgShader/shaderLib.js","webpack:///./src/queen3d/queen/osg/BoundingSphere.js","webpack:///./src/queen3d/queen/osg/FrameBufferObject.js","webpack:///./src/queen3d/queen/osgAnimation/UpdateMatrixTransform.js","webpack:///./src/queen3d/queen/osg/Scissor.js","webpack:///./src/queen3d/queen/osg/BlendFunc.js","webpack:///./src/queen3d/queen/osgAnimation/target.js","webpack:///./src/queen3d/queen/osg/CullFace.js","webpack:///./src/queen3d/queen/osgViewer/Scene.js","webpack:///./src/queen3d/queen/osg/utils.js","webpack:///./src/queen3d/queen/application/assets/grid.png","webpack:///./src/queen3d/queen/osg/ComputeBoundsVisitor.js","webpack:///./src/queen3d/queen/osg/Program.js","webpack:///./src/queen3d/queen/osgShader/CompilerVertex.js","webpack:///./src/queen3d/queen/osgShader/CompilerFragment.js","webpack:///./src/queen3d/queen/osgShader/Compiler.js","webpack:///./src/queen3d/queen/osg/Switch.js","webpack:///./src/queen3d/queen/osg/computeMatrixFromNodePath.js","webpack:///./src/queen3d/queen/osg/RenderBin.js","webpack:///./src/queen3d/queen/osg/StateGraph.js","webpack:///./src/queen3d/queen/osg/RenderLeaf.js","webpack:///./src/queen3d/queen/osgUtil/LineSegmentIntersectFunctor.js","webpack:///./src/queen3d/queen/osgUtil/Intersector.js","webpack:///./src/queen3d/queen/application/assets/light_icon.png","webpack:///./src/queen3d/queen/osg/StateCache.js","webpack:///./src/queen3d/queen/osg/State.js","webpack:///./src/queen3d/queen/osg/DrawArrayLengths.js","webpack:///./src/queen3d/queen/osgShadow/shaders/shadowCast.glsl","webpack:///./src/queen3d/queen/osgShadow/shaders/shadowReceive.glsl","webpack:///./src/queen3d/queen/osgShadow/shaders/shadowLinearSoft.glsl","webpack:///./src/queen3d/queen/osgShadow/shaders/floatFromTex.glsl","webpack:///./src/queen3d/queen/osgShadow/shaders/tapPCF.glsl","webpack:///./src/queen3d/queen/osgShadow/shaderLib.js","webpack:///./src/queen3d/queen/osg/StackObjectPairPool.js","webpack:///./src/queen3d/queen/osgDB/requestFile.js","webpack:///./src/queen3d/queen/osgUtil/DisplayGraphNode.js","webpack:///./src/queen3d/queen/osgUtil/DisplayGraphRenderer.js","webpack:///./src/queen3d/queen/osgUtil/DisplayGraph.js","webpack:///./src/queen3d/queen/osgAnimation/FindNearestParentSkeleton.js","webpack:///./src/queen3d/queen/osgAnimation/UpdateRigGeometry.js","webpack:///./src/queen3d/queen/osgAnimation/CollectBoneVisitor.js","webpack:///./src/queen3d/queen/osgAnimation/RigTransformHardware.js","webpack:///./src/queen3d/queen/osgAnimation/RigGeometry.js","webpack:///./src/queen3d/queen/osgUtil/intersectionEnums.js","webpack:///./src/queen3d/queen/osg/PagedLOD.js","webpack:///./src/queen3d/queen/osg/BoundingBox.js","webpack:///./src/queen3d/queen/osg/transformEnums.js","webpack:///./src/queen3d/queen/osg/CullVisitor.js","webpack:///./src/queen3d/queen/osgShader/utils.js","webpack:///./src/queen3d/queen/osgUtil/LineSegmentIntersector.js","webpack:///./src/queen3d/queen/osgAnimation/Skeleton.js","webpack:///./src/queen3d/queen/osgAnimation/UpdateSkeleton.js","webpack:///./src/queen3d/queen/osg/cullVisitorHelper.js","webpack:///./src/queen3d/queen/osgAnimation/UpdateMorph.js"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","window","oldJsonpFunction","slice","Bone","undefined","this","setName","MatrixTransform","_invBindInSkeletonSpace","mat4","_boneInSkeletonSpace","_boneBoundingBox","BoundingBox","utils","createPrototypeNode","objectInherit","getOrCreateDebugColor","_boneColor","vec3","fromValues","Math","random","getBoneBoundingBox","setBoneBoundingBox","bb","getMatrixInSkeletonSpace","getInvBindMatrixInSkeletonSpace","setMatrixInSkeletonSpace","copy","setInvBindMatrixInSkeletonSpace","getBoneParent","parents","getParents","typeID","getTypeID","setDefaultUpdateCallback","addUpdateCallback","UpdateBone","getName","PooledArray","_pool","_length","clean","reset","getLength","getArray","back","pop","forEach","func","Transform","matrix","getMatrix","setMatrix","dirtyBound","computeLocalToWorldMatrix","referenceFrame","TransformEnums","RELATIVE_RF","mul","computeWorldToLocalMatrix","minverse","invert","Projection","Node","projection","getProjectionMatrix","setProjectionMatrix","KdNode","first","second","_bb","_first","_second","_nodeRayStart","_nodeRayEnd","InfoCollector","_numVertexIndices","node","getAttributes","Vertex","primitiveIndexFunctor","operatorPoint","operatorLine","operatorTriangle","PrimitiveIndicesCollector","buildKdTree","_buildKdTree","_numIndices","i0","vertices","_kdTree","getVertices","iv","addPoint","_primitiveIndices","centers","_centers","idCenter","i1","iv0","iv1","addLine","numIndices","v0x","v0y","v0z","v1x","v1y","v1z","minx","miny","minz","maxx","maxy","maxz","i2","iv2","addTriangle","v2x","v2y","v2z","BuildKdTree","kdTree","_axisOrder","_stackLength","build","options","geom","targetTris","_targetNumTrianglesPerLeaf","vertexAttrib","getVertexAttributeList","getElements","nbVertices","getBoundingBox","setVertices","computeDivisions","_numVerticesProcessed","totalLenArray","geomPrimitives","getPrimitiveSetList","nbPrimitives","prim","getMode","primitiveSet","TRIANGLE_STRIP","TRIANGLE_FAN","abs","getCount","infoCollector","vertexIndicesSize","Uint32Array","Float32Array","setPrimitiveIndices","vertexIndicesArray","Uint16Array","setVertexIndices","pic","kdPrimIndices","getPrimitiveIndices","getNumPrimitiveIndices","kdVertexIndices","getVertexIndices","getNumVertexIndices","nodeNum","addNode","divide","primitiveIndices","getNodes","_maxNumLevels","max","_max","min","_min","dx","dy","dz","axisOrder","sum","nodeIndex","level","primitives","nodes","needToDivide","istart","iend","computeNodeBox","axis","originalMin","originalMax","mid","originalLeftChildIndex","originalRightChildIndex","insitueDivision","left","right","tmp","restore","leftChildIndex","rightChildIndex","bnode","init","expandByBoundingBox","Infinity","vertexIndices","primitiveIndex","numPoints","vi","vx","vy","vz","epsilon","bmin","bmax","KdTree","_vertices","_kdNodes","_vertexIndices","_numPrimitiveIndices","createPrototypeObject","indices","p0","p1","p2","buildTree","_intersectFunctor","functor","vIds","setPrimitiveIndex","pIndex","numVertices","notify","error","intersect","enter","leave","intersectLineSegment","ls","le","e","kNode","kNodes","MorphAttribute","nbTarget","disable","StateAttribute","_nbTarget","_enable","_targetNames","_hashNames","_hash","_dirtyHash","uniforms","createPrototypeStateAttribute","attributeType","cloneType","hasTarget","copyTargetNames","names","tNames","hash","nbNames","att","getOrCreateUniforms","obj","unifHash","getNumTargets","uTargetWeights","Uniform","createFloat4","setNumTargets","nb","setTargetWeights","targetWeight","_targetWeights","getTargetWeights","isEnabled","getHash","_computeInternalHash","getTypeMember","uniformMap","setFloat4","getAttributeType","array","type","Int16Array","Int8Array","Uint8Array","Uint8ClampedArray","Int32Array","BufferArray","target","elements","itemSize","GLObject","_instanceID","getInstanceID","dirty","_itemSize","_target","_type","_normalize","byteLength","warn","ELEMENT_ARRAY_BUFFER","setElements","_usage","STATIC_DRAW","ARRAY_BUFFER","DYNAMIC_DRAW","STREAM_DRAW","_sDeletedGLBufferArrayCache","Map","deleteGLBufferArray","gl","buffer","has","set","flushDeletedGLBufferArrays","availableTime","elapsedTime","beginTime","Timer","instance","tick","deleteList","numBuffers","deleteBuffer","deltaS","flushAllDeletedGLBufferArrays","onLostContext","setUsage","usage","getUsage","setItemSize","size","isValid","_buffer","_elements","invalidate","releaseGLObjects","_gl","removeObject","setNormalize","normalize","getNormalize","setGraphicContext","bindBuffer","createBuffer","_numItems","getItemSize","_dirty","isDirty","compile","bufferData","getType","defaultOptions","prefixURL","databasePath","progressXHRCallback","readNodeURL","readImageURL","readBinaryArrayURL","imageLoadingUsePromise","imageOnload","imageCrossOrigin","rejectObject","Input","json","identifier","_json","map","_identifierMap","_objectRegistry","_cacheReadObject","setOptions","objectMix","Options","imageFallback","fallback","Image","src","clone","input","_defaultOptions","getOptions","setProgressXHRCallback","setReadNodeURLCallback","registerObject","fullyQualifiedObjectname","constructor","getJSON","setJSON","setPrefixURL","prefix","getPrefixURL","setDatabasePath","path","getDatabasePath","computeURL","url","requestFile","fileHelper","requestURI","getObjectWrapper","scope","osg","splittedPath","split","fetchImage","image","checkInlineImage","isInlineImage","substring","img","crossOrigin","setURL","setImage","P","resolve","onerror","onload","substr","opt","that","index","lastIndexOf","ReaderParser","require","default","readSceneGraph","parseSceneGraph","then","child","log","ungzipFile","arrayBuffer","pad","uintToString","uintArray","str","len","toString","decodeURIComponent","unpacked","zlib","isGunzipBuffer","gunzip","typedArray","time","INFO","fileTextPromise","JSON","parse","fileGzipPromise","responseType","file","strUnzip","catch","status","err","finally","timeEnd","_unzipTypedArray","binary","_zlib","zdec","Gunzip","decompress","filePromise","progress","initializeBufferArray","vb","buf","File","bigEndian","a","b","offset","Offset","bytesPerElement","BYTES_PER_ELEMENT","nbItems","Size","nbCoords","totalSizeInBytes","TypedArray","tmpArray","DataView","getUint16","getFloat32","getUint32","readBufferArray","osgjsObject","promise","jsonObj","uniqueID","UniqueID","Elements","Array","ItemSize","Type","keys","readUserDataContainer","Values","readPrimitiveSet","count","drawElements","DrawElementUShort","DrawElementUByte","DrawElementUInt","DrawElementsUShort","DrawElementsUByte","DrawElementsUInt","drawArray","DrawArray","DrawArrays","drawArrayLengths","DrawArrayLengths","Mode","TRIANGLES","DrawElements","Indices","setIndices","First","Count","ArrayLengths","readObject","objKeys","prop","ObjectWrapper","serializers","sub","reader","_uniqueID","Texture","WebGLCaps","_checkRTT","_webGLExtensions","_webGLParameters","_webGLShaderMaxInt","_webGLShaderMaxFloat","_bugsDB","_webGLPlatforms","glParam","force","_instance","oldWebGLInspector","webglInspector","gli","host","inspectContext","document","createElement","width","height","extend","antialias","extendWithOptionsURL","WebGLUtils","setupWebGL","getContext","initContextDependant","_isGL2","WebGL2RenderingContext","initWebGLExtensions","hasLinearHalfFloatRTT","hasLinearFloatRTT","hasHalfFloatRTT","hasFloatRTT","initWebGLParameters","initPlatformSupport","initBugDB","nativeExtension","ext","getWebGLExtensions","dummyFunc","isWebGL2","Apple","UNMASKED_VENDOR_WEBGL","indexOf","getExtension","test","text","join","hasSupport","checkShader","shader","createShader","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","isContextLost","getShaderInfoLog","navigator","vendor","Mobile","userAgent","getWebGLPlatform","getWebGLPlatforms","getWebGLParameter","getWebGLParameters","getShaderMaxPrecisionFloat","MAX_SHADER_PRECISION_FLOAT","getShaderMaxPrecisionInt","MAX_SHADER_PRECISION_INT","checkSupportRTT","typeFloat","typeTexture","texture","createTexture","bindTexture","TEXTURE_2D","texImage2D","RGBA","texParameteri","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","framebuffer","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","deleteTexture","deleteFramebuffer","HALF_FLOAT_OES","LINEAR","FLOAT","NEAREST","queryPrecision","shaderType","precision","answer","getShaderPrecisionFormat","hasVAO","getDisjointTimerQuery","limits","params","par","getParameter","FRAGMENT_SHADER","HIGH_FLOAT","MEDIUM_FLOAT","LOW_FLOAT","HIGH_INT","MEDIUM_INT","LOW_INT","debugInfo","UNMASKED_RENDERER_WEBGL","applyExtension","suffix","suffixRE","RegExp","prefixRE","val","unsuffixedKey","replace","unprefixedKey","getWebGLExtension","_checkShader","_doubleCheckExtension","extension","filterBugs","doFilter","supported","getSupportedExtensions","sup","extToCheck","anisoExt","ANISOTROPIC_SUPPORT_EXT","ANISOTROPIC_SUPPORT_MAX","MAX_TEXTURE_MAX_ANISOTROPY_EXT","functorDrawElements","functorDrawArrays","POINTS","v","indexes","cb","end","LINES","v1","v2","LINE_STRIP","LINE_LOOP","last","v3","pos","primitiveFunctor","cbFunctor","primitive","getFirst","_name","_inputs","_outputs","_id","_text","getID","getInputs","getOutputs","checkInputsOutputs","validInputs","validOutputs","inputs","arguments","isArray","outputs","autoLink","output","computeShader","comment","txt","_comment","getComment","isString","String","isBlobURL","isHttpURL","isURL","zip","mimeTypes","createImageFromURL","reject","createImageFromBlob","blob","privateURL","URL","createObjectURL","revokeObjectURL","createArrayBufferFromBlob","fr","FileReader","readAsArrayBuffer","createArrayBufferFromURL","createJSONFromURL","string","createJSONFromString","requestResource","uri","mimetype","getMimeType","toLowerCase","match","resolveData","createData","Blob","resolveFilesMap","filesMap","promises","filename","fname","dataResolved","all","_unzipEntry","entry","Writer","BlobWriter","TextWriter","getData","unzipBlob","filePromises","createReader","BlobReader","zipReader","getEntries","entries","directory","close","filesMapResolved","unzip","ArrayBuffer","readFileList","fileList","fileName","promiseArray","readerWriter","Registry","getReaderWriterForExtension","mimeType","files","readerParser","addMimeTypeForExtension","_attributeTypeIndex","OFF","ON","OVERRIDE","PROTECTED","INHERIT","OVERRIDE_ON","CullSettings","_computeNearFar","_nearFarRatio","_enableFrustumCulling","_settingsSourceOverrider","_LODScale","_clampProjectionMatrixCallback","setCullSettings","settings","setNearFarRatio","ratio","getNearFarRatio","setComputeNearFar","getComputeNearFar","setEnableFrustumCulling","getEnableFrustumCulling","getSettingSourceOverrider","setClampProjectionMatrixCallback","callback","getClampProjectionMatrixCallback","setLODScale","scale","getLODScale","_onLostContextCallback","addObject","getGraphicContext","setLostContextCallback","_sResourcesArrayCache","glObject","resourcesArray","Plane","vec4","INSIDE","INTERSECT","OUTSIDE","transformProvidingInverse","iplane","x","y","z","w","normalizeEquation","plane","inv","sqrt","getNormal","setNormal","normal","getDistance","setDistance","distance","distanceToPlane","position","intersectsOrContainsBoundingSphere","bSphere","valid","center","radius","instersectsBoundingSphere","intersectsOrContainsBoundingBox","retCorner","bbox","upperBBCorner","lowerBBCorner","corner","intersectsBoundingBox","absPlane","intersectOrContainsVertices","side","intersectVertices","clamp","smoothStep","edge0","edge1","fastIsNaN","isNaN","SkinningAttribute","boneUniformSize","_boneUniformSize","maxBoneUniformSize","maxBoneUniformAllowed","getBoneUniformSize","boneSize","uBones","createFloat4Array","setMatrixPalette","matrixPalette","_matrixPalette","getMatrixPalette","getInternalArray","now","global","performance","Date","fn","mozNow","msNow","oNow","webkitNow","t0","t1","deltaM","BillboardAttribute","_attributeEnable","setEnabled","state","ColorMask","red","green","blue","alpha","_red","_green","_blue","_alpha","setMask","applyColorMask","EllipsoidModel","_radiusEquator","WGS_84_RADIUS_EQUATOR","_radiusPolar","WGS_84_RADIUS_POLAR","computeCoefficients","setRadiusEquator","getRadiusEquator","setRadiusPolar","getRadiusPolar","convertLatLongHeightToXYZ","latitude","longitude","sinLatitude","sin","cosLatitude","cos","N","_eccentricitySquared","X","Y","Z","convertXYZToLatLongHeight","theta","atan2","eDashSquared","sinTheta","cosTheta","atan","cosLat","computeLocalUpVector","coord","isWGS84","flattening","computeLocalToWorldTransformFromLatLongHeight","fromTranslation","computeCoordinateFrame","computeLocalToWorldTransformFromXYZ","lla","up","east","north","localToWorld","cross","ImageStream","video","_canPlayDefered","PAUSE","PLAYING","_status","STOP","addEventListener","_imageObject","loop","stop","setLooping","bool","play","pause","whenReady","readyState","LineWidth","lineWidth","PointSizeAttribute","_pointSize","_circleShape","setCircleShape","isCircleShape","setPointSize","pointSize","createFloat","setFloat","TextureCubeMap","_images","TEXTURE_CUBE_MAP_POSITIVE_X","setDefaultParameters","_textureTarget","TEXTURE_CUBE_MAP","_flipY","faceImage","getImage","imageFace","imageFormat","face","setImageFormat","setTextureSize","getWidth","getHeight","_textureNull","initCubemapContent","internalFormat","_internalFormat","applyTexImage2D","_textureWidth","_textureHeight","TEXTURE_CUBE_MAP_NEGATIVE_X","TEXTURE_CUBE_MAP_POSITIVE_Y","TEXTURE_CUBE_MAP_NEGATIVE_Y","TEXTURE_CUBE_MAP_POSITIVE_Z","TEXTURE_CUBE_MAP_NEGATIVE_Z","generateMipmap","hasMipmapFilter","hasMipmap","getMipmap","_dirtyMipmap","applyImageTarget","isReady","setDirty","isTypedArray","_unrefImageDataAfterApply","release","initCubemapContentImage","_dirtyTextureObject","_textureObject","computeTextureFormat","applyFilterParameter","isDirtyMipmap","TriangleIndexFunctor","_geom","_cb","AutoTransform","BlendColor","BlendFunc","BoundingSphere","BufferArrayProxy","Camera","ComputeBoundsVisitor","ComputeMatrixFromNodePath","CullFace","FrontFace","CullingSet","CullStack","CullVisitor","Depth","FrameBufferObject","FrameStamp","Geometry","KdTreeBuilder","Light","LightSource","Lod","Material","osgjsMath","PooledResource","PooledMap","NodeVisitor","PagedLOD","Polytope","Program","RenderBin","RenderLeaf","RenderStage","Shader","Shape","StackObjectPairPool","State","StateGraph","StateSet","Scissor","Switch","UpdateVisitor","Viewport","VertexArrayObject","vec2","glm","quat","mat3","ABSOLUTE_RF","TimerGPU","createFunction","_createFunction","getOrCreateObject","_parents","_attributeArray","_textureAttributeArrayList","_activeTextureAttributeUnit","_activeAttribute","_activeTextureAttribute","_binName","_binNumber","_shaderGeneratorPair","_updateCallbackList","_hasUniform","_drawID","AttributePair","attr","_object","_value","getShaderGeneratorName","getAttribute","getUniform","getValue","setDrawID","id","getDrawID","getAttributePair","attribute","addUniform","uniform","originalMode","addParent","removeParent","idx","removeUniform","removeUniformByName","uniformName","hasUniform","getUniformList","setTextureAttributeAndModes","unit","_setTextureAttribute","getNumTextureAttributeLists","getTextureAttribute","typeMember","getTextureIdFromTypeMember","_hasTextureAttribute","textureArray","removeTextureAttribute","_computeValidTextureUnit","getIdFromTypeMember","_hasAttribute","setAttributeAndModes","_setAttribute","setAttribute","removeAttribute","_computeValidAttribute","setRenderingHint","hint","setRenderBinDetails","getUpdateCallbackList","removeUpdateCallback","parent","setNumChildrenRequiringUpdateTraversal","getNumChildrenRequiringUpdateTraversal","requiresUpdateTraversal","dontNoticeParents","Boolean","hasUpdateCallback","num","binName","getAttributeMap","attributePair","getBinNumber","getBinName","setBinNumber","binNum","setBinName","getAttributeList","attributeArray","list","setShaderGeneratorName","generatorName","getShaderGeneratorPair","k","arrayDense","getOrCreateTextureStateAttributeTypeMemberIndex","textureAttributeArrayList","attributeList","hasValidAttribute","getOrCreateStateAttributeTypeMemberIndex","typeIndex","setReferenceFrame","getReferenceFrame","computeBoundingSphere","identity","transformMat4","_data","_transpose","_glCall","_cache","_isMatrix","isUniform","getPrototypeOf","location","setInternalArray","f","setFloat1","setFloat2","setFloat3","setFloat9","setFloat16","setVec2","setVec3","setVec4","setMatrix4","setMatrix3","setInt","setInt1","setInt2","setInt3","setInt4","createUniformX","dataOrName","nameOrNbItem","internalArray","glSignature","isMatrix","nbElts","createMat2","nbItem","out","createMat3","createMat4","_getNbItem","createFloat1","createFloat2","createFloat3","createInt1","createInt2","createInt3","createInt4","createMatrix2","createMatrix3","createMatrix4","float","createFloatArray","createFloat2Array","createFloat3Array","int","createIntArray","createInt","vec2i","createInt2Array","vec3i","createInt3Array","vec4i","createInt4Array","mat2","createMat2Array","createMat3Array","createMat4Array","AnimationUpdateCallback","checkPathIsAnimated","nbNodes","ups","nbUp","computeChannels","Renderer","camera","_state","_camera","_renderStage","_stateGraph","_frameStamp","_previousCullsettings","setDefaults","debugGraph","osgShader","ShaderGeneratorProxy","_cullVisitor","setRenderer","getCamera","setClearColor","setRenderStage","stateSet","getOrCreateStateSet","getCullVisitor","setCullVisitor","cv","getRenderer","rs","setFrameStamp","fs","getFrameStamp","getState","setState","gc","cullAndDraw","cull","draw","view","getView","resetStats","setStateGraph","pushStateSet","getStateSet","pushCameraModelViewProjectionMatrix","getViewMatrix","getBound","light","getLight","View","getLightingMode","LightingMode","HEADLIGHT","addPositionedAttribute","SKY_LIGHT","viewport","getViewport","scissor","getScissor","pushViewport","setClearDepth","getClearDepth","getClearColor","setClearMask","getClearMask","setViewport","setScissor","setDatabaseRequestHandler","getDatabasePager","handleCullCallbacksAndTraverse","popCameraModelViewProjectionMatrix","popViewport","popStateSet","sort","resetCacheFrame","setCamera","DisplayGraph","createRenderGraph","applyDefault","_frame","_startSimulation","_currentSimulation","_deltaTime","setReferenceTime","getReferenceTime","setSimulationTime","getSimulationTime","setDeltaTime","getDeltaTime","setFrameNumber","getFrameNumber","ShaderGenerator","_shaderProcessor","NextShaderProcessor","_ShaderCompiler","setShaderCompiler","Compiler","ShaderCompiler","_validAttributeTypeMemberCache","_computeStateAttributeCache","getShaderCompiler","getShaderProcessor","setShaderProcessor","shaderProcessor","filterAttributeTypes","getActiveAttributeList","cacheType","attributeStack","_lastApplied","getActiveAttributeListCache","getActiveTextureAttributeListCache","_validTextureAttributeTypeMemberCache","textureUnitList","textureUnit","textureUnitLength","isTextureNull","getActiveTextureAttributeList","_attributeArrayList","_attributeArrayForUnit","getActiveUniforms","textureAttributeList","at","attributeUniformMap","keyAttribute","tat","texUniformMap","tname","tuniform","CompilerShader","typeMemberName","il","cache","typeMemberNames","stateAttributeConfig","validTypeMemberList","textureAttribute","_createWaitingProgram","attributes","textureAttributes","vsDefault","fsDefault","program","VERTEX_SHADER","setActiveUniforms","generated","getOrCreateProgram","cachedProgram","_getProgram","_createProgram","shaderGen","debug","Attributes","Hash","getFragmentShaderName","fragmentshader","createFragmentShader","vertexshader","createVertexShader","resetCache","setText","debugName","VS_DBG","FS_DBG","_sDeletedGLShaderCache","deleteGLShader","flushDeletedGLShaders","numShaders","deleteShader","flushAllDeletedGLShaders","getText","failSafe","shaderText","shaderName","debugShaderTxt","processErrors","errors","source","lines","linesLength","exec","lastIndex","line","parseInt","minLine","maxLine","getCompilationResult","errorCallback","splittedText","newText","errorFold","EventHandle","owner","unbind","on","WeightEventHandle","unbindWeight","Events","_events","_suspendEvents","_weightEvents","timer","clearTimeout","args","setTimeout","events","weight","event","ok","self","evt","arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","ex","console","info","_suspendHighEvents","allowSwiftShader","animationAutoplay","anisotropy","annotation","annotationTooltipVisible","arkit","arkitDebug","asyncImage","asyncShader","autoMaterial","autospin","autostart","cameraConstraints","cameraFollowBones","cardboard","carmel","cleanShader","continuousRender","convertVertexColor8Bit","debug3D","depthMipmap","dofAttenuateDistance","dofAttenuateSpeed","dofCircle","dofRes","dofSticky","dofTransition","doubleClick","downloadPicture","drs","drsRatio","drsFps","drsMin","drsTest","epsilonAlpha","floatRtt","forceController","forceControllerOrientation","forceControllerRayOrientation","forceFallback","forceMs","forceTriangles","fpsSpeed","grainSpeed","graphOptimizer","imageCompression","internal","isApp","keepEmptyGeometries","materialNames","materialPacking","materialShowcase","maxTextureUnits","maxDevicePixelRatio","maxTextureSize","maxVertexUniforms","mergeMaterials","morphEpsilon","morphGpu","navigation","orbitPanFactor","orbitRotationFactor","orbitZoomFactor","panorama","powerPreference","preload","preserveDrawingBuffer","processMaterial","processOptions","refractionRes","resizeTimeout","rgbm","scaleEpsilon","scrollwheel","shadow","shadowAtlas","shadowJitterOffset","shadowNormalOffset","shadowPCF","shadowTextureSize","share","snapKeyframe","soundEnable","soundMute","soundPreload","splitLimit","ssaoNormal","ssrTransparent","sssJitter","sssKernel","stats","svgSize","substanceDisplacement","supersample","tracking","taaAnimation","taaFeedbackMax","taaFeedbackMin","textureFrameBudget","transparent","uiAnimations","uiAnnotations","uiAr","uiArHelp","uiArQrcode","uiColor","uiControls","uiFadeout","uiFullscreen","uiGeneralControls","uiHelp","uiHint","uiInfos","uiInspector","uiInspectorOpen","uiLoading","uiSettings","uiSnapshots","uiSound","uiStart","uiStop","uiTheatre","uiVr","uiWatermark","uiWatermarkLink","unitRenderLocal","unitRenderReporter","useVao","varyingSorting","vrAr","vrBrowserEnv","vrFade","vrLauncherAlphaCardFactor","vrMirror","vrMobileMaxFaces","vrGenerateUiTextures","vrForceRaf","vrLinkNavigation","vrInNavigation","vrScaleRtt","vrStereo","webglExt","webglRestore","webglTimerGpu","webglUniforms","zoct","zq","zw","zratio","zz","annotationCycleAutostart","annotationCycleDuration","sssHalfKernel","preferOriginalNormalMap","Manipulator","_boundStrategy","boundStrategy","setInputManager","inputManager","COMPUTE_HOME_USING_SPHERE","_controllerList","_inverseMatrix","_node","_frustum","_computeBoundNodeMaskOverride","_tmpSphere","setNode","setComputeBoundNodeMaskOverride","mask","getComputeBoundNodeMaskOverride","_inputManager","getInputManager","getHomeBoundingSphere","overrideStrat","COMPUTE_HOME_USING_BBOX","box","cbv","setNodeMaskOverride","getBoundingSphere","bsphere","volume","copyBoundingBox","getHomeBound","getHomeDistance","bound","frustum","dist","getFrustum","vertical2","zNear","horizontal2","top","bottom","update","getInverseMatrix","getControllerList","Controller","manipulator","_manipulator","setEnable","InputGroups","degtorad","PI","makeRotateFromEuler","q","order","c1","c2","c3","s1","s2","s3","FirstPersonManipulatorDeviceOrientationController","computeQuaternion","screenTransform","worldTransform","deviceOrientation","screenOrientation","beta","gamma","screenAngle","minusHalfAngle","yTemp","_quat","_pos","_deviceOrientation","_screenOrientation","manager","group","FPS_MANIPULATOR_DEVICEORIENTATION","addMappings","setDeviceOrientation","setScreenOrientation","ev","_update","setPoseVR","OrbitManipulatorDeviceOrientationController","ORBIT_MANIPULATOR_DEVICEORIENTATION","FirstPersonDeviceOrientation","OrbitManipulatorGamePadController","_delay","_zoomFactor","_rotateFactor","_panFactor","_rotate","getRotateInterpolator","_zoom","getZoomInterpolator","_pan","getPanInterpolator","setDelay","ORBIT_MANIPULATOR_GAMEPAD","addZoom","addRotateX","addRotateY","panUp","pan","panDown","panLeft","panRight","delta","panTarget","getTarget","setTarget","addTarget","OrbitManipulatorHammerController","_lastScale","_zooming","_dragStarted","_initInputs","ORBIT_MANIPULATOR_TOUCH","pinchEnd","pinchStart","pinchInOut","startPan","startRotate","rotate","endMotion","_panning","startMotion","_rotating","move","interpolator","factor","canvasX","canvasY","zoomInterpolator","zoomFactor","minDezoom","maxDezoom","aSmooth","velocity","osgMath","setManipulator","ROTATE","PAN","ZOOM","OrbitManipulatorStandardMouseKeyboardController","_mode","_inMotion","ORBIT_MANIPULATOR_MOUSEKEYBOARD","ORBIT_MANIPULATOR_RESETTOHOME","globalGroup","resetToHomeGroup","setRotationMode","setMode","OrbitManipulatorEnums","setPanMode","setZoomMode","startZoom","stopMotion","zoom","getZoomFactor","setZoomFactor","posX","posY","isReset","setStart","getStart","intDelta","deltaY","zoomTarget","computeHomePosition","tempQuat","tempPos","OrbitManipulatorWebVRController","ORBIT_MANIPULATOR_WEBVR","pose","orientation","sitToStandMatrix","getRotation","worldFactor","DelayInterpolator","delay","redrawCB","_current","_delta","_reset","_start","_redrawCB","dt","dtDelay","getCurrent","getDelta","start","OrbitManipulator","_homePosition","AvailableControllerList","ControllerList","TWO_PI","lowerOrEqual","limit","MIN_ZOOM","MAX_ZOOM","_distance","_upz","rot1","fromRotation","rot2","_rotation","_time","_vrMatrix","_minSpeed","_scaleMouseMotion","_autoPushTarget","_limitPitchUp","_limitPitchDown","_limitYawLeft","_limitYawRight","_limitZoomIn","_limitZoomOut","_constrainYaw","_constrainPitch","_constrainZoom","_rotationFactor","setRotationFactor","setPanFactor","setLimitPitchUp","setLimitPitchDown","down","setLimitYawLeft","setLimitYawRight","setLimitZoomOut","zoomOut","setLimitZoomIn","zoomIn","setConstrainPitch","_previousPitch","isConstrainPitch","setConstrainYaw","constrain","_previousYaw","isConstrainYaw","setConstrainZoom","isConstrainZoom","eyePos","getEyePosition","setEyePosition","u","eye","enabled","Groups","ORBIT_MANIPULATOR","bs","getHomePosition","computeEyePosition","setMinSpeed","getMinSpeed","getSpeedFactor","computePan","proj","vFov","speed","add","computeRotation","rightDir","prevPitch","pitch","_computePitch","deltaYaw","previousYaw","yaw","_computeYaw","isOutsideLimit","computeZoom","setAutoPushTarget","dir","newValue","tmpDist","tmpInverse","nv","panFactor","lookAt","fromQuat","DeviceOrientation","GamePad","Hammer","WebVR","StandardMouseKeyboard","WebGLDebugUtils","msg","glValidEnumContexts","enable","1","0","drawArrays","3","4","2","getProgramParameter","getVertexAttrib","vertexAttribPointer","6","activeTexture","getTexParameter","texParameterf","copyTexImage2D","8","copyTexSubImage2D","getBufferParameter","pixelStorei","bindRenderbuffer","framebufferRenderbuffer","5","getFramebufferAttachmentParameter","getRenderbufferParameter","renderbufferStorage","clear","enumBitwiseOr","depthFunc","blendFunc","blendFuncSeparate","blendEquation","blendEquationSeparate","stencilFunc","stencilFuncSeparate","stencilMaskSeparate","stencilOp","stencilOpSeparate","cullFace","frontFace","drawArraysInstancedANGLE","drawElementsInstancedANGLE","blendEquationEXT","bufferSubData","copyBufferSubData","getBufferSubData","blitFramebuffer","10","9","framebufferTextureLayer","invalidateFramebuffer","invalidateSubFramebuffer","readBuffer","getInternalformatParameter","renderbufferStorageMultisample","texStorage2D","texStorage3D","7","texImage3D","11","texSubImage2D","texSubImage3D","12","copyTexSubImage3D","compressedTexImage2D","compressedTexImage3D","compressedTexSubImage2D","compressedTexSubImage3D","vertexAttribIPointer","drawArraysInstanced","drawElementsInstanced","drawRangeElements","readPixels","clearBufferfv","clearBufferiv","clearBufferuiv","clearBufferfi","beginQuery","endQuery","getQuery","getQueryParameter","samplerParameteri","samplerParameterf","getSamplerParameter","fenceSync","clientWaitSync","waitSync","getSyncParameter","bindTransformFeedback","beginTransformFeedback","transformFeedbackVaryings","bindBufferBase","bindBufferRange","getIndexedParameter","getActiveUniformBlockParameter","glEnums","enumStringToValue","ctx","propertyName","checkInit","mightBeEnum","glEnumToString","glFunctionArgToString","functionName","numArgs","argumentIndex","funcInfo","enums","orResult","orEnums","enumValue","glFunctionArgsToString","argStr","ii","makePropertyWrapper","wrapper","original","__defineGetter__","__defineSetter__","makeDebugContext","opt_onErrorFunc","opt_onFunc","opt_err_ctx","glErrorShadow","makeErrorWrapper","getError","wrapped","NO_ERROR","resetToInitialState","isWebGL2RenderingContext","createTransformFeedback","bindVertexArray","numAttribs","MAX_VERTEX_ATTRIBS","disableVertexAttribArray","vertexAttrib1f","vertexAttribDivisor","numTextureUnits","MAX_TEXTURE_IMAGE_UNITS","TEXTURE0","TEXTURE_2D_ARRAY","TEXTURE_3D","bindSampler","useProgram","RENDERBUFFER","BLEND","CULL_FACE","DEPTH_TEST","DITHER","SCISSOR_TEST","blendColor","FUNC_ADD","ONE","ZERO","clearColor","clearDepth","clearStencil","colorMask","BACK","LESS","depthMask","depthRange","CCW","GENERATE_MIPMAP_HINT","DONT_CARE","PACK_ALIGNMENT","UNPACK_ALIGNMENT","UNPACK_FLIP_Y_WEBGL","UNPACK_PREMULTIPLY_ALPHA_WEBGL","UNPACK_COLORSPACE_CONVERSION_WEBGL","BROWSER_DEFAULT_WEBGL","polygonOffset","sampleCoverage","canvas","ALWAYS","stencilMask","KEEP","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT","drawBuffers","COPY_READ_BUFFER","COPY_WRITE_BUFFER","PIXEL_PACK_BUFFER","PIXEL_UNPACK_BUFFER","numTransformFeedbacks","MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS","TRANSFORM_FEEDBACK_BUFFER","numUBOs","MAX_UNIFORM_BUFFER_BINDINGS","UNIFORM_BUFFER","RASTERIZER_DISCARD","UNPACK_IMAGE_HEIGHT","UNPACK_SKIP_IMAGES","UNPACK_ROW_LENGTH","UNPACK_SKIP_ROWS","UNPACK_SKIP_PIXELS","PACK_ROW_LENGTH","PACK_SKIP_ROWS","PACK_SKIP_PIXELS","FRAGMENT_SHADER_DERIVATIVE_HINT","makeLostContextSimulatingCanvas","unwrappedContext_","onLost_","onRestored_","wrappedContext_","contextId_","contextLost_","resourceDb_","numCallsToLoseContext_","numCalls_","canRestore_","restoreTimeout_","glErrorShadow_","wrapEvent","listener","handleEvent","WebGLRenderingContext","makeLostContextSimulatingContext","addOnContextLostListener","addOnContextRestoredListener","wrapAddEventListener","bubble","clearErrors","loseContextIfTime","loseContext","makeLostContextFunctionWrapper","freeResources","resource","WebGLBuffer","WebGLFramebuffer","WebGLProgram","deleteProgram","WebGLRenderbuffer","deleteRenderbuffer","WebGLShader","WebGLTexture","WebGLQuery","deleteQuery","WebGLSampler","deleteSampler","WebGLSync","deleteSync","WebGLTransformFeedback","deleteTransformFeedback","WebGLVertexArrayObject","deleteVertexArray","makeWebGLContextEvent","statusMessage","preventDefault","CONTEXT_LOST_WEBGL","callbacks","restoreContext","loseContextInNCalls","numCalls","getNumCalls","setRestoreTimeout","timeout","creationFunctions","__webglDebugContextLostId__","functionsThatShouldReturnNull","isFunctions","FRAMEBUFFER_UNSUPPORTED","getAttribLocation","getVertexAttribOffset","getFragDataLocation","WAIT_FAILED","getUniformBlockIndex","INVALID_INDEX","Graph","_values","maxGraphValue","_index","_maxValue","_x","_y","getIndex","getValues","setDisplayPosition","getX","getY","addValue","uvColor","BufferStats","_usageHint","nbVertexes","_nbVertexes","_maxNbVertexes","_captionNbVertexes","_valuesNbVertexes","_graphsNbVertexes","resize","backgroundColor","redColor","greyColor","whiteColor","getGeometry","_geometry","generateBackground","h","vertexes","_vertexes","x1","y1","generateCharacter","ux","ux1","color","generateText","textGenerator","zColor","characterSizeUV","_characterSizeUV","characterWidth","_characterWidth","characterHeight","_characterHeight","characterCode","charCodeAt","uvx","getCharacterUV","generateGraph","graph","graphValues","nbGraphValues","graphStartIndex","graphIndex","graphValue","bufferIndex","vertexIndex","nbCharacters","ceil","_indexes","_characterPrimitive","getIndices","indexArray","drawElement","getPrimitives","_graphPrimitive","nbTotalCharacters","setCount","setFirst","resetCaptions","resetValues","captionsEnd","valuesEnd","graphsEnd","getCharacterPrimitive","getGraphPrimitive","getNbVertexes","Counter","config","_caption","caption","_accumValue","_accumSamples","_accumStart","_averageValue","_avgMs","_over","over","_below","below","_graph","average","avgMs","_display","isDisplayable","setDisplayable","boolean","getOver","getBelow","getGraph","getAverageMs","getAverageValue","frame","DefaultFont","determineFontHeight","fontStyle","body","getElementsByTagName","dummy","dummyText","createTextNode","appendChild","offsetHeight","removeChild","loadFont","fontFamily","WebFontConfig","google","families","active","inactive","wf","scripts","async","parentNode","insertBefore","TextGenerator","_canvas","_fontSize","_fontFamily","_characterFirstCode","_characterLastCode","_backgroundColor","_createCanvas","setFontSize","getCharacterWidth","getCharacterHeight","getCanvas","_promise","_fillCanvas","fontSize","style","pixelHeight","font","textBaseline","measureText","fillStyle","code","fromCharCode","fillText","PICKING_NODEMASK","toFixed","Stats","viewer","_captionsBuffer","_valuesBuffer","_dirtyCaptions","_dirtyValues","_viewer","_labelMaxWidth","_viewport","_offsetGroup","_counters","_groups","_updates","_displayableCounters","_width","_height","_maxCaptionTextLength","_lineFactor","_displayFilter","_backgroundWidth","_backgroundHeight","_bufferStats","_historyGraph","_graphToDisplay","_valuesMaxWidth","_showGraph","_backgroundPicking","shape","createTexturedQuadGeometry","_dragStop","_dragStart","_startTransformation","_init","getCounter","getBufferStats","addConfig","valueName","values","valueConfig","counter","groups","groupConfig","textCursorY","_dirtyValue","_checkViewportChanged","_checkCounterDisplayableChanged","_generateCaptions","_generateValues","getNode","setShowFilter","groupNamesArray","setRenderOrder","POST_RENDER","addChild","_nodeTransform","setNodeMask","statsGroupList","getString","filterList","statsFontSize","getNumber","getBoolean","setMinFilter","setMagFilter","getCanvasPixelRatio","geometry","setBound","DISABLE","STATS","onMouseMove","onMouseDown","onMouseUp","setPriority","getHigherPriority","SCENE","hits","computeNearestIntersection","_onStats","tmpVec3","translate","lsi","LineSegmentIntersector","origIntersect","dstIntersect","IntersectionVisitor","setIntersector","glX","glY","setTraversalMask","accept","getIntersections","_updateBackgroundPicking","initialX","textCursorX","filters","groupName","groupText","textWidth","counterName","nbSplits","splitText","valuesOffsetX","graphOffsetX","valuesMaxWidth","Number","isInteger","valueWidth","g","totalWidth","totalHeight","changed","ortho","fps","raf","render","glframe","textureused","texturereserved","texturetotal","pushstateset","applyStateSet","updatecallback","cullcamera","cullmatrixtransform","cullprojection","cullnode","culllightsource","cullgeometry","base","contextList","glProxy","totalDrawArraysCalls","totalDrawElementsCalls","totalUseProgramCalls","totalFaces","totalVertices","totalPoints","totalBindTexures","statsVertices","statsFaces","statsLines","hasContext","WebGLContext","bufferStats","glDrawCalls","glDrawElements","glDrawArrays","glBindTexture","glUseProgram","glFaces","glVertices","glPoints","memory","log1024","floor","round","pow","totalJSHeapSize","usedJSHeapSize","browserMemory","browserMemoryTotal","DEFAULT_PRIORITY","MODIFIERS","InputGroup","_enabled","_mask","_mappings","_boundCallback","_collectNativeEvents","_priority","_hasSources","mappings","nativeEvent","_source","isEventRegistered","_parsedEvent","populateEvent","_nativeEvents","queue","_queues","_addEvent","eventName","fullName","registerEvent","_findEvent","raw","eventList","Event","_getSource","nativeRaw","_setEnable","InputManager","_sources","_callbacks","_params","_maskedGroups","dumpInputGroups","_dumpInputGroups","dumpEventSequence","_dumpEventSequence","registerInputSource","supportsEvent","stringify","getInputSource","nativeEvents","groupEvent","parsedEvent","_getOrCreateGroup","_parseNativeEvent","priority","getParam","setParam","cleanup","tokens","token","action","mod","poll","triggerName","filter","onlyEnabled","groupCollapsed","groupEnd","groupKey","eventKey","evts","prevEvt","grp","InputSource","_supportedEvents","mouseDeltaFactor","deltaYFactor","platform","InputSourceMouse","_defaultRatio","removeEventListener","customEvent","offsetX","layerX","offsetY","layerY","clientHeight","clientX","clientY","screenX","pageX","pageY","ctrlKey","shiftKey","altKey","metaKey","button","buttons","wheelDelta","deltaMode","deltaX","deltaZ","ctrl","alt","meta","InputSourceKeyboard","keyCode","repeat","InputSourceWebVR","elem","_nbCallbacks","_pollInterval","pollInterval","_schedulePolling","_cancelPolling","vrDisplay","_pollingTimeout","setInterval","pollHeadset","clearInterval","getVRDisplays","_hmd","_frameData","triggerNotFoundEvent","displays","_dispatchEvent","VRFrameData","message","setPollInterval","interval","getFrameData","sitToStand","stageParameters","sittingToStandingTransform","InputSourceGamePad","_gamePadState","_valueThreshold","_newGamePad","gamepad","_onConnectionStateChange","_previousState","_buttonEvents","_axisEvents","buttondown","_initEvent","buttonup","buttonvalue","axes","setValueThreshold","threshold","gamepadIndex","_fireCallbacks","gamepads","getGamepads","buttonDownCallbacks","buttonUpCallbacks","buttonValueCallbacks","btnDownEvent","btnUpEvent","pressed","btnValueEvent","axisCallback","axisValueEvent","InputSourceDeviceOrientation","_event","onDeviceOrientation","absolute","InputSourceTouchScreen","_hammerEvents","_hammer","Manager","Pan","Pinch","pointers","pinch","recognizeWith","Tap","taps","posThreshold","_isNativeEvent","off","touches","changedTouches","nbTouches","rotation","deltaTime","direction","offsetDirection","getBoundingClientRect","pointerType","getHammer","Viewer","userOptions","_startTick","_stats","_done","initOptions","initWebGLContext","_updateVisitor","setUpView","initInputManager","initStats","_requestAnimationFrame","requestAnimationFrame","_options","_contextLost","_forceRestoreContext","renderBinded","_initInputSource","setVRDisplay","_devicePixelRatio","sourceClass","optionName","defaultSrcElem","InputSources","sourceElement","traceLogCall","contextLost","contextRestored","reportWebGLError","initWebGLCaps","setContextLostCallback","_contextLostCallback","setContextRestoreCallback","_contextRestoreCallback","cancelAnimationFrame","_requestID","getTextureManager","resetCaches","_requestRedraw","_runImplementation","getUpdateVisitor","timerGPU","defaultStats","glStats","browserStats","setCallback","callbackTimerGPU","queryID","getViewerStats","renderingTraversal","getScene","getSceneData","renderer","pollQueries","cullVisitor","_numCamera","_numMatrixTransform","_numProjection","_numNode","_numLightSource","_numGeometry","_numPushStateSet","_numApply","updateTraversal","updateSceneGraph","_numUpdateCallback","releaseGLExpiredSubgraphs","flushDeletedGLObjects","advance","simulationTime","sTime","MAX_VALUE","frameStamp","previousFrameNumber","lastSimulationTime","beginFrame","endFrame","frameNumber","updateStats","checkNeedToDoFrame","_requestContinousUpdate","canvasSizeChanged","updateViewport","getManipulator","isPresenting","submitFrame","setDone","done","run","hmd","getVRDisplay","setPresentVR","doPresentVR","capabilities","canPresent","layers","requestPresent","exitPresent","setupManipulator","hasChanged","computeCanvasSize","vp","prevWidth","prevHeight","widthChangeRatio","heightChangeRatio","aspectRatioChange","fromScaling","setEnableManipulator","dispose","pooledStateGraph","osgViewer","Scene","GLOBAL_ACTIONS","GLOBAL_FOCUS","SCENE_VIEWERAPI","SCENE_VIEWERAPI_1_4","FOCUS_INSPECTOR","SCENE_INSPECTOR","UI_INSPECTOR","UI","SCENE_INSPECTOR_ZOOM","UI_INSPECTOR_ZOOM","ENVIRONMENT","DEBUG","DEBUG_TRIPICK","DEBUG_GEOMPICK","AUTOSPIN","HOTSPOT","HOTSPOT_VIEWER","HOTSPOT_EDITOR","CAMERA","CAMERA_GIZMO","SOUND","SOUND_GIZMO","WEBVR","WEBVREDITOR","WEBVR_NAVIGATION","WEBVR_DISPLAY","AR","AR_DEBUG","STICKER","FeatureEventManager","_manager","featureManager","xpos","ypos","translation","onDoubleClick","onSingleClick","preventclick","preventmousemove","fallbacksingleclick","focus","preventScroll","envFeature","endRotate","MANIPULATORS","stickerFeature","currentX","currentY","onPreventMouseMove","tempTranslation","onFallbackSingleClick","singleclick","onPreventClick","hotspotFeature","cameraFeature","motion","startDrag","endDrag","OPAQUE","OPAQUE_NO_EARLYZ","BACKGROUND","REFRACTION","TRANSPARENT_CUSTOM_EARLYZ","TRANSPARENT_NO_EARLYZ_PRE","TRANSPARENT","TRANSPARENT_NO_EARLYZ_POST","EXTRA","EDITOR_GIZMO","GRID","TOOLTIP","VR_MENU","WIREFRAME","VR_CURSOR","OUTLINE","DEBUG_2","DEPTH_LESS_WRITE","DEPTH_LESS_NO_WRITE","DEPTH_DISABLE","DEPTH_ALWAYS","DEPTH_NEVER","NEVER","DEPTH_LEQUAL_BACKGROUND_NO_WRITE","LEQUAL","DEPTH_LEQUAL_WRITE","DEPTH_LEQUAL_NO_WRITE","DEPTH_EQUAL_NO_WRITE","EQUAL","COLOR_MASK_NONE","COLOR_MASK_ALPHA","COLOR_MASK_RGBA","BLEND_DISABLE","BLEND_SUBSTRACTIVE","ONE_MINUS_SRC_ALPHA","BLEND_ADDITIVE","CULL_BACK","CULL_FRONT","FRONT","CULL_DISABLE","PickMask","PICK_GEOMETRY_FIXED","PICK_GEOMETRY_ANIMATED","PICK_GEOMETRY_RIG_BOX","PICK_GIZMO_LIGHT","SHADOW_CAST","SHADOW_BOUNDS","PICK_GEOMETRY_SLOW","PICK_GEOMETRY_FAST","PICK_GEOMETRY","PICK","SHADOW","PICK_GEOMETRY_SHADOW","NO_SHADOW","NO_PICK","NO_PICK_NO_SHADOW_CAST","NO_PICK_NO_SHADOW_BOUNDS","NO_PICK_NO_SHADOW","ComposerPostProcess","functionsFile","_functionsFile","_feedbackSwapped","_syncFeedbackUniforms","_syncOnNextFrame","_lastXratio","_lastYratio","_xViewportRatio","_yViewportRatio","_xTextureRatio","_yTextureRatio","_finalPassUpScaleToScreen","_methodWrapUV","_thresholdWrapUV","_texInfos","_screenWidth","_screenHeight","_feedbackData","_cameras","_stateSets","_textureUniforms","_programs","_externalTextures","_internalPasses","_textures","_userTextures","_currentPoolIndex","_texturePool","_firstTexture","setCullCallback","VertexShader","FragmentShader","tex","removeChildren","clearShaderCache","getGlobalXRatio","getGlobalYRatio","setFinalPassUpScaleToScreen","_enforceFromInputParameter","paramName","inputTexture","texName","prevTexture","prevFeedbackTexture","newParam","_updatePassInfoFromInputs","pass","passName","lastPassInfo","outTexture","lastPassSrgb","srgb","textures","_renameTextureAlias","texInfoName","_usages","requestSrgb","orig","encodeSRGB","_setInferredParameter","srgbInferred","paramInfer","param","dest","_createTextureOut","isLastPass","isFloat","UNSIGNED_BYTE","_processUserPasses","userPasses","concat","passes","_preprocessUserPasses","numPasses","outPasses","duplicateNames","_collapsePasses","isNext","funcs","feedbackLoop","rgbmInferred","_hasFreeTexture","immuable","poolTexture","reusable","divisor","getInternalFormatType","getMinFilter","_setOrCreateTextureKey","isLinear","filterEnum","poolKey","_createTexture","_addStateSet","_addTextureToStateSet","textureInfo","isFeedback","_addTextureUniforms","_getUniformName","toUpperCase","uName","uSize","uRatio","_checkInferredParameters","_buildPass","feedbackName","previousTextureUnit","texInfo","nextPass","nextPasses","outputTexture","outputKey","_createFeedbackLoopCameras","_createCamera","_buildGraphFromPasses","previousKey","previousTexture","common","setStateSet","camera1","_createFeedbackLoopCamera","camera2","feedbackLoopData","texture1","texture2","cameraName","dstTexture","srcTexture","srcUnit","PRE_RENDER","attachTexture","quad","createTexturedFullScreenFakeQuadGeometry","swapFeedbackLoopTextures","frame0","_createFuncFromUserData","userFunc","_createTextureInfoFromUserData","userData","userPass","header","collapsible","_canBeCollapsed","currentPass","_mergeWithoutDuplicates","lastPassName","setInternalFormatType","setInternalFormat","_computeHashFromPass","_writeDeclarations","setMethodWrapUV","method","_getInfos","bodySimple","bodyNearest","bodyBias","toExponential","replaceValue","signature","TEXTURE_2D_NEAREST","TEXTURE_2D_BIAS","_extractTextures","infos","_writeFunctionBodies","colorSpacesDefines","functionBodies","defineKeys","getShaderTextPure","includeList","processIncludes","textureDefines","tex2dInfo","TEXTURE_2D_TextureInput","defineInfo","inTex","_writeMainFunction","textureName","arg","_removeDuplicatedUniforms","numLines","fragment","vertexSource","setScreenSize","_getTextureSize","resizeRatio","xViewport","yViewport","xTexture","yTexture","_resizeViewports","_resizeTextureUniforms","xRatio","yRatio","cameras","isRtt","isRenderToTextureCamera","attachment","getAttachments","xFinalRatio","yFinalRatio","tunifs","_resizeFeedbackTextureUniforms","compareFunc","element","addInternalTexture","desc","addExternalTexture","setInputTexture","getCameras","getStateSetPass","getInternalTexture","alias","program2D","programQC","updateFrustum","dR","near","far","nLeft","nRight","nTop","nBottom","fLeft","fRight","fTop","fBottom","vBuff","createDebugFrustrumGeometry","createBoundingBoxGeometry","updateGeometry","createDebugFrustumGeometry","glPrecision","getOrCreateShader","getOrCreateShader2D","getOrCreateShaderQuadCircle","resetPrograms","createDebugLineGeometry","createTorusGeometry","argRadiusOut","argRadiusWidth","argNbRadial","argNbTubular","argArc","radiusOut","radiusWidth","nbRadial","nbTubular","arc","nbTriangles","createCylinderGeometry","argRadiusTop","argRadiusBottom","argHeight","argRadialSegments","argHeightSegments","argTopCap","argLowCap","radiusTop","radiusBottom","radialSegments","heightSegments","topCap","lowCap","heightHalf","createCircleGeometry","segment","createPlaneGeometry","offx","offy","createQuadCircleGeometry","GizmoGeometry","HideCullCallback","blendAttribute","SRC_ALPHA","LineCustomIntersector","testPlane","_testPlane","_inter","setTestPlane","getTranslateDistance","_nbAxis","dist1","dot","_iStart","dist2","_iEnd","a01","b0","det","b1","intersectTriangle","intersectLine","intersectPoint","_TMP_MAT","NodeGizmo","_tmask","_autoInsertMT","_correctPivotOnAutoInsert","_rotateNode","_translateNode","_planeNode","_rotateInLocal","_translateInLocal","_showAngle","_downCanvasCoord","_hoverNode","_keepHoverColor","_isEditing","_editLineOrigin","_editLineDirection","_editOffset","_editLocal","_editWorldTrans","_editWorldScaleRot","_editInvWorldScaleRot","_debugNode","_lastDistToEye","_attachedNode","_pivotOffset","attachToNode","_lsi","_origIntersect","_dstIntersect","_iv","PICK_ARC_X","PICK_ARC_Y","PICK_ARC_Z","PICK_ARROW_X","PICK_ARROW_Y","PICK_ARROW_Z","PICK_PLANE_X","PICK_PLANE_Y","PICK_PLANE_Z","NO_FULL_CIRCLE","CORRECT_PIVOT","PICK_ARC","PICK_ARROW","PICK_PLANE","PICK_GIZMO","GetNearestEditableNode","TRAVERSE_PARENTS","_editableNode","getEditableNode","editMask","traverse","setRotateInLocal","setTranslateInLocal","tmask","setAutoMatrixTransformInsertion","setCorrectPivotOnAutoInsert","isEditing","getAttachedNode","initNodeTranslate","initNodeTranslatePlane","initNodeRotate","NODE_GIZMO","_insertEditNode","mtInsert","_isInserted","_findEditNodeFromNodePath","nodepath","_findEditNodeFromNode","_getEditNodeVisitor","attachToNodePath","editNode","_attachEditNode","userNode","updateGizmoMask","transChildren","getChildren","rotChildren","planeChildren","onNodeHovered","hoverColor","hit","np","_nodePath","unif","drawArcXYZ","drawArc","pickArc","mtXYZ","mtX","mtY","mtZ","hideNode","showAngle","aHeight","aConeHeight","pickStart","pickHeight","mtCone","mtArrow","drawArrow","pickArrow","mtPlane","updateArcRotation","qTmp","quatx","setAxisAngle","quaty","rotateNode","arcs","getTransformType","nodeIn","refFrame","getAttachedNodeWorldMatrix","worldMat","getWorldMatrix","worldTrans","tmpVec","tmpMat","ttype","setCullingActive","getTranslation","scaleFactor","scaleFov","clientWidth","gizmoMatrix","getScale","invScale","worldRot","sortByRatio","_ratio","_canvasWidth","_canvasHeight","computeIntersections","setOnlyGizmoPicking","setOnlyScenePicking","pickGizmo","getCanvasPositionFromWorldPoint","mat","worldPoint","cam","screenPoint","computeWindowMatrix","saveEditMatrices","nm","getNodeMask","startRotateEdit","startTranslateEdit","startPlaneEdit","wm","gizmoMat","projCenter","sign","tang","_localIntersectionPoint","projArc","stateAngle","origin","drawLineCanvasDebug","x2","y2","pickAndSelect","updateRotateEdit","updateTranslateEdit","updatePlaneEdit","mrot","vec","vecX","vecY","vecZ","negatePivot","ox","oy","minClient","angle","nbAxis","uAngle","attMat","negate","tra","coordx","coordy","inter","PolytopeIntersection","IntersectFunctor","Intersection","_intersectionPoints","_maxDistance","_numIntersectionPoints","PolytopeIntersectFunctor","_src","_dest","_maxNumIntersectionsPoints","_intersector","getPolytope","containsBoundingBox","pushCurrentMask","popCurrentMask","addIntersection","arrayUniq","maxDistance","referencePlane","_iReferencePlane","intersection","initIntersection","maxNum","contains","polytope","planeList","getPlanes","resultMask","getCurrentMask","selectorMask","vPrevious","dPrevious","vCurrent","dCurrent","rCurrent","vnew","swap","containsPoint","v0","containsVertex","containsLine","containsTriangle","PolytopeIntersector","Intersector","_polytope","_iPolytope","_referencePlane","transformVec4PostMult","setPolytope","setPlanes","iPlanes","setPolytopeFromWindowCoordinates","xMin","yMin","xMax","yMax","intersectBoundingBox","intersectBoundingSphere","containsBoundingSphere","setGeometry","setIntersectionVisitor","kdtree","getShape","computeTransformedVertices","setCurrentTransformation","iPlaneList","SphereIntersection","_localIntersectionNormal","_i1","_i2","_i3","_r1","_r2","_r3","SphereIntersectFunctor","_center","_radius","r2","dmin","getMin","getMax","sqrDistance","sqrDist","sqrLen","distToSegmentSqr","scaleAndAdd","edge2","diff","_limitOneIntersection","_hit","a00","a11","tmp0","tmp1","numer","denom","zone","invDet","_zone","SphereIntersector","_iCenter","_iRadius","setCenter","setRadius","intersectNode","maxScale","TangentSpaceGenerator","_T","_B","_N","_texCoordUnit","generate","setTexCoordUnit","texCoordUnit","computePrimitiveSet","getNumIndices","nx","Normal","tx","compute","nbElements","tangents","t3","subarray","nt","Tangent","ia","ib","ic","P1","P2","P3","N1","N2","N3","uv1","uv2","uv3","V","B1","B2","B3","T1","T2","T3","Tdst","Bdst","Ndst","tempVec","tempVec2","WebVRCustom","UpdateRecreateOnResize","rttScene","hmdConfig","root","_rttScene","_hmdConfig","_root","isCardboard","hResolution","vResolution","createScene","UpdateOffsetCamera","rootView","offsetView","_rootView","_offsetView","nodeView","setupWebVR","HMD","webVRUniforms","webVRMatrices","aspect","hScreenSize","lensSeparationDistance","distScale","distortionK","fov","vScreenSize","eyeToScreenDistance","perspective","hOffset","interpupillaryDistance","lensShift","leftMat","rightMat","projectionLeft","projectionRight","viewLeft","viewRight","lensCenterLeft","lensCenterRight","hmdWarpParam","chromAbParam","chromaAbParameter","scaleIn","getWebVRShader","createTextureRtt","rttSize","rttTexture","createOrthoRtt","viewportSize","canvasSize","orthoCamera","vw","vh","cw","ch","NESTED_RENDER","createCameraRtt","projMatrix","attachRenderBuffer","DEPTH_ATTACHMENT","DEPTH_COMPONENT16","HMDconfig","rootOverride","worldFactorOverride","getDefaultConfig","rootViewMatrix","rttTextureLeft","rttCamLeft","orthoCameraLeft","rttTextureRight","rttCamRight","orthoCameraRight","UpdateRttCameraCallback","getAssembleShader","fragmentShader","createCameraCanvas","leftEyeTexture","rightEyeTexture","HMDdevice","getEyeParameters","frameData","eyeTextureSize","renderWidth","renderHeight","camRttLeft","leftProjectionMatrix","camRttRight","rightProjectionMatrix","camCanvas","osgUtil","DisplayNormalVisitor","DisplayGeometryVisitor","LineSegmentIntersectFunctor","NO_LIMIT","intersectionEnums","LIMIT_ONE_PER_DRAWABLE","LIMIT_ONE","POINT_PRIMITIVES","LINE_PRIMITIVES","TRIANGLE_PRIMITIVES","ALL_PRIMITIVES","appviewer","getViewerOSGJS","_appviewer","_forcePicking","_frameManager","onFinished","attachNode","hoverNode","redrawShadow","onChanged","clearEvent","_minBox","_visitedBuffers","applyTransform","localMatrix","_matrixStack","IDENTITY","vertex","visitedBuffer","exactEquals","transformedVertices","m00","m10","m20","m30","m01","m11","m21","m31","m02","m12","m22","m32","m03","m13","m23","m33","boxMin","boxMax","curMinX","curMinY","curMinZ","curMaxX","curMaxY","curMaxZ","vertexCount","px","py","pz","m3_X_P","m0_X_P","m1_X_P","m2_X_P","BoundingComputer","modelboxWidthDisplacement","modelboxWithoutDisplacement","_maxWorldDisplacement","BIAS_MIN","BIAS_MAX","maxWorldDisp","_updateModelBoxes","min_disp","max_disp","worldDisp","visitor","getPreciseBox","min_l","max_l","ShaderMaker","_shaderCache","vert","farg","shaderId","defines","defineStrings","shaderHash","shaderCache","_createShader","frag","shaderid","shadername","shaderChunk","addShaders","getShader","SHADER_MAKER","GridVertexShader","GridFragShader","AxisVertexShader","AxisFragShader","TextureVertexShader","TextureFragSHader","WorldGrid","_timeGrid","stateset","GLState","RenderDetail","_grid","createGridGeometry","_axis","createAxisGeometry","_plane","_invalidateNodeBound","_texture","GridTextureImage","GridImage","LINEAR_MIPMAP_LINEAR","texturePlaneSS","FeatureManager","app","_app","_viewerOSGJS","_urlOptions","_features","getFeatures","_nodeGizmo","_nodeGrid","getRootModel","postProcess","_textureDepth","ratioX","ratioY","projectioN","getViewport3d","getPixelRatio","_resourceManager","ResourceManager","widgetAPI","getTabbedWidget","duration","getModel","getCurrentManipulator","boundingSphere","focusOnTargetAndEye","nodeGizmo","_boundingSphere","rootModel","bc","computePreciseBox","modelBoxWithDisp","getModelBoxWithDisplacement","modelroot","features","outline","ground","environment","lighting","sound","hotspot","postprocess","webvr","webVR","ARKit","inspector","lightShadowNode","getNodeShadow","rootNode","getNodeIn","getNodeOut","createGizmoNode","createWorldGrid","feature","nodein","nodeout","globalUniform","rootScene","nodeRootModel","featuerRoot","initGraph","preloadMaxBackground","lightingFeature","environmentFeature","_canvasPixelRatio","focusOnSavedCamera","saveCameraPosition","_featureEventManager","initGlobalClickEvents","addGlobalUniforms","drawFrame","initializePreciseBoundManager","onBeforeUnload","Config","getShadowForcedUpdate","getSuperSample","intensity","SQRT1_2","createIconGeometry","setLightType","createDirectionalGeometry","createSpotGeometry","za","ja","updateCone","createHemiGeometry","Ha","createPointGeometry","updateRadius","dummyTexture","CreatePromise","_imageProxy","ResourceManagerInstance","_enableCache","colorArg","textureOutput","reduce","pre","colorInput","albedo","linear2Srgb","option","minFilter","magFilter","setWrapT","wrapT","setWrapS","wrapS","setMaxAnisotropy","panoramaLUV","integrateBRDFLUV","loadLUV","cubemapLUV","loadCubemapLUV","osgjsImage","htmlImage","imageData","deinterleaveImage4","setWidth","setHeight","maxPower","LN2","images","power","byteSize","newData","getSortedKeyValueString","cubemap","loadImage","cubeFace","res","parameters","notEmptyParameters","StateAtributeRegister","libraryName","className","objectLibraryClass","setTypeID","attributeTypeId","getOrCreateStateAttributeTypeId","EditorLight","lightnum","_position","_ground","DIRECTION","SPOT","POINT","HEMI","tempvec3","boundingsphere","_light","_referenceFrame","getPosition","expandByVec3","ShadowCastAttribute","shadowReceiveAttribute","_shadowReceiveAttribute","setReceiveAttribute","getReceiveAttribute","getDefines","getPrecision","receiveAttributeDirty","_receiveAttributeDirty","ShadowCasterVisitor","_noCastMask","_nodeList","removeNodeFromCasting","st","blend","getSource","depth","getFunc","getWriteMask","setNoCastMask","ComputeMultiFrustumBoundsVisitor","TRAVERSE_ALL_CHILDREN","_pooledMatrix","_bs","traversalMask","worldLightPos","cameraFrustum","cameraNearFar","lightFrustum","_cameraFrustum","_lightFrustum","getCameraPlaneMaskForLightNear","point","_cameraPlaneMaskedByLightNear","setResultMask","transform","pushMatrix","popMatrix","applyBoundingBox","bbOut","ShadowReceiveAttribute","lightNum","_lightNumber","_bias","_normalBias","_precision","_kernelSizePCF","_fakePCF","_jitterOffset","_isAtlasTexture","getLightNumber","getUniformName","getAtlas","setAtlas","setBias","bias","getBias","setNormalBias","getNormalBias","setJitterOffset","jitter","getJitterOffset","getKernelSizePCF","setKernelSizePCF","setPrecision","setLightNumber","normalBias","pcf","ShadowTechnique","_shadowedScene","_continuousUpdate","_needRedraw","getShadowedScene","setContinuousUpdate","isContinuousUpdate","needRedraw","requestRedraw","setShadowedScene","shadowedScene","updateShadowTechnique","cullShadowCasting","cleanSceneGraph","ShadowTexture","_uniforms","_mapSize","_renderSize","hasLightNumber","lun","assert","ViewRight","ViewUp","ViewLook","DepthRange","MapSize","RenderSize","setViewMatrix","viewMatrix","_viewMatrix","setProjection","_projection","setDepthRange","_depthRange","_updateViewMatrixUniforms","viewUp","viewLook","texNumber","CameraCullCallback","shadowTechnique","_shadowTechnique","nodeTraverse","cs","getCurrentCullingSet","getCurrentProjectionMatrix","getComputedNear","getComputedFar","markSceneAsNoShadow","getFrustumPlanes","getCurrentModelViewMatrix","setupMask","setLightFrustum","ShadowMap","shadowTexture","_projectionMatrix","_lightNumberArrayIndex","_lightUp","_cameraShadow","_textureUnitBase","_textureUnit","_textureMagFilter","_textureMinFilter","_textureSize","unifRenderSize","_texelSizeUniform","_receivingStateset","_casterStateSet","_shadowCastShaderGeneratorName","unifRange","_worldLightPos","_worldLightDir","_castsShadowDrawTraversalMask","_castsShadowBoundsTraversalMask","_tmpVec","_tmpVecBis","_tmpVecTercio","_tmpMatrix","setShadowSettings","_infiniteFrustum","shadowStateAttribute","_debug","getDepthRange","lf","nearFarBounding","_debugGeomFrustum","_debugNodeFrustum","getTexture","setTextureUnitBase","unitBase","shadowSettings","getShadowCastShaderGeneratorName","setCastsShadowDrawTraversalMask","castsShadowDrawTraversalMask","setCastsShadowBoundsTraversalMask","castsShadowBoundsTraversalMask","setLight","textureSize","setTexturePrecision","textureType","kernelSizePCF","getCastsShadowDrawTraversalMask","_castsDrawShadowTraversalMask","getCastsShadowBoundsTraversalMask","getReceivingStateSet","checkLightNumber","lightNumber","_rebindFbo","detachAll","atlasTexture","lightIndex","initTexture","fullOverride","_preventTextureBindingDuringShadowCasting","textureNull","shouldGetMaxTextureUnits","viewportDimension","frameBufferObject","setFrameBufferObject","updateShadowTechnic","setTextureFiltering","texType","getTexturePrecision","HALF_FLOAT","textureFormat","CLAMP_TO_EDGE","format","mapSize","getCasterStateSet","getUp","zFar","EPSILON","_emptyCasterScene","makePerspectiveFromBoundingBox","eyeDir","fovRadius","tan","ymax","ymin","xmax","xmin","infiniteFrustum","lookAtDirection","makeOrthoFromBoundingBox","diameter","zNearRatio","aimShadowCastingCamera","worldLightDir","lightMatrix","positionedAttribute","getCurrentRenderBin","getPositionedAttribute","positionedAttributeElements","pa","eyeToWorld","isDirectionLight","worldMatrix","transpose","getDirection","getSpotCutoff","frameShadowCastingFrustum","clampProjectionMatrix","setShadowUniformsReceive","noDepth","_debugNodeSceneCast","setTranslation","getTraversalMask","cleanReceivingStateSet","ignoreTexture","setDebug","Debug","_debugGeomSceneCast","getDebug","ShadowTextureAtlas","_lightNumberArray","_viewMatrices","_depthRanges","_mapSizes","getLightNumberArray","setLightNumberArray","lightNumberArray","createUniforms","renderSizeUniform","lighNumber","setLightShadowMapSize","dimension","texUnit","ShadowMapAtlas","_lights","_shadowMaps","_viewportDimension","_shadowSettings","_shadowMapSize","atlasSize","_numShadowWidth","_numShadowHeight","_cameraClear","ligthtIndex","numShadow","getShadowMap","addLight","lightCount","shadowMap","recomputeViewports","numViews","viewDivideY","viewDivideX","mapSizeX","mapSizeY","numShadowWidth","numShadowHeight","updateCameraClear","fbo","getFrameBufferObject","removeShadowMap","addShadowMap","kernelSizeList","ShadowSettings","shadowProjection","shadowCastShaderGeneratorName","castsDrawShadowTraversalMask","getTextureSize","setTextureType","tt","getTextureType","setTextureFormat","tf","getTextureFormat","setShadowCastShaderGeneratorName","ShadowedScene","_shadowTechniques","_optimizedFrustum","_frustumReceivers","_tmpMat","_computeBoundsVisitor","getShadowTechniques","addShadowTechnique","technique","removeShadowTechnique","lt","_settings","userShadowCasterVisitor","_removeNodesNeverCastingVisitor","_castsShadowTraversalMask","computeShadowedSceneBounds","getVisitorType","CULL_VISITOR","hasCastingScene","getCurrentModelMatrix","registerApplyFunction","nodeTypeID","getApplyFunction","osgShadow","ShadowCastCompiler","ShadowFrustumIntersection","ShadowCastShaderGenerator","maxUnits","PBRMaterial","_enableVertexColor","_hasClearcoat","_hasNormalMap","_hasOpacityMap","_opacityFactor","_normalFactor","_normalFlipY","_depthWrite","_onlyDepthMaskNoShading","_displacementAmount","_cullFace","_unlit","_invertAlpha","_metalnessWorkFlow","_clearcoatParam","_hasAOMap","_hasDisplacementMap","flag","updateOpacity","opacityFactor","normalFactor","normalFlipY","displacementAmount","clearcoatParam","StateAttributeRegister","isPowerOf2","ChangeColorAttribute","_valid","caclLod","_targetColor","_sourceLod","_useMask","_maskRange","_useSourceColor","_sourceColor","log2","targetColor","range","sourceColor","maskRange","sourceLod","DiamondAttribute","_brightness","_scale","brightness","cls","UVTransformAttribute","_transform","offsetx","offsety","ration","GeomNodeVisitor","includeShadow","geoms","getNodeName","nodeState","currMatId","find","item","matId","compGeoms","gitem","_meshIndex","targetName","_nameIndex","GeomNodeVisitorV3","getNodeNameV3","v1Name","getNodeNameV1","UVProjectionAttribute","ProjectionMode","TRIPLANAR","_triplanarBlendWeight","validModes","uTriplanarBlendWeight","POLAR","ORTHOGONAL","ModelLoader","uvproject","version","noForceHttps","httpHeader","model","Visitor","pm","MaterialUtils","resetGeometryStateSet","uvTranform","UVProjection","DefaultUrlResolver","useCdn","imageUrl","textureConfig","uint","urlParams","URLSearchParams","search","limited","urlSearch","isPc","UrlConfig","TextureResolver","_createTextureFeature","channel","hasMap","Parse","texRes","getInstance","getOrCreateTexture","DISPLACEMENT_TEXTURE_UNIT","RGB","REPEAT","setFlipY","OPACITY_TEXTURE_UNIT","createTextureFromColor","ALBEDO_TEXTURE_UNIT","setTexture","setTargetColor","colorTexture","_defaultText","_defaultMat","classType","metalnessWorkFlow","channels","Diamond","scaleX","scaleY","Albedo","Roughness","Emissive","NormalMap","flipY","BumpMap","Opacity","sampleChannel","refractionTint","refractUseDiffuse","refractUseShininessMap","IOR","roughnessFactor","AO","occludeSpecular","MetalnessPBR","SpecularF0","ClearCoat","thickness","reflectivity","roughness","normalmap","Displacement","CavityMap","_silverMat","replaceMat","setCache","capApp","OffscreenCanvas","Error","offscreen","Application","_switchManipulator","setEnvironmentModel","defaultEnv3d","setBackgroundMode","loadModel","attachMaterial","scene","_rootScene","Promise","takeScreenShot","takeScreen","material","createPBRMaterial","configMaterial","uvtransform","isDefaultValue","uvTransform","setTransform","uvProjection","vertexColor","Color","albedoSetter","albedoChannel","metallicSetter","METALLIC_TEXTURE_UNIT","metalChannel","roughnessSetter","ROUGHNESS_TEXTURE_UNIT","roughnessChannel","normalmapSetter","NORMAL_TEXTURE_UNIT","normalChannel","normalMap","aomapSetter","AO_TEXTURE_UNIT","aoChannel","aoMap","opacitySetter","opacityChannel","hasOpacityMap","displacementSetter","diplacementChannel","hasDisplacementMap","displacementFactor","diamondAttribute","setHasNormalMap","setHasOpacityMap","setOpacityFactor","setHasAOMap","setHasDisplacementMap","setDisplacementAmount","setNormalFlipY","setNormalFactor","cullFaceEnum","setMetalnessWorkFlow","getHasOpacityMap","getOpacityFactor","pbrMaterial","setVertexColorEnable","front","both","FRONT_AND_BACK","createShadowSetting","setting","fakePCF","LightModel","matrixPrev","createNode","_mtLight","lightNode","createLight","_shadowMap","_lightSource","lightSource","_mtQuad","_quadGeom","GeometryCreator","light_icon","_dirGeom","_mtEditLight","editLightSS","_updateMatrixOnToggleCamera","_scene","depthTexture","lightEnable","getDiffuse","getSpecular","visiable","toJSON","Model","LightsModel","select","lights","forceShadowRedraw","lightModel","_lightingFeature","initLights","_finishPromise","initDepthTexture","getFeaturesManager","getTextureDepth","setDepthTexture","setScene","dirtyScene","jsonLight","setUpdateMatrixOnToggleCamera","LightingFeature","shadowmapSizeUniform","uShadowMapSize","_isScreenshot","onSelectChanged","onEnableChanged","redraw","_shadowAtlasSetting","_shadowMapAtlas","SHADOW_TEXTURE_UNIT","_nodeFeature","_shadowNode","_lightNode","lightnodeStateSet","initLightNode","_showLighting","_onLightGizmoEditing","shadowmap","getAmbient","setLinearAttenuation","shadowSetting","enableShadow","MaxTextureUnit","gizmo","getGizmo","getLightSource","_updateLightsAndIcons","setLightUnit","getNodeGizmo","gizmoNode","isLightNone","getNodeEditLight","attachnode","tempVec4","tempVec3","getIconScaleFov","editLight","nodeLight","getNodeLight","lightQuad","getNodeQuad","lightScale","getNodeScale","quadMatrix","editMatrix","nodeMatrix","multiply","screenshot","shadowNeedUpdate","showLight","needUpdate","updateNode","curMat","preMat","setIconVisibility","updateLightIcons","updateSelection","updateVisitor","setIsScreenshot","_separateVR","_isEnv","_isRootModel","popModelViewMatrix","popProjectionMatrix","_minNear","_computedNear","_maxFar","_computedFar","projectionStackTop","_projectionMatrixStack","vrConfig","doVR","leftProjection","rightProjection","nearfar","uNearFar","clampedProjectionMatrix","isMainCamera","cameraMain","updateNearFar","_handleMainCamera","nodePostProcessOut","cameraEnvironment","getCullCallback","leafs","_currentStateGraph","_leafs","_currentRenderBin","addStateGraph","isVR","leaf","createOrReuseRenderLeaf","isEnv","modelViewMat","viewMat","getCurrentViewMatrix","leftModelView","rightModelView","leftOffsetView","rightOffsetView","leftView","rightView","drawable","updateCalculatedNearFar","framebufferWidth","framebufferHeight","leftRenderWidth","rightRenderWidth","leftRenderHeight","rightRenderHeight","RenderPassEnum","DEFAULT","EARLYZ_OPAQUE","EARLYZ_TRANSPARENT","OPAQUE_SHADING","TRANSPARENT_SHADING","SHADOWMAP","ANY_OPAQUE","ANY_TRANSPARENT","renderLeafDrawGeometry","drawGeometry","PBRMaterialAttributeIndex","getOrCreateStateAttributeTypeMemberIndexFromName","drawGeometryImp","isTriangles","applyAttribute","doubleDraw","RenderInfo","getUserData","lastApplied","getCullFace","drawImplementation","needDraw","curPass","getDepthWrite","getOnlyDepthMaskNoShading","modifyDrawOpaqueUniform","uniformCache","opaqueUniform","uDrawOpaque","stateUserData","uniformCacheByInstanceId","drawOpaque","valuesArray","instanceid","isPrimitiveTriangles","primitivelist","ForceAttribute","graphicContext","getLastProgramApplied","getUniformsCache","sortBin","_binNum","getInsertPosition","previous","sg","_parent","_stateset","getStateSetStackSize","StateAttributeOverrideOn","EarlyZStateSet","ss","ClearDepthRGBA","clearTranpanrentRGBA","RenderStageSplitter","_binArraySorted","_renderBufferDepthAttachment","startsWith","binsArray","_bins","bin","fboDepth","fboTransparent","fboRefraction","fboOpaque","fboExtra","renderbufferDepthAttachment","setAttachment","colorAttachment","textureTarget","createFBO","_textureOpaque","_textureTransparent","frameBufferObjectTransparent","clearOpaqueRGBA","_clearDepth","renderLeaf","binArraySorted","sortedLength","drawExtraBin","previousLeaf","binsorted","isEarlyzTransparent","preDepth","doearlyz","getDoEarlyZ","drawLeafs","isOpaqueRenderPass","binNumber","oldDepth","drawOpaqueBin","isWritingDepth","drawTransparentBin","hasCameraDepth","bindDepthRTT","bindOpaqueRTT","stateInsertPosition","insertStateSet","drawEarlyOpaque","doEarlyTransparent","drawEarlyAlpha","removeStateSet","drawOpaqueShading","bindTransparencyRTT","drawTransparentShading","_textureExtra","bindExtraRTT","drawExtra","preLeaf","LAST_LEAF","passTypes","forceAttribute","setUserData","isShadowCasterCamera","_scissor","_positionedAttribute","applyPositionedAttribute","sortBinArray","drawImplementationEditor","_LINEAR_TO_SRGB","linear","_SRGB_TO_LINEAR","linearToSrgb1","srgbToLinear1","linearToSrgb","srgbToLinear","encodeRGBM","decodeRGBM","rgbToHex","rgb","AddGaussianBlurPass","passArray","inputName","outputName","steps","needAdjustBlurDir","blurX","blurY","shaders","stepidx","step","shaderFile","hasShader","Generate","PostProcessNode","postProcessFeature","_view3d","_effectiveConfig","_model","getEventEmitter","onPingPongTexture0","getBackgroundModel","onBackgroundUpdated","onBackgroundColor","_composer","getBackground","background","toggle","from","to","statesetPass","textureunit","bgType","_replaceTexture","getBackgroundType","uOutputLinear","ColorHelper","rgbmRange","uRGBMRange","caps","useTransparency","useExtra","useDepth","_needDepthTexture","hasBG","useFxaa","useToneMapping","useSsao","effectiveconfig","useRefraction","useSsr","useDof","useBloom","useSharpen","useSss","useTaa","composer","effectiveConfig","_getSupportedFloatTexture","supportLinearFloat","_getSupportedLinearFloatTexture","_sssTexKernel","sssByteRange","useSSSLookupFloat","getSSSWeightRange","blurdirUniform","blurDir","firstDepthUniform0","firstDepthUniform1","mipIdx","curMipIdx","inputTextureDepth","outputTextureDepth","glslExtension","_addFixedBackgroundRefraction","supportFloatTexture","define","useChromaticAberration","useColorBalance","effects","useTaaTransparent","effect","useDistortionVR","useVignette","useGrain","backgroundTexture","getNodeBackground","backgroundUniform","_updateEffectiveConfig","_initComposer","needsPackDepthMipmap","needsPackColorMipmap","mipmapPassCount","_packMipmapDepth","_addSsao","_addSss","_addCombineOpacity","_packMipmapColor","_addRefraction","_addDof","_addBloom","_addMergeable","_addFixedBackground","_addPassThrough","hasNoPass","_addSuperSample","_addFinalPass","_addInternalTextures","_assignInternalTextureToCamera","refractedTex","_textureRefraction","texWidth","texHeight","composerPrototype","_resizeMipmapHeight","getCanvasWidth","getCanvasHeight","_hookComposerResize","statset","postProcessUniform","resetAttachments","_createComposer","resetCameraAttachments","PostProcessCallback","RESIZE_OBSERVABLE","CLIENT_WIDTH","CLIENT_HEIGHT","_postProcessFeature","_interpolatorDofFocusPoint","_interpolatorDofBlurNear","_interpolatorDofBlurFar","_interpolatorDofCross","_epsilon","_dofInitialized","_dofAutoFocus","_currentEye","_lastEye","_currentRot","_lastRot","_dofLastPos","_dofLastFocal","_firstFrame","_cullConfig","_skipTaaFrames","_lastUpdateTime","canvasRatioModel","viewerToCanvasRatio","_hookViewerCheckNeedToDoFrame","_hookViewerFrame","_hookViewerComputeCanvasSize","onResetTaa","showDofCross","_nodeIn","getMainCamera","createPathStandard","setSwitch","getCurrentComposer","viewerOSG","viewerOSGCheckNeedToDoFrameBound","viewerNeedDoFrame","_toggleComposerCameras","mainCamera","frameBound","setShadowForcedUpdate","_resizeCanvasTimeout","_doResizeCanvas","_overrideCanvasWidth","_overrideCanvasHeight","_onResizeCanvas","_onForceResizeCanvas","_cbEnableResizeCanvas","_enableResizeCanvas","viewerOSGJS","_originalCanvasResize","_computeCanvasSize","postProcessFeatureCallback","overrideW","overrideH","_resetResizeCanvas","supportOffscreen","ResizeObserver","observe","canvasRatio","onEffectChanged","trigger","uGlobalTexSize","textureRatio","uGlobalTexRatio","halton","uHalton","uPreviousGlobalTexSize","uPreviousGlobalTexRatio","uPreviousHalton","frameMod","uStaticFrameNumShadow0","uStaticFrameNumShadow1","uStaticFrameNumShadow2","uStaticFrameNumShadow3","projMat","getClampedProjectionMatrix","uSsaoProjectionScale","projInfo","uSsaoProjectionInfo","framestamp","updateNearFarRatio","updateGlobalTexUniforms","uTimeViewer","uPixelRatio","framemod","_shadowJitterUpdate","uFrameMod","needsSetFramemod","uTaaEnabled","uFrameModTaaSS","reprojectMatrix","uReprojectViewProj","prevProjection","uPreviousProjection","invViewMatrix","uPreviousViewInvView","projectionMatrix","_tmpView","_tmpProjection","updateSsao","updateDirtyEffect","updateGlobalUniforms","PostProcessFeature","_onViewerToCanvasRatio","encodeURIComponent","ua","onToneMappingExposureChanged","onToneMappingBrightnessChanged","onToneMappingContrastChanged","onToneMappingSaturationChanged","onToneMappingMethodChanged","checkSsaoEnable","onSsaoIntensity","onSsaoRadius","onSsaoBias","_createMainCamera","_nodeOut","_createNodeOut","_callbackPostProcess","_initUniforms","_updateViewports","ppvp","camvp","camW","camH","attrs","toneMapMode","isEffectiveGrain","isEffectiveSharpen","isEffectiveChromaticAberration","isEffectiveVignette","isEffectiveBloom","isEffectiveDof","isEffectiveSsr","uDistortion","uProjectionLeft","uUnprojectionLeft","uGrainFactor","checkGrainEnable","uSharpFactor","checkSharpenEnable","uChromaFactor","checkChromaticAberrationEnable","lensRadius","uLensRadius","amount","hardness","checkVignetteEnable","uBloomFactor","checkBloomEnable","uBloomThreshold","uBloomRadius","uColorBalanceLow","uColorBalanceMid","uColorBalanceHigh","uToneExposure","uToneBrightness","uToneContrast","uToneSaturation","uToneMethod","updateDofFocusPoint","updateTargetDofBlurNear","checkDofEnable","updateTargetDofBlurFar","uSsaoRadius","uSsaoIntensity","uSsaoBias","uSsrFactor","checkSsrEnable","uSSAARestart","hideDofCross","backgroundEnv_vert","backgroundEnv_frag","BackgroundNode","createTexturedBoxGeometry","_show","_bgEnv","_bgFixed","_texRatio","_canvasHidth","hide","scaleArray","bgEnv","exposure","backgroundExposure","bgFixed","ambient","TextureEnvironment","_channel","_isCubemap","getChannel","isCubemap","lodRange","uniformLodRange","uniformSize","channelType","EnvironmentNode","_isPBR","_textureSpecular","_textureSpecularUnit","ENV_SPECUAR_TEXTURE_UNIT","_textureSpecularPBR","_textureIntegrateBRDF","_textureSpecularPBRUnit","_textureIntegrateBRDFUnit","ENV_BRDF_TEXTURE_UNIT","_nodeBackground","_adjustRotation","fromXRotation","_defaultExposure","_lightProbes","envLight","_shadow","_lightIntensity","_lightShadowEnabled","_shadowBias","_lightNodeRoot","setTexturesStateSet","removeTexturesStateSet","setExposure","setEnvironment","perspectResult","tempMat","envTransformUniform","envUniform","environmentTransform","cullvisitor","getPerspective","_mainCamera","fovy","aspectRatio","curModelView","fromMat4","mainCam","camNode","createCameraNode","updateTextureUnits","updateLightShadow","updateLightColorAndIntensity","probe","exposureRate","lightProbeColor","defaultExposure","eyeup","debugEnvShadow","_debugShadow","_debugDone","dirGeom","useShadow","isUsingLightShadow","maxTextureUnit","updateLightFromProbes","fromZRotation","sph","sphValues","diffuseSPH","setIsCubemap","textureSpecular","logrange","updateLodRange","textureSpecularPBR","textureIntegrateBRDF","ispbr","tempMat1","tempMat2","Environment","_nodeEnvironment","_backgroundLoaded","onExposureChanged","onRotationChanged","onBackgroundEnableChanged","onBlurChanged","onEnvironmentChanged","_resourceDefer","onShadowEnable","onShadowBiasChanged","onLightIntensityChanged","initEnvironment","initRotateEnvironment","backgroundFeature","getBackgroundEnableType","_rotEnv","lastCanvasX","_computeDelta","getWorldNode","getMinimumBound","rotateEnv","rotateLight","setLightShadowEnabled","setLightIntensity","setShadowBias","getEnvironment","setBackgroundExposure","updateRotation","isBackgroundEnvironment","setBackgroundTexture","backgroundType","setBackgroundAmbient","envModel","texturePromises","texturesPromises","isPBR","setIsPBR","setDiffuseSPH","probes","setLightProbes","setDefaultExposure","setEnvironmentPBR","setEnvironmentOld","encoding","envNode","envModelTextures","textureLodSupported","textureModel","findTexture","imageModel","getImageRes","transferToGPU","textureRes","setSpecularPBRTexture","limitSize","texturePromise","getPromiseTexture","maxUnit","setIntegrateBRDFTexture","blur","getClosestBlur","getBackgroundResource","loadedBackground","nodeEnv","Resolution","maxSetp","Background","onBackgroundChanged","_modelEnvironment","getNodeEnvironment","getResources","convertNPOT","setBackground","rescale","_viewWidth","_viewHeight","showBackground","showColor","showEnvironment","showAmbient","requireBiggerTexture","pixels","canvasSrc","canvasDSt","drawCallBack","flush","finish","contextSrc","imageDataSrc","getImageData","putImageData","contextDst","clearRect","fillRect","save","globalCompositeOperation","drawImage","drawFunc","ScreenShot","superSample","oldMask","prepareForScreenShot","setPoseForScreenshot","setFinalDrawCallback","canBeEnabled","forceEnable","updateFrame","resetAfterScreenShot","StickerAttribute","_hitPoint","_hitNormal","_feature","_stickers","stNum","highlight","getHighlight","_anchors","flat","getInvTransform","getInvQuatMat","getWorldPos","getWorldNormal","getVisible","tempWorldPosition","tempWorldNormal","tempN","tempMat3","Sticker","gbp","ref0","ref1","tmpvec3","xUnitVec3","yUnitVec3","_visible","_highlight","_invTransform","_invQuatMat","_originalImage","_globalBoundingSphere","_mirror","_worldPos","_worldNormal","_ref0","_ref1","_useGBP","invTransform","invQuatMat","worldPos","worldNormal","anchors","visible","mirror","getMirror","renderData","lodash","cloneDeep","_renderWithAnchor","pt","subtract","updateInvTransform","sx","sy","mapAspectX","mapAspectY","mapWidth","mapHeight","dynamicScale","_getDynamicScale","quatFromXtoTarget","zaxis","cross1","cross2","projectXY","rotationTo","turnup","acos","uv","getUV","transformMat3","transferToUVSpace","temp","findIndex","_activeAnchor","p3","p4","y1c","y2c","y1n","y2n","corners","_corners","lerp","anchor","MAX_STICKERS_NUM","StickerFeature","initSticker","_previousDraggingPoint","_stickerTextures","_stickerAttribute","_uHighlight","_uMat","_uT","_selected","_activeSticker","_maximumSelectedNum","_setupStickersByModelsBound","setup","yw","zMax","zMin","startPt","endPt","imagesP","sticker","fromJson","_updateStickerSlot","worldPosition","pick","worldT","computeLocalToWorld","normalFromMat4","STICKER_TEXTURE_UNIT","updatePosition","check","getStickerById","calculateReferPoints","stickers","isInUnitSquare","setHighlight","emit","hitStickersByPos","setActiveSticker","archerIndex","selectAndActiveAnchor","enableManipulator","updateAnchor","Channel","initChannel","times","channelName","createVec3Channel","chan","Vec3","createFloatChannel","Float","createQuatChannel","Quat","createQuatSlerpChannel","QuatSlerp","createFloatCubicBezierChannel","FloatCubicBezier","createVec3CubicBezierChannel","Vec3CubicBezier","create32","createInstanceChannelType","operator","targetID","Target","InvalidTargetID","createInstanceVec3Channel","createInstanceQuatChannel","createInstanceFloatChannel","createInstanceFloatCubicBezierChannel","createInstanceVec3CubicBezierChannel","createInstanceChannel","createInstanceQuatSlerpChannel","ChannelType","animationCount","createAnimation","animationName","createInstanceAnimation","animation","firstKeyTime","Animation","vec3CopyKeyFrame","Vec4CopyKeyFrame","Vec3LerpInterpolator","channelInstance","t2","z1","z2","QuatLerpInterpolator","q0","q1","nlerp","QuatSlerpInterpolator","slerp","FloatLerpInterpolator","FloatCubicBezierInterpolator","oneMinusT","oneMinusT2","oneMinusT3","Vec3CubicBezierInterpolator","moduleInterpolator","CollectAnimationUpdateCallbackVisitor","_animationUpdateCallback","getAnimationUpdateCallbackMap","cbs","cbsLength","TypeToSize","Matrix","ResultType","BasicAnimationManager","BaseObject","_simulationTime","_pauseTime","_timeFactor","_startTime","_instanceAnimations","_startAnimations","_targets","_targetsMap","_targetsByTypes","ni","_activeAnimations","_activeAnimationList","_activeChannelsByTypes","nj","_animationsUpdateCallback","_animationsUpdateCallbackArray","_animationsToRegister","_pause","_seekTime","animations","_resetTargets","addAnimations","instanceAnimationList","_addAnimation","_registerAnimations","_findAnimationUpdateCallback","_registerTargetFoundInAnimationCallback","updateManager","_processStartAnimation","activeChannelType","_updateChannelsType","Interpolator","targetType","_updateTargetType","nk","animCallback","_removeFinishedAnimation","togglePause","setSeekTime","stopAnimation","activeAnimationList","nbAnim","_removeActiveChannels","stopAllAnimation","setTimeFactor","timeFactor","getTimeFactor","isPlaying","playAnimationObject","anim","playAnimation","animationObject","getAnimations","instanceAnimation","_registerInstanceAnimation","instanceChannels","instanceChannel","uniqueTargetName","_targetMap","collector","targetMap","targets","registerTarget","keyAnimation","animCb","UpdateMatrixTransform","stackedTransforms","getStackedTransforms","numStacked","stackedTransform","UpdateMorph","numTarget","getNumTarget","getTargetName","_addActiveChannels","targetChannelsList","channelTypeList","channelIndex","targetList","operatorType","affectedChannels","nbChannels","defaultValue","accumulatedWeight","achannel","tLocal","_addActiveAnimation","cmd","resetUpdateCallbacks","anims","nbAnims","resetAllStackedTransforms","setAnimationLerpEndStart","lerpDuration","originalDuration","firstKey","animDuration","originalEnd","sizeElt","idLast","easeLinear","easeInQuadratic","easeInCubic","easeInQuartic","easeInQuintic","easeInSextic","easeInSeptic","easeInOctic","easeOutQuadratic","easeOutCubic","easeOutQuartic","easeOutQuintic","easeOutSextic","easeOutSeptic","easeOutOctic","easeInOutQuadratic","easeInOutCubic","easeInOutQuartic","easeInOutQuintic","easeInOutSextic","easeInOutSeptic","easeInOutOctic","easeInBack","easeInOutBack","easeOutBack","easeInCircle","easeInOutCircle","easeOutCircle","easeInElastic","easeOutElastic","easeInOutElastic","easeOutBounce","easeInBounce","easeInOutBounce","easeOutQuad","easeInQuad","easeInOutQuad","easeOutQuart","easeInQuart","easeInOutQuart","StackedMatrix","createMatrixTarget","resetToDefaultValue","applyToMatrix","qIdentity","StackedQuaternion","createQuatTarget","setQuaternion","matrixTmp","mtmp","StackedRotateAxis","createFloatTarget","setAxis","setAngle","quatTmp","qtmp","StackedScale","createVec3Target","setScale","StackedTranslate","setTranslate","osgAnimation","Easing","MorphGeometry","RigGeometry","Skeleton","UpdateSkeleton","updator","callbackIdx","PathCallback","_path","STATE_ATTRIBUTE_OVERRIDE_ON","OutlineNode","_durationOutline","_timerOutline","_durationHighlight","_timerHighlight","_nodeProxy","_outlineScene","_paths","_cbHideHighlight","hideHighlight","_cbHideOutline","hideOutline","GL_DEPTH_DISABLE","_stateSetSelection","_uColorSelection","_stateSetHover","_uColorHover","_uOutlineFactor","_uHighlightFactor","_uLineWidth","_clearTimeoutOutline","_clearTimeoutHighlight","children","_getMaterialNode","pathnodesArray","isHover","pathnodes","matrixtransform","logicnode","_getLastMaterialPath","UpdateCallbackChecker","addPaths","camerastateset","glCullDisable","outlineComposer","outlineTexture","cameraRTT","createSubSceneRtt","_cameraRtt","viewerosg","composerPassOutlineStateset","blendSub","tempBoundingbox","EditorComputeBoundsVisitor","_pushIfGeo","_bonesBoxMatrix","_usedBones","_stateSet","bone","bonematrix","statsset","pushIfGeo","nodePath","nameids","getBoneNameID","lastnode","editorBoundsVisitor","OutLine","colorHover","outlineWidth","colorSelection","durationOutline","durationHighlight","onColorSelectionChanged","onColorHoverChanged","onOutlineWiddthChanged","onHideOutline","onHideHighlight","onClearFocusTimeout","_nodeOutline","_onMaterialChange","setColorSelection","setColorHover","setOutlineWidth","_timer","nodeoutline","focusOnBound","focusOnHomePosition","showOutline","outlineStateset","hoverStateset","pathNodes","_focusOnBound","clearOutlineScene","addPathsHover","setDurationOutline","setDurationHighlight","FrameManager","mFrame","poseForScreenShot","preTick","frameTimeAverage","shadowForcedUpdate","SuperSampleTrigger","isSameFrame","isDrawAlreadyQueued","currentTick","_drawImpl","_doJitter","JITTER_ARRAY","SuperSample","_canBeEnabled","_sampleCount","_isFakeSupersampling","_isSupersampling","_frameNum","_frameNumTaa","_switch","_jitter","wireframeNode","getOrCreateScene","getWireframeNodes","framenum","istaa","getSortedJitterTable","taascale","switchenable","isTaaJitter","updateUniforms","isSupersampled","curFrame","_lastUpdateFrame","_postProcess","drawSameFrame","CADManipulatorStandardMouseKeyboardController","ZOOM_OFFSET","PICK_INTERVAL","CAD_MANIPULATOR_MOUSEKEYBOARD","CAD_MANIPULATOR_RESETTOHOME","savePosition","_timerRef","_lastX","_lastY","CADManipulatorHammerController","CAD_MANIPULATOR_TOUCH","CADManipulator","_tmpHomePosition","_intersectionVisitor","_lineSegmentIntersector","_polytopeIntersector","_usePolytopeIntersector","_primitiveMask","d0","d1","_right","_homeEye","_homeCenter","_homeUp","_orientation","_pivotPoint","_eye","_zoomDir","setViewer","CAD_MANIPULATOR","setPivotPoint","pivotPoint","setHomePosition","setRotateFactor","setUsePolytopeIntersector","upi","getUsePolytopeIntersector","getIntersectionVisitor","getLineSegmentIntersector","getOrCreatePolytopeIntersector","setIntersectionLimit","setPrimitiveMask","trans","rotPos","speedTmp","rotMat","vectorDistance","speedDist","zoomSpeed","rightNormalized","pitchQuat","yawQuat","pitchyawQuat","rightScalar","yawDelta","pitchDelta","transformQuat","scalar","xy","positionPitch","transMat","mouseFactor","deltapan","pTrans","pi","getPositionRelativeToCanvas","_graphicContext","getOffsetRect","getCanvasCenter","docElem","documentElement","scrollTop","pageYOffset","scrollLeft","pageXOffset","clientTop","clientLeft","FirstPersonManipulatorHammerController","FPS_MANIPULATOR_TOUCH","FirstPersonManipulatorWebVRController","FPS_MANIPULATOR_WEBVR","FirstPersonManipulatorStandardMouseKeyboardController","_stepFactor","_looking","FPS_MANIPULATOR_MOUSEKEYBOARD","startLookAt","stopLookAt","goForward","goBackward","goLeft","goRight","stopMoving","stopStrafing","changeStepFactor","FPS_MANIPULATOR_RESETTOHOME","_buttonup","setStepFactor","getLookPositionInterpolator","getForwardInterpolator","getSideInterpolator","FirstPersonManipulator","cen","_direction","_up","_forward","_side","_lookPosition","_angleVertical","_angleHorizontal","_tmpGetTargetDir","_vrEnable","_vrRot","_vrPos","_vrTrans","FPS_MANIPULATOR","asin","upy","upz","LIMIT","computePosition","len2","directFactor","moveForward","strafe","strafeVertical","tmpTarget","SwitchManipulator","_manipulatorList","_currentManipulator","cbList","getManipulatorList","getNumManipulator","addManipulator","setManipulatorIndex","getCurrentManipulatorIndex","useBoundingBox","osgGA","NO_MOUSEEVENTS","getCADManipulatorStandardMouseKeyboardController","getCADManipulatorHammerController","getFirstPersonDeviceOrientationController","getFirstPersonManipulatorHammerController","getFirstPersonStandardMouseKeyboardControllerClass","getFirstPersonWebVRControllerClass","getOrbitManipulatorDeviceOrientationController","getOrbitManipulatorGamePadController","getOrbitManipulatorHammerController","getOrbitManipulatorStandardMouseKeyboardController","getOrbitManipulatorWebVRController","Rotate","Zoom","eps","_enableRecenter","_zoomEMA","_pitchEMA","_yawEMA","_panVEMA","_panHEMA","_constrainPan","_constrainedTarget","_noPan","_noZoom","_noRotation","preventFlip","upDir","rotationMatrix","dotvalue","zoomEma","limitIn","limitOut","zoomValue","_getLimitReached","_prevDistance","limitReachy","_computeEMA","prevYaw","limitReach","_postMultRotate","_resetInitialVR","DelayInterpolatorProtoType","setter","isDone","threhold","updater","hookIsDone","_autoRotating","_autoRotateMode","_startAutoRotate","_","debounce","trailing","_stopAutoRotate","leading","orbiter","_isOrbitPan","cameraEasing","ORBIT","FPS","controlist","controller","_setManipulatorDelay","curManipulator","setTargetAndEye","currentManipulator","newHome","tempEye","tempTarget","rotateZ","SHADINGKEYS","getComponentEnums","LUMINANCE","ALPHA","getComponents","Remapping","mapper","mapping","MaskMapping","CLASSIC","CLASSIC_LIT","CLASSIC_SHADELESS","INSPECTOR","LIT","MATCAP","PBR","PBR_LIT","PBR_SHADELESS","SHADELESS","getShadingMask","isSRGB","getDefaultFormatEnum","getDefaultFormatComponent","getDefaultFormatString","getDefaultComponentCount","getPossibleFormat","getPossibleFiltering","textureParam","NEAREST_MIPMAP_LINEAR","getColorPacking","getBoxFactor","_channelMapping","_materialModel","_stateSetContext","_additive","_castShadows","_hashes","_dirtyUniforms","_activeChannels","CURRENT_COMPILER","WIREFRAME_COMPILER","getVertexAlphaEnable","SHADING_COMPILER","getShadeless","getVertexColorEnable","getHasOnlyPoints","getVertexColorColorSpace","isShadowCompiler","SHADOWCAST_COMPILER","getChannels","compilerChannel","compilerChannels","cc","isEnableEffective","getShaderHash","getChannelPacking","stateSetContext","opacity","isEffective","getTransparency","getFactor","getTextureModel","hasOnlyPoints","uReflection","addUniforms","activeChannels","cacheUniforms","_cacheChannelUniforms","getReflection","EARLYZ_COMPILER","hasVertexColor","hasVertexAlpha","EditorCompiler","textureAttrs","_vertDefines","_fragDefines","_vertAssignUV","_envBrdf","_envSpecular","_compression","_material","_skinning","_morphing","_shadows","_shadowsTextures","_targetByUnit","initAttributes","initTextureAttributes","defineShaderName","initDefines","shadows","typeName","getVertexShaderName","eps_alpha","compilerName","getCompilerName","renderMode","_channels","AlphaMask","isFrag","mainSource","getFragmentMain","getVertexMain","getSortedUnique","defineStr","processShader","E","declareAndAssignTexCoord","getTexCoordUnit","getNonIdentityUvTransform","_getTexCoordTransforms","isEnableEffectiveHardware","defineOpacity","getChannelMapping","getSRGB","getChannelUV","getLightType","getIsCubemap","defineChannel","randa","Ye","_randHardcodedScale","defineChannels","defineVertexColorAndAlpha","defineLights","defineShadows","defineEnvironment","defineSsr","defineMorphing","defineSkinning","defineCompression","definePointSize","setStateAttributeConfig","PBRCompiler","textureAttr","_changeColorAttribute","_originMaterial","_uvTransform","_uvProjection","_sticker","_diamondAttribute","materialName","diamondShader","isUseSourceColor","getHasNormalMap","getHasClearcoat","getHasAOMap","getHasDisplacementMap","getMetalnessWorkFlow","getUnLit","isMobile","defineUV","defineSticker","defineUnLit","OutlineCompiler","EarlyZCompiler","EditorShaderGenerator","shaderCompiler","compilerType","compilingProgramNum","_materialHashCompiler","textureattributes","getAsyncCompiling","getAsyncLinkingStatus","getLinkResult","_placeHolder","_waitingProgram","enableAsyncCompilation","addShaderGenerator","shaderGeneratorProxy","registerShaderGenerator","HAS_REGISTED","tempXY","CanvasPixelRatio","pixelRatio","_dynamicResolutionScaling","_pixelRatio","scaling","pixelratio","pixelratoi","nodeGrid","nodeRuler","shoes","mainShoe","initRoot","_uInverseMat","stickerUnit","show","shoe","isLeft","nodeLeft","nodeRight","udata","goemNode","_rootModel","treeBuilder","ExplodeSetupVisitor","explodeCenter","_explodeCenter","explodeNode","explode","assign","worldTraslation","sphere","worldCenter","ExplodeVisitor","newCenter","newDir","newPos","parentWorldMat","targetWorldMat","newLocalMat","shaderChunks","earlyZFrag","cubemapFragment","cubemapSampler","cubemapVertex","math","changeColor","panoramaSampler","pbr_ue4","pbrFrag","baseVert","sphericalHarmonics","sphericalHarmonicsFragment","sphericalHarmonicsVertex","triplanar_projection","shadowCastFrag","stickerglsl","baseShaderChunks","postProcessShaderChunks","ReleaseVisitor","traversalMode","_releaseVisitor","_explodeSetup","_explode","_explodeRoot","texture0","factorShadowEnv0","uProjFactor","uDofBlurNearFarFocal","uDofCross","uDofScale","uTimeGrain","uTaaInvViewMatrixLeft","uTaaCurrentFramePVLeft","uTaaLastFramePVLeft","uTaaCornersCSLeft","uTaaInvViewMatrixRight","uTaaCurrentFramePVRight","uTaaLastFramePVRight","uTaaCornersCSRight","uVrFadeFactor","uVrVeilFactor","uInverseScopeModelMatrix","uEarlyZ","uQVT","uQVS","uQW","uQUV0","uBoxRadius","uTextureToBeRefractedSize","uHoverUV","uDisplay2D","uSplitView","uInspectorView","uScatteringFactorPacker","uNormalizeFactorThickness","uIsVr","uQuality","readShaders","stencil","premultipliedAlpha","fullscreen","enableFrustumCulling","Mouse","_featuresManager","_eventEmiiter","requestContinuousUpdate","getShaderGeneratorProxy","drawNoJitter","_superSample","setSuperSample","setRoot","setSceneData","EnvironmentFeature","BackgroundFeature","OutlineFeature","screenShot","ScreenShotFeature","rootscene","displayGraph","setDisplayGraphRenderer","createGraph","finished","featureFinished","detail","ret","_drawable","rot","fixed","exp","bright","contrast","sat","setViewMode","setNoPan","setNoZoom","getScreenShot","_launchViewer","captureMaterial","forceClean","clearCache","flushAllDeletedGLObjects","PresetLights","isPreset","lightsModel","showLighting","setSelect","phi","ymatrix","fromYRotation","zmatrix","setAutoRotateMode","Bus","_hooks","osgWrapper","Name","UserDataContainer","userdata","UpdateCallbacks","cbAddCallback","pp","Children","queueNodes","RenderingHint","createAttribute","jsonAttribute","isRejected","AttributeList","createTextureAttribute","TextureAttributeList","al","Diffuse","Emission","Specular","Shininess","setAmbient","Ambient","setDiffuse","setEmission","setSpecular","setShininess","SourceRGB","SourceAlpha","DestinationRGB","DestinationAlpha","setSourceRGB","setSourceAlpha","setDestinationRGB","setDestinationAlpha","ConstantColor","setConstantColor","Direction","Position","LightNum","SpotCutoff","LinearAttenuation","ConstantAttenuation","QuadraticAttenuation","setConstantAttenuation","setDirection","setPosition","setQuadraticAttenuation","setSpotCutoff","setSpotBlend","SpotExponent","MinFilter","MagFilter","WrapT","WrapS","ReferenceFrame","VertexAttributeList","PrimitiveSetList","arraysPromise","prims","cbAddPrimitives","promisePrimitive","cbSetBuffer","vList","functionSortAttributes","promiseBuffer","plod","CenterMode","setCenterMode","UserCenter","RangeMode","setRangeMode","RangeList","setRange","RangeDataList","setFileName","addChildNode","osgAnimationWrapper","channelCtor","registry","Channels","arrayChannelsPromise","StandardVec3Channel","creator","TargetName","KeyFrames","Time","Key","jsTime","jsKeyX","jsKeyY","jsKeyZ","pArray","eTime","eKeyX","eKeyY","eKeyZ","StandardQuatChannel","jsKeyW","eKeyW","StandardFloatChannel","jsKey","eKey","Vec3LerpChannel","QuatLerpChannel","QuatSlerpChannel","FloatLerpChannel","FloatCubicBezierChannel","ControlPointOut","ControlPointIn","arrayPromise","keyFrames","controlPointIn","controlPointOut","Vec3CubicBezierChannel","cpi0","cpi1","cpi2","cpo0","cpo1","cpo2","Animations","animPromises","promiseAnimation","umt","StackedTransforms","promiseStacked","stack","Translate","Quaternion","Axis","Angle","sme","stc","Scale","InvBindMatrixInSkeletonSpace","setMax","setMin","upSkl","rigGeom","SourceGeometry","BoneMap","rigPromise","_boneNameID","geomPromise","sourceGeometry","setSourceGeometry","getSourceGeometry","mergeChildrenData","morphGeometry","MorphTargets","morphTargets","promiseResultArray","morphGeometryResolved","getMorphTargets","jn","mergeChildrenVertexAttributeList","updateMorph","TargetMap","StackedMatrixElement","StackedScaleElement","Text","_context","_matrixTransform","_font","_color","_fillStyle","textAlign","_textX","baseLine","_textY","_characterSize","_characterSizeMode","OBJECT_COORDS","_autoRotateToScreen","_layout","LEFT_TO_RIGHT","_alignment","CENTER_CENTER","_forcePowerOfTwo","drawText","_previousModelView","SCREEN_COORDS","OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT","RIGHT_TO_LEFT","LEFT_TOP","LEFT_CENTER","LEFT_BOTTOM","CENTER_TOP","CENTER_BOTTOM","RIGHT_TOP","RIGHT_CENTER","RIGHT_BOTTOM","setTextProperties","_nextPowerOfTwo","quadWidth","setFont","setColor","getColor","setCharacterSize","setMaximumScale","getCharacterSize","setCharacterSizeMode","setAutoScaleToScreen","getCharacterSizeMode","setFontResolution","resolution","getFontResolution","_setAlignmentValues","setAutoRotateToScreen","getAutoRotateToScreen","setLayout","layout","getLayout","setAlignment","alignment","getAlignment","doUpdate","_firstTimeToInitEyePoint","_previousWidth","_previousHeight","_previousProjection","_previousPosition","_autoScaleToScreen","psvector","computePixelSizeVector","pixelSize","_autoScaleTransitionWidthRatio","_minimumScale","_maximumScale","modelView","setRotation","setForcePowerOfTwo","getForcePowerOfTwo","osgTextWrapper","AutoRotateToScreen","CharacterSize","Layout","Alignment","osgDB","DatabasePager","osgWrappers","osgAnimationWrappers","osgText","osgTextWrappers","defaultColor","_defaultTexture","maps","SpecularMap","defaultConfig","diffuse","useTexture","specular","gloss","metalness","displace","uvMap","createMaterial","defaultConf","attrGroup","attrDefault","createRenderMaterial","MetalnessWorkFlow","rk","restAttr","createNativeMat2","colorCardConf","createTextureMat","mat3d","cusUv","orginScale","baseMap","baseColor","roughMap","roughFactor","metalMap","metalFactor","displaceMap","displaceFactor","diffuseColor","diffuseMap","glossFactor","glossMap","specColor","specMap","opacFactor","opacMap","createDefaultEvn3d","cusNum","thumbnail","createTime","hdr","toneMap","saturation","createDefaultScenePackage","mats","techMaterial","osgjs","glb","boundingBox","env3ds","products","geomId","components","scenes","envId","prodId","getAppInstance","setEnv3d","setEnvironmentRotation","setEnvironmentExposure","setToneMappingExposure","setToneMappingBrightness","setToneMappingContrast","setToneMappingSaturation","setToneMappingMethod","_touchTime","_touchPos","_rect","_picking","initEvent","touchEvent","setOutLine","evtTouchClick","getPos","setCanvasRect","activeElement","tagName","endPos","clicked","clickedOutline","getCanvsPos","env3d","dom","pickOption","enablePicker","destory","picker","getDefaultEnvHandle","env","setDefaultEnv3d","once","enableGrid","enableGizmo","inRadiuScale","outRadiuScale","inScale","outScale","mesh","_InverseModelMatrix","_tempMatrix","_version","geomVisitor","geomName","getGeomByName","updateGeomMaterial","CompName","loader","resMap","load","delete","GroundShadow","onLoad","setUnLit","enableInvertAlpha","orgMaterial","_visiable","setVisiable","Utils","Util","meshObj","sceneProdId","clearMeshParent","removeParents","frags","parseFloat","xw","maxX","objShadow","nodeShadow","quatR","trsMat","fromRotationTranslationScale","env3dConf","area","lum_ratio","luminosity","variance","samples","sizeCompressed","sizeUncompressed","writeByChannel","initSceneEnv","queen3d","backgroundTransparent","setSceneEnv","setSceneBg","setSceneLight","setEnv3dOption","setEnvToneMap","setBackgroundColor","setBackgroundFixed","setLightingEnable","setThreeLightsJson","initSceneGeoms","geomsCacher","pack","downloading","prod","finded","initMatGeom","_inputFilter","_inputWrap","_outputSize","_downSampler","_mipmapSampler","_downSamplerTarget","mipMaping","_output","createU84","context","bindRenderTarget","renderTargetMipmap","wrap","_draw","_blurIn","_blurOut1","_blurOut2","quality","tex1","tex2","_computeTarget","_splitAlpha","_histogram_scan_shader","_withoutMaskBlit","_maskBlit","_mean","_targetAlpha","_blurHQ","_scan","sourceMode","ColorMatchPass","AVERAGE","sourceTexture","color_variation_hue","color_variation_chroma","color_variation_luma","useMask","mask_hue","mask_chroma","mask_luma","mask_blur","mask_smoothness","TEXTURE","smoothTex","blurTex","targetTex","opacityTex","COLOR","defaultParams","createUid","createOss","createDiamond","createUV","excludeKeys","createObjByOwnKeys","d2","newSource","onInit","sourceId","arr","PackSourceGroup","sourceType","currItem","isHashEqual","Set","getOwnPropertyNames","newObj","diamond","groupId","uvsize","locked","colorcard","store","showLoading","nativeProductMap","nativeMatMap","defaultAlbeoColor","destroy","afterInit","showGizmo","gizmoAttach","packSource","initSceneProducts","updateController","initSceneMats","createNativeMat","setGeomMat","createSceneProductObj","prodObj","prodConf","findProductDef","geomCon","findGeomDef","createProductObj","noShadow","srcProd","defaultMat","addMat","comps","createGroup","getGeoms","updateTransform","prodDef","comp","setGeomVisible","initNativeMatMap","initSceneMat","nativeProd","packProd","matItem","matProdItem","findMatDef","matNodes","initPackMat","nativeMat","compName","props","isRequired","loading","RefCanvas","initQueen","loadPackSource","ContentStyle","loadingStyle","useContainerRefWithRadio","radio","gap","contentRef","containerRef","resizeHandler","changeContainerStyle","containerEl","contentEl","contentRatio","contentGap","loadMatSource","RefAsset","assetType","loaded","previewId","renderAsset","Mesh","Mat","msgData","postMessage","channelFactory","ReaderWriterGLTF","_filesMap","_loadedFiles","_bufferViewCache","_basicAnimationManager","_visitedNodes","_animatedNodes","_bones","_skeletonToInfluenceMap","_inputImgReader","_localPath","_extensions","_nodeAnimationTypes","base64ToArrayBuffer","base64","binary_string","atob","bytes","WEBGL_COMPONENT_TYPES","5120","5121","5122","5123","5125","5126","TYPE_TABLE","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","ATTRIBUTE_OSGJS_TABLE","POSITION","NORMAL","TANGENT","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","TEXCOORD_3","TEXCOORD_4","TEXCOORD_5","TEXCOORD_6","TEXCOORD_7","TEXCOORD_8","TEXCOORD_9","TEXCOORD_10","TEXCOORD_11","TEXCOORD_12","TEXCOORD_13","TEXCOORD_14","TEXCOORD_15","COLOR_0","JOINTS_0","WEIGHTS_0","TEXTURE_FORMAT","6406","6407","6408","6409","6410","LUMINANCE_ALPHA","TYPE_CHANNEL_PATH","weights","TYPE_STACKED_TRANSFORMS","PBR_SPEC_EXT","PBR_SPEC_MODE","PBR_METAL_MODE","DIFFUSE_TEXTURE_UNIT","SPECULAR_GLOSSINESS_TEXTURE_UNIT","METALLIC_ROUGHNESS_TEXTURE_UNIT","SPECULAR_TEXTURE_UNIT","EMISSIVE_TEXTURE_UNIT","ALBEDO_UNIFORM","METALLIC_ROUGHNESS_UNIFORM","SPECULAR_UNIFORM","NORMAL_UNIFORM","AO_UNIFORM","EMISSIVE_UNIFORM","_glTFJSON","_stateSetMap","_inputReader","_rootStateSet","_defaultBlendFunc","_transparentBlendFunc","_defaultCullFace","_doubleSideCullFace","_preProcessNodes","_gltfJSON","meshes","osgjsNodeName","loadBuffers","buffers","loadURI","loadBufferViews","bufferViews","bufferView","byteOffset","loadAccessors","accessors","bufferArray","accessor","bufferViewIndex","componentType","elementBytes","itemBytes","byteStride","normalized","_computeNodeMatrix","loadNodes","skins","usedAsBone","skin","skeleton","osgjsNode","osgjsNodeAttached","osgjsGeometry","setBoneNameID","osgjsBoneMapID","_createMatrixTransform","_linkNodes","osgjsChild","hasChild","loadSkins","_processSkin","loadScenes","_osgjsScene","sceneNodes","rootNodes","_assignGeometryAttributes","gltfAttributes","accessorIndex","osgjsAttributeName","_assignGeometryPrimitives","primitiveMode","osgPrimitive","_getMorphTargetName","_computeAbsoluteMorphData","baseAttributes","morphAttributes","morphAbsoluteComputed","baseAccessorIndex","baseAccessor","_processMorphGeometry","morphUpdateCallback","morphTarget","osgjsMorphGeometry","osgjsUpdateMorph","loadMeshes","materials","osgjsGeometries","rigGeometry","computeBoundingBox","osgjsStateSet","loadImages","decodeURI","gltfTexture","osgjsTexture","_pbrMetallicRoughnessTextureUniforms","metalnessRoughness","_pbrMetallicRoughness","pbrWorklow","baseColorTexture","baseColorFactor","metallicFactor","metallic","metallicRoughnessTexture","_KHR_materials_pbrSpecularGlossinessTextureUniforms","specluarGlossiness","_KHR_materials_pbrSpecularGlossiness","diffuseTexture","diffuseFactor","specularFactor","glossinessFactor","specularGlossinessTexture","loadMaterials","hasTransparentMaterial","hasDoubleSidedMaterial","rootStateSet","pbrMetallicRoughness","extensions","KHR_materials_pbrSpecularGlossiness","normalTexture","occlusionTexture","emissiveTexture","emissiveFactor","alphaMode","doubleSided","_createBone","nodeID","nodeAnimationTypes","updateCallback","stackTransforms","StackedType","skinID","inverseBindMatrixAccessor","joints","inverseBindMatrices","boneMap","boneMapID","boneID","parentID","boneParent","loadAnimations","osgjsAnimations","samplers","osgjsChannels","sampler","accessorValues","createChannel","nbTargets","nkKeys","targetIndex","animationFactory","animationManager","_animationManager","glTFFile","readJSON","addReaderWriter","JSZip","ReaderWriterZIP","_fileName","readZipFile","zfile","fileOrBlob","ReaderWriterQueen","req","Request","credentials","fetch","response","bf","osgPlugins","loadFileTest","routes","component","router","history","App","use","mount","_keys","_map","arrayLength","hasKey","getMap","getKeys","nodeMask","_boundingSphereComputed","_boundingBox","_boundingBoxComputed","_updateCallbacks","_cullCallback","_cullingActive","_numChildrenWithCullingDisabled","_numChildrenRequiringUpdateTraversal","_tmpBox","pooledMatrix","nodeGetMat","validNodeMask","pushOntoNodePath","popFromNodePath","deltaUpdate","_updateNumChildrenRequeringUpdateTraversal","parentNum","getUpdateCallback","hasExistingCallback","arrayIdx","getNumChildrenWithCullingDisabled","getCullingActive","setNumChildrenWithCullingDisabled","getNumChildren","getChild","nbChildren","updateCallbackRemoved","ascend","expandByBoundingSphere","expandRadiusBySphere","getWorldMatrices","CollectParentPaths","nodePaths","halt","collected","matrixCreate","matrixList","matrixGenerator","isCullingActive","CompilerColorGeometry","configColor","cloneStateAttributeConfig","createFragmentShaderGraph","getOrCreateUniform","createVariable","setValue","ShaderGeneratorCompilerColorGeometry","CompilerColorSkinning","configSkinning","getOrCreateVarying","declareVertexVaryings","roots","getOrCreateAttribute","ShaderGeneratorCompilerColorSkinning","GeometryColorDebugVisitor","_debugColor","_debugSkinning","_stCenter","CompilerSkinningGeometry","setGeometryDebug","setSkinningDebug","disableDebug","_debugCenterGeometry","verts","geo","mt","_isCenterDebug","_debugRigGeometry","BonesColor","eltBones","Bones","eltWeights","Weights","bones","_rigTransformImplementation","nbBones","bonesColor","idb","c0","w0","w1","w2","w3","idc","_debugGeometry","debugColor","debugSkinning","_originalStateSet","_isNormalDebug","renderOrder","renderOrderNum","_view","_renderer","_attachments","setView","_finalDrawCallback","getFinalDrawCallback","setInitialDrawCallback","_initialDrawCallback","getInitialDrawCallback","clearMask","modelviewMatrix","setViewMatrixAsLookAt","setProjectionMatrixAsOrtho","getRenderOrder","orderNum","bufferComponent","ArrayType","Float64Array","setMatrixArrayType","create64","fromValues32","fromValues64","transformMat4Rotate","mth","neg","INFINITY","NEGATIVE_INFINITY","zeroRotation","fromEuler","halfToRad","cx","cy","sz","cz","getEulerDeprecated","getEuler","qx","qy","qz","qw","a2","outx","outy","outz","outw","ax","ay","az","aw","bx","by","bz","bw","invLen","tempNear","tempFar","getLookAt","mvp","withNearFar","computeNearFar","nbPlanes","znear","A","B","C","getSqrScale","glmRotate","rad","glmFromRotate","destination","applyViewport","CompilerOffsetNormal","configNormal","getOffsetDirection","getOrCreateModelNormal","getOrCreateModelVertex","vertexOffset","getVariable","getOrCreateViewVertex","_variables","FragEyeVector","isEmpty","_varyings","ShaderGeneratorCompilerOffsetNormal","CompilerOffsetTangent","configTangent","getOrCreateModelTangent","ShaderGeneratorCompilerOffsetTangent","_unifScale","_normalStateSet","ts","_tangentStateSet","setTangentVisibility","setNormalVisibility","_isVisitedNormalDebug","_createDebugGeom","nbCB","_createDoubleOffsetArray","elts","_createDoubledBufferArray","getInitialBufferArray","ctor","elementsDouble","iSize","iSize2","_addMorphTargets","originMorph","morph","vecName","originTargets","origTarget","origAttrs","newTarget","newAttrs","dispVec","rig","_stateSetAnimation","nbParents","isBufferGZIP","_clearColor","_clearMask","_preRenderList","_postRenderList","createRenderStageOrder","renderStage","pooledRenderStageOrder","_initInternal","getPreRenderStageList","getPostRenderStageList","addPreRenderStage","renderStageOrder","addPostRenderStage","drawPreRenderStages","previousRenderLeaf","drawPostRenderStages","applyCamera","attachments","keyAttachment","attach","OSGObject","_userdata","Constructor","instanceID","LOG2E","log10","LOG10E","endsWith","_slicePolyfill","setTest","hasConstructorParameterSupport","nativeSetConstructor","CustomEvent","bubbles","cancelable","createEvent","initCustomEvent","_range","_rangeMode","DISTANCE_FROM_EYE_POINT","_userDefinedCenter","_centerMode","USE_BOUNDING_SPHERE_CENTER","PIXEL_SIZE_ON_SCREEN","USER_DEFINED_CENTER","UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED","getRadius","getCenter","centerMode","projectBoundingSphere","camMatrix","fle","radius2","l2","lenght","zeroVector","viewModel","TRAVERSE_ACTIVE_CHILDREN","requiredRange","projmatrix","numChildren","ImageBitmap","ImageObject","_url","_mipmap","_isGreyscale","getURL","useOrCreateImage","currentSrc","nbImg","isCanvas","HTMLCanvasElement","isBitmap","isVideo","HTMLVideoElement","isImage","naturalWidth","videoWidth","naturalHeight","videoHeight","isGreyscale","nbSamples","sampleX","sampleY","xFactor","yFactor","complete","imageTry","CompilerShadowCast","_attributes","_shadowCastAttribute","_isBillboard","_skinningAttribute","_morphAttribute","_pointSizeAttribute","registerTextureAttributes","createShadowCastDepth","shadowDepthRange","fragEye","nodeMaskOverride","visitorType","NODE_VISITOR","_databaseRequestHandler","_traversalFunctions","_pushOntoNodePath","_popFromNodePath","UPDATE_VISITOR","traverseParents","traverseChildren","pushOntoNodePathParents","unshift","pushOntoNodePathChildren","popFromNodePathParents","popFromNodePathChildren","getNodeMaskOverride","getNodePath","dbpager","getDatabaseRequestHandler","_generators","getShaderGenerator","shaderGenerator","ShaderProcessor","createInstance","shaderLib","shadowShaderLib","_shadersText","_shadersList","_globalDefaultprecision","_debugLines","_includeR","_includeCondR","_defineR","_precisionR","instrumentShaderlines","content","sourceID","preShader","preprocess","inputsDefines","strMatch","includeOpt","includeName","found","defineString","_getSortedUnique","filterDuplicate","_convertExtensionsToWebGL2","cbRenamer","cbDefiner","definer","renamer","strShader","_convertToWebGL2","replaceMRT","number","varName","isFragment","_hasVersion","strCore","convertToWebGL2","WebglCaps","strVersion","strExtensions","strDefines","strPrecision","lib","nodeFactory","_nodes","debugShaderNode","_clippingMask","_planeList","_vertexList","_maskStack","_resultMask","pl","setToUnitFrustum","withNear","withFar","setToBoundingBox","setAndTransformProvidingInverse","_referenceVertexList","polytopBackIndex","numActivePlanes","voidset","empty","setReferenceVertexList","getReferenceVertexList","plength","pMasklength","getResultMask","getMaskStack","polytopeBack","containsVertices","outside","containsAllOfVertices","intersectsOrContainsVertices","containsAllOfBoundingSphere","containsAllOfBoundingBox","centerx","centery","centerz","sizex","sizey","sizez","TexCoord0","scopes","newQuad","cornerx","cornery","cornerz","wx","wy","wz","hx","hy","hz","uvs","colors","createTexturedSphere","widthSegments","phiStart","phiLength","thetaStart","thetaLength","segmentsX","segmentsY","useDrawArrays","nbPrim","fullVerticesList","fullNormalsList","fullUVList","vtxCount","triCount","v4","n1","n2","n3","n4","uv4","getCoordAndUvSphere","norm","idv","idu","iStart","tristart","res1","res2","uy","uz","col","createTexturedSphereGeometry","makeFailHTML","GET_A_WEBGL_BROWSER","OTHER_PROBLEM","doReportCreationError","opt_attribs","opt_onError","handleCreationError","container","innerHTML","create3DContext","checkAndCreate3DContext","webgl2","webkitRequestAnimationFrame","mozRequestAnimationFrame","oRequestAnimationFrame","msRequestAnimationFrame","cancelRequestAnimFrame","webkitCancelRequestAnimationFrame","mozCancelRequestAnimationFrame","oCancelRequestAnimationFrame","msCancelRequestAnimationFrame","getTime","FRAME_COUNT","setContext","getQueryObjectEXT","_hasTimeElapsed","TIME_ELAPSED_EXT","QUERY_COUNTER_BITS_EXT","_hasTimeStamp","TIMESTAMP_EXT","_ext","_frameAverageCount","_glQueries","_queriesByID","_userQueries","_queryCount","_nbOpened","setFrameAverageCount","clearQueries","glQueries","nbQueries","query","_pollingStartQuery","_pollingEndQuery","supportTimeStamp","_callback","createUserQuery","createGLQuery","_startIndex","_endIndex","_isOpened","_siblings","createQuery","getOrCreateLastGLQuery","beginCurrentQuery","_isWaiting","endCurrentQuery","getAvailableQueryByID","siblings","nbSiblings","qsib","newQuery","queryCounterEXT","computeQueryAverageTime","glAvg","_averageTimer","computeFullAverageTime","sibAvg","nbGlQueries","disjoint","GPU_DISJOINT_EXT","pollQuery","userQueries","nbUserQueries","timeElapsed","lastQuery","available","QUERY_RESULT_AVAILABLE","startTime","QUERY_RESULT","endTime","_resultCount","_initialBufferArray","_bufferArray","setBufferArray","setInitialBufferArray","getBufferArray","makeFunc","methodName","DEFAULT_CULLING","setCullingMask","getCullingMask","setFrustum","getCurrentResultMask","resetCullingMask","isBoundingBoxCulled","VIEW_FRUSTUM_CULLING","isBoundingSphereCulled","isVerticesCulled","NO_CULLING","VIEW_FRUSTUM_LEFT_CULLING","VIEW_FRUSTUM_RIGHT_CULLING","VIEW_FRUSTUM_TOP_CULLING","VIEW_FRUSTUM_BOTTOM_CULLING","NEAR_PLANE_CULLING","FAR_PLANE_CULLING","VIEW_FRUSTUM_SIDES_CULLING","ENABLE_ALL_CULLING","_constantColor","getConstantColor","_ambient","_diffuse","_specular","_emission","_shininess","getParameterName","emission","shininess","getEmission","getShininess","setTransparency","plugins","plugin","_matrix","_matrixDirty","_cachedMatrix","_billboardAttribute","setScaleFromVec3","setScaleFromvec3","scaleVec","setMinimumScale","minimumScale","getMinimumScale","maximumScale","getMaximumScale","autoScaleToScreen","getAutoScaleToScreen","setAutoScaleTransitionWidthRatio","autoScaleTransitionWidthRatio","getAutoScaleTransitionWidthRatio","computeMatrix","rotInverse","scaleInverse","computeBound","scale00","scale10","W","M","P00","P20_00","P10","P20_10","P23","P33","pixelSizeVector","scaleRatio","readImage","_input","Version","nodeOld","parseSceneGraphDeprecated","newnode","getFieldBackwardCompatible","field","setMaterial","setBlendFunc","tl","blendfunc","newblendfunc","newmaterial","_primitives","Primitives","lp","newstateset","childLength","CW","applyFrontFace","_primitiveIndex","_backface","intersectionVisitor","intersector","getPrimitiveMask","getIntersectionLimit","setLimitOneIntersection","limitOneIntersection","getModelMatrix","TextureProfile","_size","computeSize","textureProfile","numBitsPerTexel","getSize","TextureObject","textureSet","_textureSet","_profile","getTextureSet","TextureObjectSet","profile","_usedTextureObjects","_orphanedTextureObjects","getProfile","getUsedTextureObjects","getOrphanedTextureObjects","takeOrGenerate","textureObject","takeFromOrphans","textureID","orphan","flushDeletedTextureObjects","nbTextures","flushAllDeletedTextureObjects","TextureManager","_textureSetMap","generateTextureObject","totalUsed","totalUnused","keyTexture","nbUsed","nbUnused","MB","reportStats","total","notice","availableTimeArg","releaseTextureObject","_applyTexImage2DCallbacks","checkAndFixEnum","NONE","DEPTH_COMPONENT","DEPTH_STENCIL","DEPTH24_STENCIL8","DEPTH_COMPONENT24","DEPTH_COMPONENT32F","COMPRESSED_RGB_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT3_EXT","COMPRESSED_RGBA_S3TC_DXT5_EXT","COMPRESSED_RGB_ATC_WEBGL","COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL","COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL","COMPRESSED_RGB_PVRTC_4BPPV1_IMG","COMPRESSED_RGB_PVRTC_2BPPV1_IMG","COMPRESSED_RGBA_PVRTC_4BPPV1_IMG","COMPRESSED_RGBA_PVRTC_2BPPV1_IMG","COMPRESSED_RGB_ETC1_WEBGL","NEAREST_MIPMAP_NEAREST","LINEAR_MIPMAP_NEAREST","TEXTURE_MAX_ANISOTROPY_EXT","MIRRORED_REPEAT","TEXTURE_BINDING_CUBE_MAP","MAX_CUBE_MAP_TEXTURE_SIZE","UNSIGNED_SHORT","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","UNSIGNED_SHORT_5_6_5","UNSIGNED_INT_10F_11F_11F_REV","UNSIGNED_INT_24_8","RED_INTEGER","RGB_INTEGER","RGBA_INTEGER","RG_INTEGER","RED","R8","R8UI","RG8","RG8UI","RGB8","RGB565","RGB9_E5","RGB8UI","RGBA8","RGB5_A1","RGBA4","RGBA8UI","SRGB8_ALPHA8","SRGB8","R16F","RG16F","RGB16F","RGBA16F","R11F_G11F_B10F","R32F","RG32F","RGB32F","RGBA32F","createMapGl2ToGl1","createMapGl1ToGl2","halfFloat","ushort","uin24","UNSIGNED_INT","internalFormatGl2ToGl1","internalFormatGl1ToGl2","_sTextureManager","getEnumFromString","_image","_magFilter","_minFilter","_maxAnisotropy","_wrapS","_wrapT","_isCompressed","_colorSpaceConversion","setColorSpaceConversion","getTextureTarget","getTextureObject","maxSize","addApplyTexImage2DCallback","removeApplyTexImage2DCallback","getWrapT","getWrapS","dirtyTextureParameters","dirtyMipmap","dirtyTextureObject","getMagFilter","multiplier","getMaxAnisotropy","_imageFormat","setUnrefImageDataAfterApply","checkIsCompressed","fo","formatSource","getInternalFormat","powerOfTwo","TEXTURE_WRAP_S","TEXTURE_WRAP_T","_getInternalFormatGL","mips","nbLevel","imi","numCallback","applyImage","_getTypeGL","imgWidth","imgHeight","createFromImage","createFromCanvas","ShaderGeneratorShadowCast","ShadowCompiler","updateCallbackList","numStateSetUpdateCallback","ncs","numUpdateCallback","createCullingSet","_modelViewMatrixStack","_viewportStack","_cullingSetStack","_frustumVolume","_bbCornerFar","_bbCornerNear","_pooledCullingSet","_cameraIndexStack","_cameraModelViewIndexStack","_cameraMatrixInverse","_cameraMatrixInverseRoot","getProjectionMatrixStack","getCameraInverseMatrix","mapCameraInverse","cameraInverse","indexInModelViewMatrixStack","invMatrix","world","modelViewMatrixStackArray","getLookVectorLocal","outLookVector","lookVectorLocal","pushCullingSet","popCullingSet","isCulled","bsWorld","maxNodePathLength","pushModelViewMatrix","lookVector","matInverse","pushProjectionMatrix","FindPagedLODsVisitor","_activePagedLODList","_frameNumber","setFrameNumberOfLastTraversal","pagedLODList","ExpiredPagedLODVisitor","_childrenList","_markRequestsExpired","removeExpiredChildrenAndFindPagedLODs","expiryTime","expiryFrame","removedChildren","sizeBefore","removeExpiredChildren","request","numRanges","_perRangeDataList","getDatabaseRequest","_groupExpired","_loadedModel","sortByTimeStamp","r1","_timeStamp","sortByPriority","_pendingRequests","_pendingNodes","_loading","_progressCallback","_lastCB","_childrenToRemoveList","_downloadingRequestsNumber","_maxRequestsPerFrame","_acceptNewRequests","_expiredPagedLODVisitor","_findPagedLODsVisitor","_targetMaximumNumberOfPagedLOD","_elapsedTime","_beginTime","_availableTime","DatabaseRequest","_group","_function","setTargetMaximumNumberOfPageLOD","getTargetMaximumNumberOfPageLOD","setAcceptNewDatabaseRequests","acceptNewRequests","getAcceptNewDatabaseRequests","executeProgressCallback","removeExpiredSubgraphs","takeRequests","addLoadedDataToSceneGraph","setMaxRequestsPerFrame","numRequests","getMaxRequestsPerFrame","getRequestListSize","setProgressCallback","timeStamp","setTimeStamp","registerPagedLODs","isLoading","subgraph","requestNodeFile","timestamp","dbrequest","processRequest","loadNodeFromFunction","loadNodeFromURL","_releaseExpiredSubgraphs","numToPrune","expiredPagedLODVisitor","getFrameNumberOfLastTraversal","_spotCutoff","_spotBlend","_attenuation","viewPosition","viewDirection","modelViewMatrix","modelViewNormalMatrix","attenuation","spotCutOff","spotBlend","getSpotBlend","setGround","getGround","getConstantAttenuation","getLinearAttenuation","getQuadraticAttenuation","setLightAsDirection","setLightAsSpot","setLightAsHemi","setLightAsPoint","isSpotLight","isHemiLight","applyPositionedUniform","modelViewNormal","spotsize","replaceCallback","shaderExtension","regExt","globalReg","decalrs","fragData","datagl","convert2WebGL2","cbFilterDuplicate","isStringInteger","getFinalDefinedValue","testIf","tok","eval","processBranch","trim","fixIndent","cleanDeclarations","handleVaryings","handleUniforms","handleAttributes","handlePrecision","addExtensions","addVersion","hasVersion","cbUnroll","unrollReplace","glslPreprocessShader","glslesPreprocessor","debugExperimental","doStats","pruneComments","logCounts","minify","profileTimeEach","profileTimeGlobal","pruneUnused","pruneDefines","replaceDefine","optimize","tabs","whitespace","extractArguments","replaceRange","resolveDefineFunction","resolveDefines","getDefaultDefines","GL_FRAGMENT_PRECISION_HIGH","fastPreprocess","unprocessedShader","shadersText","_vaoObject","_sDeletedGLVertexArrayObjectCache","deleteGLVertexArrayObject","flushDeletedGLVertexArrayObjects","flushAllDeletedGLVertexArrayObjects","createVertexArray","vao","_lightingMode","_clientWidth","_clientHeight","_sizeObserver","setLightingMode","createRenderer","NO_LIGHT","devicePixelRatio","widthPixel","heightPixel","getCanvasClientWidth","getCanvasClientHeight","overrideDevicePixelRatio","refreshGraph","previousNode","statsNode","setDatabasePager","lightingMode","availableTimeBudget","flushDeletedGLPrograms","flushDeletedGLFrameBuffers","flushDeletedGLRenderBuffers","flushAllDeletedGLPrograms","flushAllDeletedGLFrameBuffers","flushAllDeletedGLRenderBuffers","uType","setIndexArray","nbBytes","_buildOptions","perLeaf","maxLevel","setShape","_shape","MAX_MORPH_GPU","_morphTargetNames","_maxMorphGPU","_isInitialized","EFFECTIVE_EPS","getStateSetAnimation","getTargetsWeight","getMaximumPossibleMorphGPU","setMaximumPossibleMorphGPU","getMorphTargetNames","isInitialized","tmpBox","appendVertexAttributeToList","_computeEffectiveSumWeights","computeTransformedVertex","id3","baseVerts","sumWeights","morphElts","vertexLen","morphedVerts","_morphedVerts","baseWeight","_cacheDrawCall","_useVAO","_vao","_cacheVertexAttributeBufferList","enableVAO","releaseVAO","_glContext","prgID","setVertexAttribArray","_generateVertexSetup","validAttributeKeyList","validAttributeIndexList","includeFirstIndexBuffer","vertexAttributeSetup","_generatePrimitives","validPrimitives","optimizeVAO","primitiveSetup","generateDrawCommand","validAttributeList","attributesCacheMap","_attributesCache","geometryVertexAttributes","autogeneratedFunction","useVAO","listVABuff","attributeBuffer","optimizeIndexBufferVAO","clearVertexAttribCache","setVertexArrayObject","vertexSetupCommand","Function","vaoSetup","drawCommand","_getValidPrimitives","_warnInvalidPrimitives","cachedDraw","_warnNoPrimitives","computeCentroid","_centroidComputed","_centroid","sumArea","tmp1Vec3","tmp2Vec3","vertexArray","postfix","keyPostFix","urlOptions","OptionsDefault","shaderStats","keyOption","getOptionsURL","vars","hashes","setNotifyLevel","NOTICE","WARN","ERROR","logContent","divLogger","codeElement","firstChild","logFunc","overflow","zIndex","maxWidth","pointerEvents","writeMask","_func","_near","_far","_writeMask","GREATER","NOTEQUAL","GEQUAL","setWriteMask","applyDepth","_projectionStack","_modelStack","_viewStack","_windowStack","getIntersector","pushModelMatrix","popModelMatrix","pushViewMatrix","popViewMatrix","pushWindowMatrix","pushWindowMatrixUsingViewport","getWindowMatrix","popWindowMatrix","getTransformation","applyNode","logSub","intLevel","currentNotifyLevel","strLevel","trace","logSubFold","title","unFlattenMatrix","rowMajor","logMatrix","table","logMatrixFold","FATAL","LOG","levelEntries","noticeFold","logFold","noticeMatrix","noticeMatrixFold","label","logLevel","getNotifyLevel","setConsole","replacement","sprintf","shaderUtils","Variable","_prefix","declare","Constant","globalDeclaration","Attribute","Varying","Sampler","Output","wholeName","_unique","isUnique","glFragColor","glPosition","glPointSize","Define","_defineName","_defineValue","BaseOperator","Add","_getFirstVariableCast","variable","inType","outType","outputType","addType","firstVariable","Mult","SetFromNode","MatrixMultDirection","_overwriteW","_forceComplement","_inverseOp","complement","setInverse","setForceComplement","setOverwriteW","vecIn","vecOut","inputType","matrixType","strOut","strCasted","strvec3","MatrixMultPosition","Blend","ADD","MIX","MULTIPLY","InlineCode","replaceVariables","reg","Factory","extractFunctions","shadowLib","registerNodes","operations","registerNode","functions","lightCommon","skinning","morphing","colorEncode","billboard","other","newbb","expandByvec3","dv","dr","sh","newRadius","intersects","sphCenter","sphRadius","_fbo","_rbo","_buffers","_hasMRT","_sDeletedGLFrameBufferCache","deleteGLFrameBuffer","fb","_sDeletedGLRenderBufferCache","deleteGLRenderBuffer","renderBufferObject","getAttachment","attachmentType","_reportFrameBufferError","getRenderBufferObject","createFrameBufferObject","createRenderBuffer","renderBuffer","createRenderbuffer","framebufferRenderBuffer","rawgl","trackedObject","defaultName","applyTextureAttribute","DRAW_FRAMEBUFFER","bindFrameBufferObject","checkStatus","_checkAllowedSize","nbAttachments","bufs","hasRenderBuffer","COLOR_ATTACHMENT15","_stackedTransforms","transforms","stacked","nbStacked","applyScissor","sourceRGB","destinationRGB","sourceAlpha","destinationAlpha","_sourceFactor","_destinationFactor","_sourceFactorAlpha","_destinationFactorAlpha","_separate","setSource","setDestination","SRC_COLOR","ONE_MINUS_SRC_COLOR","DST_ALPHA","ONE_MINUS_DST_ALPHA","DST_COLOR","ONE_MINUS_DST_COLOR","SRC_ALPHA_SATURATE","BLEND_DST_RGB","BLEND_SRC_RGB","BLEND_DST_ALPHA","BLEND_SRC_ALPHA","CONSTANT_COLOR","ONE_MINUS_CONSTANT_COLOR","CONSTANT_ALPHA","ONE_MINUS_CONSTANT_ALPHA","BLEND_COLOR","getDestination","getSeparate","checkSeparate","getSourceRGB","getSourceAlpha","getDestinationRGB","getDestinationAlpha","applyBlendFunc","createTarget","applyCullFace","_databasePager","_sceneData","hasOwnPropertyFunc","isFunction","isPlainObject","nodeType","deep","F","properties","objectType","createDefaultType","libName","libraryClassName","classObject","generateId","typeMap","objectNodeType","setNodeTypeID","getNodeTypeID","cullVisitorHelper","parentNodeTypeID","nodeTypeId","applyFunctionArray","typeMemberIndex","textureTypeMemberIndex","stateAttributeTypeMember","textureStateAttributeTypeMember","attributeTypeIndex","stateAttributeType","getStateAttributeTypeNameToTypeId","attributeId","getMaxStateAttributeTypeID","attributeTypeName","typeId","getOrCreateTextureStateAttributeTypeMemberIndexFromName","registeredTimers","logTime","logTimeEnd","profileEnd","seen","compilerClass","validAttributeTypeMember","validTextureAttributeTypeMember","getMatrixStack","forceSyncCompilation","syncCompile","glSync","sp","uniformRegexp","attributesRegexp","attributeMap","vShader","fShader","_program","_nullProgram","_vertex","_fragment","_uniformsCache","_activeUniforms","_foreignUniforms","_trackAttributes","_asyncCompilation","_compileClean","setVertexShader","setFragmentShader","_sDeletedGLProgramCache","deleteGLProgram","numPrograms","vs","getVertexShader","getFragmentShader","getProgram","activeUniforms","setForeignUniforms","foreignUniforms","getForeignUniforms","setUniformsCache","uniformsCache","setAttributesCache","attributesCache","getAttributesCache","setTrackAttributes","trackAttributes","getTrackAttributes","_cacheUniformId","_rebuildProgramFromSpector","vertexShaderText","fragmentShaderText","onCompiled","onError","_spectorOnCompiled","_spectorOnError","_onErrorToSpector","errLink","_onCompilationToSpector","_bindProgramToSpector","spector","__SPECTOR_rebuildProgram","_logDebugShaders","debugShader","getTranslatedShaderSource","_activateFailSafe","createProgram","_glAttachAndLink","programGL","vertexShader","attachShader","linkProgram","_glShaderCompile","_glShaderCompilationResult","success","fragmentText","vertexText","_attributeMap","_uniformMap","getShaderName","_shaderName","getCompilationResultAndLink","link","bindAttribLocation","_logShaderStats","compileResult","LINK_STATUS","validateProgram","validationLogProgram","getProgramInfoLog","cacheAttributeList","cacheUniformList","placeHolder","frameNum","applyProgram","uniformList","getUniformLocation","registerErrorCallback","CompilerVertex","_createVertexShader","declareVertexMain","vname","createShaderFromGraphs","getDebugIdentifier","declarePointSize","declareVertexPosition","getOrCreateConstantOne","varyings","keyVarying","vModelVertex","vModelNormal","vModelTangent","vViewVertex","vViewNormal","getOrCreateViewNormal","vViewTangent","getOrCreateViewTangent","vVertexColor","venabled","acolor","vcolor","varying","declareVertexTransformBillboard","declareScreenVertex","getOrCreateProjectionMatrix","ModelViewMatrix","ProjectionMatrix","getOrCreateBoneMatrix","boneMatrix","inputWeights","inputBones","bonesIndex","morphTangentApproximation","inputVertex","outputVertex","normalizedMorph","getOrCreateLocalNormal","getOrCreateMorphNormal","tangent","targetWeights","nWeights","wts","morphTransformVec3","numTargets","skinTransformVertex","skinTransformNormal","getOrCreateMorphVertex","inputNormal","getOrCreateMorphTangent","inputTangent","hasMorphTangent","getOrCreateSkinVertex","getOrCreateSkinNormal","getOrCreateSkinTangent","getOrCreateLocalVertex","getOrCreateLocalTangent","normalizeAndSetAlpha","tang3","tang4","tangNormalized","wrapperVertexOnly","_fragmentShaderMode","logError","fnName","CompilerFragment","_createFragmentShader","cleanAfterFragment","applyPointSizeCircle","_activeNodeMap","_texturesByName","createDefaultFragmentShaderGraph","fofd","getOrCreateConstant","fragCol","finalColor","getLighting","getOrCreateMaterialDiffuseColor","getOrCreateMaterialEmission","textureColor","getDiffuseColorFromTextures","texColor","getAlpha","getPremultAlpha","fragColor","textureTexel","getFirstValidTexture","texelAlpha","getOrCreateFrontViewTangent","frontViewTangent","getOrCreateFrontViewNormal","frontViewNormal","getOrCreateNormalizedViewEyeDirection","eyeVector","getOrCreateNormalizedFrontViewNormal","nFrontViewNormal","getOrCreateFrontModelNormal","frontModelNormal","getOrCreateNormalizedFrontModelNormal","nFrontModelNormal","premultAlpha","getColorsRGB","finalSrgbColor","multiplyDiffuseWithVertexColor","vertexColorUniform","texturesInput","getTextureByName","texAccum","_getShadowReceiveAttributeFromLightNum","_getShadowTextureFromLightNum","getInputsFromShadow","shadowReceive","lighted","shadowUniforms","tUnit","textureUniforms","normalWorld","vertexWorld","getOrCreateSampler","shadowSize","shadowViewRight","shadowViewUp","shadowViewLook","shadowBias","getOrCreateDistanceShadow","_computeShadowOutDistance","getOrCreateJitterShadow","hasLightShadow","createShadowingLight","shadowedOutput","outDistance","doJitter","addDefines","getOrCreateMaterialNormal","matDiffuse","getOrCreateMaterialSpecularColor","getOrCreateMaterialSpecularHardness","getOrCreateMaterialAmbient","getLightingSeparate","finalDiffuse","finalSpecular","diffuseSum","specularSum","getLightSeparate","diffuseOut","specularOut","precompute","getPrecomputeLight","getLightWithPrecompute","shadowFactor","getAmbientLight","eyeLightDir","dotNL","nodeName","lightUniforms","lightType","viewVertex","lightAttenuation","lightViewPosition","lightViewDirection","lightSpotCutOff","lightSpotBlend","materialDiffuse","materialSpecular","materialShininess","lightDiffuse","lightSpecular","lightGround","getOutputsFromLight","lightAmbient","materialAmbient","silenceWarning","createTextureRGBA","textureSampler","texCoord","texel","wrapperFragmentOnly","_textureAttributes","_compiledNodeMap","_traversedNodeMap","_vertexShader","_fragmentShader","_invariantPosition","_customVertexShader","_customFragmentShader","logWarn","getOrCreateConstantZero","texturesNum","tu","tuTarget","tunit","tType","registerTexture","registerTextureShadow","tName","texObj","samplerName","variables","keyVariable","varNode","evaluateExtensions","evaluateDefines","shaderStack","evaluateGlobalVariableDeclaration","evaluateGlobalFunctionDeclaration","evaluate","shaderStr","compiledNodes","activeNodes","messages","nodeInputs","nodeInput","argOutputs","keyOutput","_logLookForVariable","factory","cacheID","nameID","varname","deepness","exist","markNodeAsVisited","checkOrMarkNodeAsTraversed","objectToArray","keyInput","_getAndInitFunctor","_functorEvaluateAndGatherField","evaluateAndGatherField","jl","_functorEvaluateGlobalFunctionDeclaration","globalFunctionDeclaration","decl","_functorEvaluateGlobalVariableDeclaration","declarations","sortDeclarations","iType","vatt","_functorEvaluate","modelVertex","modelNormal","modelTangent","viewNormal","viewTangent","setAllChildrenOff","setAllChildrenOn","ignoreCameras","userMatrix","nodePathIndex","ignoreCamera","nodePathLength","createPositionAttribute","sortMode","_sorted","_sortMode","defaultSortMode","_drawCallback","_pooledPositionedAttribute","_stateGraphList","SORT_BY_STATE","SORT_BACK_TO_FRONT","SORT_FRONT_TO_BACK","createRenderBin","pooledRenderBin","BinPrototypes","DepthSortedBin","sortBackToFrontFunction","_depth","sortFrontToBackFunction","sortBinNumberFunction","_createRenderBin","renderBinConstructor","addPositionAttribute","getStateGraphList","copyLeavesFromStateGraphListToRenderLeafList","detectedNaN","stateGraphList","stateGraphListLength","leafsArray","leafsArrayLength","getSortMode","sortBackToFront","sortFrontToBack","sortImplementation","SortMode","binsKeys","binsMap","binsKeysArray","binsKeysArrayLength","keyBin","setParent","getParent","findOrInsert","bins","getStage","positionedAttributes","stateAttribute","setGlobalDefaultAttribute","haveAppliedAttribute","binsKeysLength","current","stateList","stateListLength","dl","leafArray","leafArrayLength","_children","createStateGraph","statsNbMoveStateGraph","getLeafs","stateSetID","childrenMap","moveStateGraph","stackArray","sgCurrentArg","sgNewArg","sgNew","sgCurrent","applyUniformCache","modelview","applyModelViewMatrix","applyProjectionMatrix","matrixModelViewChanged","modelMatrix","_modelMatrix","modelUniform","viewUniform","CacheUniformApply","cacheIndex","_modelView","programInstanceID","getCacheUniformsApplyRenderLeaf","idLastDraw","lastStateSetStackSize","prevRenderGraph","prevRenderGraphParent","curRenderGraph","curRenderGraphParent","curRenderGraphStateSet","_stateSetStackChanged","_setStateSetsDrawID","LineSegmentIntersection","_threshold","_d","_invLength","_end","_dInvX","_dInvY","_dInvZ","zmin","zmax","invX","invY","invZ","closest0","closest1","sN","tN","D","sD","tD","sc","tc","e2","e1","tvec","pvec","qvec","r0","interX","interY","interZ","determinant","_intersections","_intersectionLimit","reachedLimit","primitiveMask","createStateBlendFunc","separate","sourceFactor","destinationFactor","sourceFactorAlpha","destinationFactorAlpha","createStateDepth","createStateFrontFace","createStateCullFace","createStateScissor","createStateColorMask","createStateViewport","createStateDepthMask","createStateClearDepth","createStateClearColor","StateCache","_stateClearColor","_stateClearDepth","_stateDepthMask","_stateViewport","_stateColorMask","_stateScissor","_stateDepth","_stateFrontFace","_stateCullFace","_stateBlendFunc","applyClearColor","applyClearDepth","applyDepthMask","applyViewportAttribute","applyColorMaskAttribute","applyScissorAttribute","applyFrontFaceAttribute","applyCullFaceAttribute","applyDepthAttribute","applyBlendFuncAttribute","applyClearStates","applyDrawStates","checkUniformCache","uniformArray","cacheArray","_excludeUniforms","uProjectionMatrix","uModelMatrix","uViewMatrix","uModelViewMatrix","uModelNormalMatrix","uModelViewNormalMatrix","uArrayColorEnabled","_shaderGeneratorProxy","break","_currentVAO","_currentIndexVBO","_shaderGeneratorNames","_modelViewMatrix","_modelNormalMatrix","_modelViewNormalMatrix","arrayColorEnable","_globalDefault","ArrayColorEnabled","_previousColorAttribPair","_vertexAttribMap","_disable","_programCommonUniformsCache","_lastAppliedModelViewMatrix","_lastAppliedProjectionMatrix","_programType","_programAttribute","_programUniformCache","_stateCache","getExcludeUniforms","_extVAO","pushCheckOverride","maskValue","_evaluateOverrideObjectOnStack","_back","pushAttributeMap","activeTextureUnits","activeTextureAttribute","textureUnitAttributeArray","getOrCreateTextureAttributeArray","pushUniformsList","generatorPair","tmpStack","tmpStackArray","matrixModel","sendNormal","mu","m2","getCurrentShaderGeneratorStateSet","programStack","stateSetProgramPair","generator","stateSetGeneratorPair","generatorStack","stateSetGenerator","_applyAttributeMapStateSet","stateSetAttributeArray","stateSetAttributePair","hasStateAttributeStack","hasStateAttributeStackChanged","_changed","stateSetAttribute","_applyAttributeStack","_createAttributeStack","_applyTextureAttributeMapListStateSet","stateSetTextureAttributeArrayList","_textureAttributeArray","stateSetTextureAttributeLength","stateTextureAttributeLength","maxTexture","stateSetTextureAttributeArray","_applyTextureAttribute","previousProgram","_currentShaderGenerator","generatedProgram","_applyGeneratedProgramUniforms","_applyCustomProgramUniforms","popAllStateSets","popAttributeMap","popUniformsList","globalDefault","applyAttributeMap","applyTextureAttributeMapList","stateSetUniformMap","uniformPair","textureAttributeArray","getGlobalDefaultAttribute","setGlobalDefaultTextureAttribute","getGlobalDefaultTextureAttribute","validAttributeArray","stateSetAttributeArrayLength","_attributeArrayLength","activeAttribute","lazyDisablingOfVertexAttributes","enableVertexColor","previousColorEnabled","disableVertexColor","applyDisablingOfVertexAttributes","vertexAttribMap","attrib","binded","currentArray","enableVertexAttribArray","_getActiveUniformsFromProgramAttributes","activeUniformsList","_attributeArrayStack","attributeKeys","keyUniform","_getActiveUniformsFromProgramTextureAttributes","textureAttributeKeysList","textureAttributeKeys","nbUnit","unitTextureAttributeList","_cacheUniformsForCustomProgram","uniformsFinal","loc","trackUniforms","programTrackUniformMap","programUniformMap","uniformMapStack","uniformStack","hasStateSetUniformPair","stateSetUniformPair","stateSetUniform","_checkErrorUniform","_computeForeignUniforms","activeUniformMap","_removeUniformsNotRequiredByProgram","_cacheUniformsForGeneratedProgram","shaderUniforms","stateSetUniforms","_copyUniformEntry","cacheData","_initUniformCache","foreignUniformKeys","cacheForeignUniforms","cacheActiveUniforms","uniStack","foreign","_checkCacheAndApplyUniform","indexCache","nameUniform","isCached","uniformArrayLength","cacheUniformsActive","cacheUniformsForeign","nbForeigns","nbStateSets","nbLast","_arrayLengths","getArrayLengths","shadowCast","shadowLinearSoft","floatFromTex","tapPCF","objectPair","requestFileFromURL","XMLHttpRequest","open","responseText","send","requestFileFromReader","readAsText","readAsDataURL","urlOrFile","DisplayGraphNode","selectables","_selectables","_linkList","_uniqueNodes","_uniqueEdges","getColorFromClassName","childID","childrenNode","createMatrixGrid","matrixArray","getLabel","generateNode","description","generateStateSet","hasNode","addEdge","generateSourceGeometry","sourceGeom","sourceGeomID","generateNodeAndLink","DisplayGraphRenderer","_renderBinMap","_renderBinStack","_generatorID","_refID","renderBin","rb","preRenderList","postRenderList","createNodeAndSetID","leafFunction","stateGraphID","stateGraphFunction","leafsPool","createLink","generateRenderLeaf","generateStateGraph","generateRenderStage","generateRenderBin","init$","$","SimpleTooltips","css","el","querySelectorAll","selector","showTooltip","hideTooltip","currentTarget","display","_graphNode","_graphRender","_displayNode","_displayRenderer","_cbSelect","_focusedElement","_idToDomElement","_$svg","append","_css","setCallbackSelect","d3","dagreD3","_createGraphApply","d3url","dagreurl","getScript","diGraph","Digraph","injectStyleElement","svg","svgGroup","initialScale","oldZoom","argSVG","styleTooltip","idToDom","oldDrawNodes","drawNodes","svgNodes","tooltip","click","onNodeSelect","focusOnGraph","selectNode","lastNode","fill","lastColor","elt","childNodes","activeNode","focusOnScene","_cssInjected","FindNearestParentSkeleton","_pathToRoot","UpdateRigGeometry","ObjectBase","finder","setSkeleton","setPathToSkeleton","getSkeleton","getNeedToComputeMatrix","computeMatrixFromRootSkeleton","CollectBoneVisitor","_boneMap","getBoneMap","RigTransformHardware","computeBonePalette","boneNameID","boneName","mapVisitor","bm","nbVec4Uniforms","animAttrib","computeMatrixPalette","mTmp","transformFromSkeletonToGeometry","invTransformFromSkeletonToGeometry","matPalette","uniformIndex","invBindMatrix","getMatrixFromSkeletonToGeometry","getInvMatrixFromSkeletonToGeometry","_isAnimatedPath","_matrixFromSkeletonToGeometry","_invMatrixFromSkeletonToGeometry","_needToComputeMatrix","setNeedToComputeMatrix","needToComputeMatrix","weightsArray","sourceGeometryVertexAttributeList","primitiveSetList","vWeights","vBones","id4","palette","m0","m1","m4","m5","m6","m8","m9","m14","m15","doSkin","idBone","riggedVerts","_riggedVerts","idr","_expiryTime","_expiryFrame","_frameNumberOfLastTraversal","_databasePath","_numChildrenThatCannotBeExpired","PerRangeData","function","frameNumberOfLastTraversal","childNo","setExpiryTime","rd","setFunction","setNumChildrenThatCannotBeExpired","getNumChildrenThatCannotBeExpired","timed","framed","updateTimeStamp","needToLoadChild","lastChildTraversed","dbhandler","bbmin","bbmax","tmpMin","tmpMax","inMin","inMax","i4","mini","maxi","cm","outMax","outMin","createRenderLeaf","createCullSettings","_rootStateGraph","_currentRenderStage","_rootRenderStage","POSITIVE_INFINITY","_pooledLeaf","_pooledRenderStages","_pooledCullSettings","_identityMatrix","_renderStageType","ccb","getCurrentCamera","nearVec","farVec","dNear","dFar","rg","setCurrentRenderBin","renderBinStack","currentRenderBin","currentStateGraph","zfar","nearFarRatio","resultNearFar","desiredZnear","desiredZfar","deltaSpan","zfarPushRatio","znearPullRatio","minNearPlane","transNearPlane","transFarPlane","centerRatio","createOrReuseRenderStage","classInstance","classCtor","createRenderStage","postPushGeometry","geometryStateSetAnimation","prePopGeometry","pushLeaf","cameraApply","lastProjectionMatrix","lastViewMatrix","previousZnear","previousZfar","previousCullsettings","previousStage","rtts","matrixTransformApply","lastMatrixStack","projectionApply","nodeApply","lightSourceApply","loggedOnce","geometryApply","checkVariableType","optionalPrefix","varsList","callFunction","funcName","callString","extractPragmaArgs","extractSignature","openParen","closeParen","preSignature","splitPre","firstWord","nameFunc","pragmaArgs","returnName","NODE_NAME","DERIVATIVES","returnVariable","isDefine","postSignature","argumentList","hasOptionalArgs","orderedArgs","argi","cleanArg","splits","isOutput","glslName","optional","NodeCustom","_defines","_missingArgs","signatures","globalDeclare","exts","getExtensions","getOrCreateSignature","_validateSameVariables","glslArray","jsObj","nbGlsl","_validateSameType","jsVar","_getSignatureBestMatch","matchNames","matchOutput","matchInput","nbSignatures","sig","_signature","_typeDownCast","glslArg","jsArg","typeIn","realType","validType","returnOut","shaderNodeClassGlobal","shaderNodeClassLocal","shaderNode","_iThreshold","setEnd","sm","se","div","ResetRestPoseVisitor","resetter","setRestPose","ValidateSkeletonVisitor","foundNonBone","compareBone","_needValidate","needToValidate","validateSkeletonVisitor","_morphs","_weights","_indexMap","_gpuMorphed","funcWeights","_initNode","morphs","nbMorphs","_remapBufferArrays","indexMap","strI","strIndex","vAttrs","morphNames","attName","_mergeExtraMorphTarget","extraWeightSum","gpuMorphed","vAttr","nbVertex","_cpuMorph","morphExtraTargets","_computeExtraWeightsSum","_morphBufferArrayCPU","processed","updateWeights","sortedTargets","ti","extraEpsilon","extraMorphCPU"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B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/FACF,oBACE,ykGACF,uBACE,q9MACF,uBACE,4rCACF,sBACE,utEACF,sBACE,4oCACF,yBACE,qhIACF,yBACE,o7DACF,wBACE,4yBACF,qBACE,4jBACF,kBACE,moEACF,uBACE,06BACF,wBACE,qwLACF,uBACE,8xDACF,iBACE,unWACF,sBACE,y7aACF,wBACE,w/BACF,0BACE,iLACF,yBACE,q4CACF,yBACE,6/BACF,0BACE,mVACF,0BACE,iPACF,YACE,mqUACF,cAAe,yDAGf,WACE,kFACF,WACE,w7iBACF,eAAgB,yDAChB,eACE,gMACF,cACE,kFACF,cACE,ovIACF,iBAAkB,+BAClB,iBACE,mlHACF,iBAAkB,mDAClB,iBACE,wGACF,2BAA4B,gCAC5B,2BACE,siGACF,4BACE,gHACF,4BACE,2kCACF,sBAAuB,gCACvB,sBACE,yiCACF,wBACE,4GACF,wBACE,ilDACF,qBACE,yDACF,qBACE,oOACF,oBACE,0SACF,oBACE,iGACF,qBACE,4SACF,qBACE,iGACF,sBACE,6JACF,sBACE,iGACF,sBAAuB,mDACvB,sBACE,iGACF,qBAAsB,gCACtB,qBACE,2tGACF,4BAA6B,gCAC7B,4BACE,m4BCnHW,GACb,mBACE,qdACF,qBACE,yqBACF,sBACE,0XACF,yBACE,ynBACF,4BACE,0oDACF,iBACE,krEACF,kBACE,q3BACF,eACE,8+HACF,kBACE,s4CACF,uBACE,s3CACF,mBACE,kzCACF,mBACE,qvMACF,gBACE,opDACF,iBACE,wqBACF,cACE,6VACF,qBACE,ovFACF,0BACE,0aACF,uBACE,8kHACF,kBACE,81EACF,oBACE,myBACF,oBACE,gvCACF,2BACE,uZACF,gBACE,07BACF,mBACE,ojDACF,oBACE,08CACF,mBACE,k7CACF,sBACE,ipQACF,oBACE,wXACF,8BACE,4vDACF,YACE,2iPACF,aACE,21BACF,eACE,0tCACF,gBACE,ydACF,kBACE,mwCACF,aACE,sqDACF,cACE,oKACF,cACE,gIACF,eACE,irDACF,yBACE,gI,0PCzEAC,EAAc,SAAdA,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AK8sS,gBAKL,IAHA,IAAI1/E,EAAUptN,KAAKsrS,SACf/0E,EAAYx1N,KAAKyJ,IAAIxK,KAAK+4P,aAAc/4P,KAAK+yK,SAASt2K,QACtDkvS,EAAS3rS,KAAKqrS,QACT9uS,EAAI,EAAGqvS,EAAWD,EAAOlvS,OAAQF,EAAIqvS,IAAYrvS,EAEtD,IADA,IAAIgV,EAAQo6R,EAAOpvS,GAAG48P,mBACb17P,EAAI,EAAGA,EAAI84N,EAAW94N,IAC3B8T,EAAM9T,GAAK2vN,EAAQ3vN,GAI3B,OAAO,KAGf,eACA,eAGWs5K","file":"js/index.bc94f35d.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"index\": 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"//infishwaibao.oss-cn-chengdu.aliyuncs.com/screenshow/\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([0,\"chunk-vendors\"]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport BoundingBox from '../osg/BoundingBox';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport UpdateBone from './UpdateBone';\r\n\r\n/**\r\n * Bone\r\n * @class Bone\r\n */\r\nvar Bone = function(name) {\r\n if (name !== undefined) this.setName(name);\r\n\r\n MatrixTransform.call(this);\r\n this._invBindInSkeletonSpace = mat4.create();\r\n this._boneInSkeletonSpace = mat4.create();\r\n this._boneBoundingBox = new BoundingBox();\r\n};\r\n\r\nutils.createPrototypeNode(\r\n Bone,\r\n utils.objectInherit(MatrixTransform.prototype, {\r\n // consistent color depending of id\r\n // _rand: function ( id ) {\r\n // var x = Math.sin( id * 45.233 ) * 43758.5453;\r\n // return x - Math.floor( x );\r\n // },\r\n // _generateBoneColor: function ( id ) {\r\n // return vec3.fromValues( this._rand( id + 2.16 ), this._rand( id * 57.27 ), this._rand( id * 0.874 ) );\r\n // },\r\n\r\n getOrCreateDebugColor: function() {\r\n // for bone display (debugging, etc)\r\n if (this._boneColor) return this._boneColor;\r\n // this._boneColor = this._generateBoneColor( this.getInstanceID() );\r\n this._boneColor = vec3.fromValues(Math.random(), Math.random(), Math.random());\r\n return this._boneColor;\r\n },\r\n\r\n getBoneBoundingBox: function() {\r\n return this._boneBoundingBox;\r\n },\r\n\r\n setBoneBoundingBox: function(bb) {\r\n this._boneBoundingBox = bb;\r\n },\r\n\r\n getMatrixInSkeletonSpace: function() {\r\n return this._boneInSkeletonSpace;\r\n },\r\n\r\n getInvBindMatrixInSkeletonSpace: function() {\r\n return this._invBindInSkeletonSpace;\r\n },\r\n\r\n setMatrixInSkeletonSpace: function(m) {\r\n mat4.copy(this._boneInSkeletonSpace, m);\r\n },\r\n\r\n setInvBindMatrixInSkeletonSpace: function(m) {\r\n mat4.copy(this._invBindInSkeletonSpace, m);\r\n },\r\n\r\n getBoneParent: function() {\r\n var parents = this.getParents();\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n var typeID = parents[i].getTypeID();\r\n if (typeID === Bone.getTypeID()) {\r\n return parents[i];\r\n }\r\n }\r\n return undefined;\r\n },\r\n\r\n setDefaultUpdateCallback: function(name) {\r\n this.addUpdateCallback(new UpdateBone(name !== undefined ? name : this.getName()));\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'Bone'\r\n);\r\n\r\nexport default Bone;\r\n","var PooledArray = function() {\r\n this._pool = [];\r\n this._length = 0;\r\n};\r\n\r\nPooledArray.prototype = {\r\n clean: function() {\r\n this._length = 0;\r\n this._pool.length = 0;\r\n },\r\n reset: function() {\r\n this._length = 0;\r\n },\r\n getLength: function() {\r\n return this._length;\r\n },\r\n getArray: function() {\r\n return this._pool;\r\n },\r\n back: function() {\r\n return this._pool[this._length - 1];\r\n },\r\n pop: function() {\r\n this._length--;\r\n return this._pool[this._length];\r\n },\r\n push: function(value) {\r\n if (this._length === this._pool.length) {\r\n this._pool.push(value);\r\n } else {\r\n this._pool[this._length] = value;\r\n }\r\n this._length++;\r\n },\r\n forEach: function(func) {\r\n for (var i = 0; i < this._length; i++) func(this._pool[i]);\r\n }\r\n};\r\n\r\nexport default PooledArray;\r\n","import utils from './utils';\r\nimport { mat4 } from './glMatrix';\r\nimport Transform from './Transform';\r\nimport TransformEnums from './transformEnums';\r\n\r\n/**\r\n * MatrixTransform is a Transform Node that can be customized with user matrix\r\n * @class MatrixTransform\r\n */\r\nvar MatrixTransform = function() {\r\n Transform.call(this);\r\n this.matrix = mat4.create();\r\n};\r\n\r\n/** @lends MatrixTransform.prototype */\r\nutils.createPrototypeNode(\r\n MatrixTransform,\r\n utils.objectInherit(Transform.prototype, {\r\n getMatrix: function() {\r\n return this.matrix;\r\n },\r\n\r\n setMatrix: function(m) {\r\n this.matrix = m;\r\n this.dirtyBound();\r\n },\r\n\r\n // local to \"local world\" (not Global World)\r\n computeLocalToWorldMatrix: function(matrix /*, nodeVisitor */ ) {\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.mul(matrix, matrix, this.matrix);\r\n } else {\r\n mat4.copy(matrix, this.matrix);\r\n }\r\n return true;\r\n },\r\n\r\n computeWorldToLocalMatrix: (function() {\r\n var minverse = mat4.create();\r\n return function(matrix /*, nodeVisitor */ ) {\r\n mat4.invert(minverse, this.matrix);\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.mul(matrix, minverse, matrix);\r\n } else {\r\n // absolute\r\n mat4.copy(matrix, minverse);\r\n }\r\n return true;\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'MatrixTransform'\r\n);\r\n\r\nexport default MatrixTransform;","import utils from './utils';\r\nimport Node from './Node';\r\nimport { mat4 } from './glMatrix';\r\n\r\nvar Projection = function() {\r\n Node.call(this);\r\n this.projection = mat4.create();\r\n};\r\n\r\nutils.createPrototypeNode(\r\n Projection,\r\n utils.objectInherit(Node.prototype, {\r\n getProjectionMatrix: function() {\r\n return this.projection;\r\n },\r\n setProjectionMatrix: function(m) {\r\n this.projection = m;\r\n }\r\n }),\r\n 'osg',\r\n 'Projection'\r\n);\r\n\r\nexport default Projection;","import utils from './utils';\r\nimport { vec3 } from './glMatrix';\r\nimport BoundingBox from './BoundingBox';\r\nimport primitiveIndexFunctor from './primitiveIndexFunctor';\r\nimport primitiveSet from './primitiveSet';\r\nimport notify from './notify';\r\n\r\n// **** GENERAL INFO ON KDTREE ****\r\n// A KdTree is a Spatial Partitionning Tree (http://en.wikipedia.org/wiki/Space_partitioning)\r\n// The type of tree is sort of defined by the splitting axis method:\r\n// - Per Axis split (octree/ kdtree)\r\n// - Arbritrary direction split (bsp)\r\n\r\n// The algorithm used for splitting, the name for finding best split is 'Surface Area Heuristic (SAH)'\r\n// Octree divide the space in 8 subspace (one box -> 8 sub boxes)\r\n// whereas kdtree does it by splitting population number in two equal group\r\n\r\n// Kd Tree http://en.wikipedia.org/wiki/K-d_tree\r\n// a given set of points is sorted along one Axis (e.g. X).\r\n// The sorted list is split at the median.\r\n// The result are two sets, one for each half-space (left and right).\r\n\r\n// Then, for the current node, the splitting-plane position (or the median-point) and depth is saved.\r\n// Finally, if the point-set has more than n point and the tree depth is below m\r\n// (with n,m chosen by the user, as build options), two child-nodes (L/R one for each point-set)\r\n// are created which themselfs repeat the pocedure.\r\n\r\n// The split-axis gets alternated at each depth, the split order is computed by checking the main\r\n// bounding box the length of its axis\r\n// **** GENERAL INFO ON KDTREE ****\r\n\r\n// The KdTree implemented here is flattened, ie, a node and its children all lie in the same array\r\n// The most important thing is the understanding of the variables first and second for each node\r\n// Their semantic depend if the node is a leaf or not\r\n// if it's a leaf :\r\n// first and second defines a range in the triangles array (triangles in the cell)\r\n// if it's not a leaf :\r\n// - first and second respectively represents the left and right sub children\r\n// We know that a node is a leaf if first is negative, in that case the range will be defined by\r\n// [ -first - 1, -first-1 + second ]\r\nvar KdNode = function(first, second) {\r\n this._bb = new BoundingBox();\r\n this._first = first;\r\n this._second = second;\r\n // These variables represent the local clipped ray (for intersection test)\r\n // They are mostly temporary because they are recomputed for each intersection test\r\n this._nodeRayStart = vec3.create();\r\n this._nodeRayEnd = vec3.create();\r\n};\r\n\r\nvar InfoCollector = function() {\r\n this._numVertexIndices = 0;\r\n};\r\n\r\nInfoCollector.prototype = {\r\n apply: function(node) {\r\n if (!node.getAttributes().Vertex) return;\r\n primitiveIndexFunctor(node, this);\r\n },\r\n\r\n operatorPoint: function() {\r\n this._numVertexIndices += 2;\r\n },\r\n\r\n operatorLine: function() {\r\n this._numVertexIndices += 3;\r\n },\r\n\r\n operatorTriangle: function() {\r\n this._numVertexIndices += 4;\r\n }\r\n};\r\n\r\nvar PrimitiveIndicesCollector = function(buildKdTree) {\r\n this._buildKdTree = buildKdTree;\r\n this._numIndices = 0;\r\n};\r\n\r\nPrimitiveIndicesCollector.prototype = {\r\n apply: function(node) {\r\n if (!node.getAttributes().Vertex) return;\r\n primitiveIndexFunctor(node, this);\r\n },\r\n\r\n operatorPoint: function(i0) {\r\n var vertices = this._buildKdTree._kdTree.getVertices();\r\n var iv = i0 * 3;\r\n this._buildKdTree._kdTree.addPoint(i0);\r\n this._buildKdTree._primitiveIndices[this._numIndices] = this._numIndices;\r\n var centers = this._buildKdTree._centers;\r\n var idCenter = this._numIndices * 3;\r\n centers[idCenter] = vertices[iv];\r\n centers[idCenter + 1] = vertices[iv + 1];\r\n centers[idCenter + 2] = vertices[iv + 2];\r\n this._numIndices++;\r\n },\r\n\r\n operatorLine: function(i0, i1) {\r\n if (i0 === i1) return;\r\n var vertices = this._buildKdTree._kdTree.getVertices();\r\n var iv0 = i0 * 3;\r\n var iv1 = i1 * 3;\r\n\r\n this._buildKdTree._kdTree.addLine(i0, i1);\r\n\r\n var numIndices = this._numIndices;\r\n this._buildKdTree._primitiveIndices[numIndices] = numIndices;\r\n\r\n var idCenter = numIndices * 3;\r\n\r\n var v0x = vertices[iv0];\r\n var v0y = vertices[iv0 + 1];\r\n var v0z = vertices[iv0 + 2];\r\n\r\n var v1x = vertices[iv1];\r\n var v1y = vertices[iv1 + 1];\r\n var v1z = vertices[iv1 + 2];\r\n\r\n var minx = v0x < v1x ? v0x : v1x;\r\n var miny = v0y < v1y ? v0y : v1y;\r\n var minz = v0z < v1z ? v0z : v1z;\r\n\r\n var maxx = v0x > v1x ? v0x : v1x;\r\n var maxy = v0y > v1y ? v0y : v1y;\r\n var maxz = v0z > v1z ? v0z : v1z;\r\n\r\n var centers = this._buildKdTree._centers;\r\n centers[idCenter] = (minx + maxx) * 0.5;\r\n centers[idCenter + 1] = (miny + maxy) * 0.5;\r\n centers[idCenter + 2] = (minz + maxz) * 0.5;\r\n\r\n this._numIndices++;\r\n },\r\n\r\n operatorTriangle: function(i0, i1, i2) {\r\n if (i0 === i1 || i0 === i2 || i1 === i2) return;\r\n\r\n var vertices = this._buildKdTree._kdTree.getVertices();\r\n var iv0 = i0 * 3;\r\n var iv1 = i1 * 3;\r\n var iv2 = i2 * 3;\r\n\r\n this._buildKdTree._kdTree.addTriangle(i0, i1, i2);\r\n\r\n var numIndices = this._numIndices;\r\n this._buildKdTree._primitiveIndices[numIndices] = numIndices;\r\n\r\n var idCenter = numIndices * 3;\r\n\r\n var v0x = vertices[iv0];\r\n var v0y = vertices[iv0 + 1];\r\n var v0z = vertices[iv0 + 2];\r\n\r\n var v1x = vertices[iv1];\r\n var v1y = vertices[iv1 + 1];\r\n var v1z = vertices[iv1 + 2];\r\n\r\n var v2x = vertices[iv2];\r\n var v2y = vertices[iv2 + 1];\r\n var v2z = vertices[iv2 + 2];\r\n\r\n var minx = v0x < v1x ? (v0x < v2x ? v0x : v2x) : v1x < v2x ? v1x : v2x;\r\n var miny = v0y < v1y ? (v0y < v2y ? v0y : v2y) : v1y < v2y ? v1y : v2y;\r\n var minz = v0z < v1z ? (v0z < v2z ? v0z : v2z) : v1z < v2z ? v1z : v2z;\r\n\r\n var maxx = v0x > v1x ? (v0x > v2x ? v0x : v2x) : v1x > v2x ? v1x : v2x;\r\n var maxy = v0y > v1y ? (v0y > v2y ? v0y : v2y) : v1y > v2y ? v1y : v2y;\r\n var maxz = v0z > v1z ? (v0z > v2z ? v0z : v2z) : v1z > v2z ? v1z : v2z;\r\n\r\n var centers = this._buildKdTree._centers;\r\n centers[idCenter] = (minx + maxx) * 0.5;\r\n centers[idCenter + 1] = (miny + maxy) * 0.5;\r\n centers[idCenter + 2] = (minz + maxz) * 0.5;\r\n\r\n this._numIndices++;\r\n }\r\n};\r\n\r\nvar BuildKdTree = function(kdTree) {\r\n this._kdTree = kdTree;\r\n this._bb = new BoundingBox();\r\n this._primitiveIndices = undefined; // Uint32Array\r\n this._centers = undefined; // Float32Array\r\n this._axisOrder = vec3.create();\r\n this._stackLength = 0;\r\n};\r\n\r\nBuildKdTree.prototype = {\r\n build: function(options, geom) {\r\n var targetTris = options._targetNumTrianglesPerLeaf;\r\n var vertexAttrib = geom.getVertexAttributeList().Vertex;\r\n if (!vertexAttrib) return false;\r\n var vertices = vertexAttrib.getElements();\r\n if (!vertices) return false;\r\n var nbVertices = vertices.length / 3;\r\n if (nbVertices < targetTris) return false;\r\n\r\n this._bb.copy(geom.getBoundingBox());\r\n this._kdTree.setVertices(vertices);\r\n\r\n this.computeDivisions(options);\r\n options._numVerticesProcessed += nbVertices;\r\n\r\n var totalLenArray = 0;\r\n var geomPrimitives = geom.getPrimitiveSetList();\r\n var nbPrimitives = geomPrimitives.length;\r\n\r\n for (var i = 0; i < nbPrimitives; i++) {\r\n var prim = geomPrimitives[i];\r\n var mode = prim.getMode();\r\n if (mode === primitiveSet.TRIANGLE_STRIP || mode === primitiveSet.TRIANGLE_FAN)\r\n totalLenArray += Math.abs(prim.getCount() - 2) * 3;\r\n else totalLenArray += prim.getCount() * 3;\r\n }\r\n\r\n var infoCollector = new InfoCollector(this);\r\n infoCollector.apply(geom);\r\n var vertexIndicesSize = infoCollector._numVertexIndices;\r\n\r\n this._primitiveIndices = new Uint32Array(totalLenArray / 3);\r\n this._centers = new Float32Array(totalLenArray);\r\n\r\n // init kdtree arrays\r\n // Check if we can use Uint16 later\r\n this._kdTree.setPrimitiveIndices(new Uint32Array(totalLenArray));\r\n var vertexIndicesArray =\r\n nbVertices > 65535\r\n ? new Uint32Array(vertexIndicesSize)\r\n : new Uint16Array(vertexIndicesSize);\r\n this._kdTree.setVertexIndices(vertexIndicesArray);\r\n\r\n var pic = new PrimitiveIndicesCollector(this);\r\n pic.apply(geom);\r\n\r\n // Adjust sizes\r\n var kdPrimIndices = this._kdTree\r\n .getPrimitiveIndices()\r\n .slice(0, this._kdTree.getNumPrimitiveIndices());\r\n this._kdTree.setPrimitiveIndices(kdPrimIndices);\r\n var kdVertexIndices = this._kdTree\r\n .getVertexIndices()\r\n .slice(0, this._kdTree.getNumVertexIndices());\r\n this._kdTree.setVertexIndices(kdVertexIndices);\r\n\r\n this._primitiveIndices = this._primitiveIndices.slice(0, pic._numIndices);\r\n this._centers = this._centers.slice(0, pic._numIndices * 3);\r\n\r\n var node = new KdNode(-1, this._primitiveIndices.length);\r\n node._bb.copy(this._bb);\r\n var nodeNum = this._kdTree.addNode(node);\r\n\r\n var bb = new BoundingBox();\r\n bb.copy(this._bb);\r\n this.divide(options, bb, nodeNum, 0);\r\n\r\n var primitiveIndices = this._kdTree.getPrimitiveIndices();\r\n\r\n nbPrimitives = this._primitiveIndices.length;\r\n for (i = 0; i < nbPrimitives; ++i) {\r\n this._primitiveIndices[i] = primitiveIndices[this._primitiveIndices[i]];\r\n }\r\n this._kdTree.setPrimitiveIndices(this._primitiveIndices);\r\n\r\n return this._kdTree.getNodes().length > 0;\r\n },\r\n\r\n computeDivisions: function(options) {\r\n this._stackLength = options._maxNumLevels;\r\n var max = this._bb._max;\r\n var min = this._bb._min;\r\n var dx = max[0] - min[0];\r\n var dy = max[1] - min[1];\r\n var dz = max[2] - min[2];\r\n var axisOrder = this._axisOrder;\r\n\r\n // We set the cutting order (longest edge aabb first)\r\n axisOrder[0] = dx >= dy && dx >= dz ? 0 : dy >= dz ? 1 : 2;\r\n axisOrder[2] = dx < dy && dx < dz ? 0 : dy < dz ? 1 : 2;\r\n var sum = axisOrder[0] + axisOrder[2];\r\n axisOrder[1] = sum === 3 ? 0 : sum === 2 ? 1 : 2;\r\n },\r\n // The core function of the kdtree building\r\n // It checks if the node needs to be subdivided or not\r\n // If it's a leaf, it computes the final bounding box of the node\r\n // and it ends here\r\n // If it's a node, then it puts the splitting axis position on the median population\r\n // On the same time it reorders the triangle index array\r\n divide: function(options, bb, nodeIndex, level) {\r\n var kdTree = this._kdTree;\r\n var primitives = this._primitiveIndices;\r\n var nodes = kdTree.getNodes();\r\n var node = nodes[nodeIndex];\r\n\r\n var first = node._first;\r\n var second = node._second;\r\n\r\n var needToDivide =\r\n level < this._stackLength && first < 0 && second > options._targetNumTrianglesPerLeaf;\r\n var istart = -first - 1;\r\n var iend = istart + second - 1;\r\n\r\n if (!needToDivide) {\r\n if (first < 0) {\r\n // leaf is done, now compute bound on it.\r\n this.computeNodeBox(node, istart, iend);\r\n }\r\n return nodeIndex;\r\n }\r\n\r\n if (first >= 0) return nodeIndex;\r\n // leaf node as first < 0, so look at dividing it.\r\n\r\n var axis = this._axisOrder[level % 3];\r\n var originalMin = bb._min[axis];\r\n var originalMax = bb._max[axis];\r\n\r\n var mid = (originalMin + originalMax) * 0.5;\r\n\r\n var originalLeftChildIndex = 0;\r\n var originalRightChildIndex = 0;\r\n var insitueDivision = false;\r\n\r\n var left = istart;\r\n var right = iend;\r\n\r\n var centers = this._centers;\r\n while (left < right) {\r\n while (left < right && centers[primitives[left] * 3 + axis] <= mid) {\r\n ++left;\r\n }\r\n\r\n while (left < right && centers[primitives[right] * 3 + axis] > mid) {\r\n --right;\r\n }\r\n\r\n if (left < right) {\r\n var tmp = primitives[left];\r\n primitives[left] = primitives[right];\r\n primitives[right] = tmp;\r\n ++left;\r\n --right;\r\n }\r\n }\r\n\r\n if (left === right) {\r\n if (centers[primitives[left] * 3 + axis] <= mid) ++left;\r\n else --right;\r\n }\r\n\r\n if (right - istart <= -1) {\r\n originalLeftChildIndex = 0;\r\n originalRightChildIndex = nodeIndex;\r\n insitueDivision = true;\r\n } else if (iend - left <= -1) {\r\n originalLeftChildIndex = nodeIndex;\r\n originalRightChildIndex = 0;\r\n insitueDivision = true;\r\n } else {\r\n originalLeftChildIndex = kdTree.addNode(new KdNode(-istart - 1, right - istart + 1));\r\n originalRightChildIndex = kdTree.addNode(new KdNode(-left - 1, iend - left + 1));\r\n }\r\n\r\n var restore = bb._max[axis];\r\n bb._max[axis] = mid;\r\n\r\n var leftChildIndex =\r\n originalLeftChildIndex !== 0\r\n ? this.divide(options, bb, originalLeftChildIndex, level + 1)\r\n : 0;\r\n\r\n bb._max[axis] = restore;\r\n\r\n restore = bb._min[axis];\r\n bb._min[axis] = mid;\r\n\r\n var rightChildIndex =\r\n originalRightChildIndex !== 0\r\n ? this.divide(options, bb, originalRightChildIndex, level + 1)\r\n : 0;\r\n\r\n bb._min[axis] = restore;\r\n\r\n if (!insitueDivision) {\r\n node._first = leftChildIndex;\r\n node._second = rightChildIndex;\r\n\r\n insitueDivision = true;\r\n\r\n var bnode = node._bb;\r\n bnode.init();\r\n if (leftChildIndex !== 0) bnode.expandByBoundingBox(nodes[leftChildIndex]._bb);\r\n if (rightChildIndex !== 0) bnode.expandByBoundingBox(nodes[rightChildIndex]._bb);\r\n }\r\n return nodeIndex;\r\n },\r\n // It computes the bounding box of the node so that the box contains all the triangles\r\n // of the cell\r\n computeNodeBox: function(node, istart, iend) {\r\n var minx = Infinity,\r\n miny = Infinity,\r\n minz = Infinity,\r\n maxx = -Infinity,\r\n maxy = -Infinity,\r\n maxz = -Infinity;\r\n var vertexIndices = this._kdTree.getVertexIndices();\r\n var primitives = this._kdTree.getPrimitiveIndices();\r\n var vertices = this._kdTree.getVertices();\r\n for (var i = istart; i <= iend; ++i) {\r\n var primitiveIndex = primitives[this._primitiveIndices[i]];\r\n var numPoints = vertexIndices[primitiveIndex++];\r\n for (var j = 0; j < numPoints; ++j) {\r\n var vi = vertexIndices[primitiveIndex++] * 3;\r\n var vx = vertices[vi];\r\n var vy = vertices[vi + 1];\r\n var vz = vertices[vi + 2];\r\n\r\n if (vx < minx) minx = vx;\r\n if (vy < miny) miny = vy;\r\n if (vz < minz) minz = vz;\r\n\r\n if (vx > maxx) maxx = vx;\r\n if (vy > maxy) maxy = vy;\r\n if (vz > maxz) maxz = vz;\r\n }\r\n }\r\n var epsilon = 1e-6;\r\n var bnode = node._bb;\r\n var bmin = bnode._min;\r\n var bmax = bnode._max;\r\n bmin[0] = minx - epsilon;\r\n bmin[1] = miny - epsilon;\r\n bmin[2] = minz - epsilon;\r\n bmax[0] = maxx + epsilon;\r\n bmax[1] = maxy + epsilon;\r\n bmax[2] = maxz + epsilon;\r\n }\r\n};\r\n\r\nvar KdTree = function() {\r\n this._vertices = null;\r\n this._kdNodes = [];\r\n this._primitiveIndices = undefined;\r\n this._vertexIndices = undefined;\r\n this._numVertexIndices = 0;\r\n this._numPrimitiveIndices = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n KdTree,\r\n {\r\n getVertices: function() {\r\n return this._vertices;\r\n },\r\n setVertices: function(vertices) {\r\n this._vertices = vertices;\r\n },\r\n\r\n getNumPrimitiveIndices: function() {\r\n return this._numPrimitiveIndices;\r\n },\r\n\r\n getNumVertexIndices: function() {\r\n return this._numVertexIndices;\r\n },\r\n\r\n setPrimitiveIndices: function(indices) {\r\n this._primitiveIndices = indices;\r\n },\r\n getPrimitiveIndices: function() {\r\n return this._primitiveIndices;\r\n },\r\n\r\n // vector containing the primitive vertex index data packed as no_vertice_indices then vertex indices\r\n // ie. for points it's (1, p0), for lines (2, p0, p1) etc.\r\n setVertexIndices: function(indices) {\r\n this._vertexIndices = indices;\r\n },\r\n\r\n getVertexIndices: function() {\r\n return this._vertexIndices;\r\n },\r\n\r\n getNodes: function() {\r\n return this._kdNodes;\r\n },\r\n\r\n addPoint: function(p0) {\r\n var i = this._numVertexIndices;\r\n this._primitiveIndices[this._numPrimitiveIndices++] = i;\r\n this._vertexIndices[this._numVertexIndices++] = 1;\r\n this._vertexIndices[this._numVertexIndices++] = p0;\r\n },\r\n\r\n addLine: function(p0, p1) {\r\n var i = this._numVertexIndices;\r\n this._primitiveIndices[this._numPrimitiveIndices++] = i;\r\n this._vertexIndices[this._numVertexIndices++] = 2;\r\n this._vertexIndices[this._numVertexIndices++] = p0;\r\n this._vertexIndices[this._numVertexIndices++] = p1;\r\n },\r\n\r\n addTriangle: function(p0, p1, p2) {\r\n var i = this._numVertexIndices;\r\n this._primitiveIndices[this._numPrimitiveIndices++] = i;\r\n this._vertexIndices[this._numVertexIndices++] = 3;\r\n this._vertexIndices[this._numVertexIndices++] = p0;\r\n this._vertexIndices[this._numVertexIndices++] = p1;\r\n this._vertexIndices[this._numVertexIndices++] = p2;\r\n },\r\n\r\n addNode: function(node) {\r\n this._kdNodes.push(node);\r\n return this._kdNodes.length - 1;\r\n },\r\n build: function(options, geom) {\r\n var buildTree = new BuildKdTree(this);\r\n return buildTree.build(options, geom);\r\n },\r\n\r\n _intersectFunctor: function(functor, node) {\r\n // treat as a leaf\r\n var istart = -node._first - 1;\r\n var iend = istart + node._second;\r\n var vIds = this._vertexIndices;\r\n\r\n functor.setVertices(this._vertices);\r\n functor.setPrimitiveIndex(istart);\r\n\r\n for (var i = istart; i < iend; ++i) {\r\n var pIndex = this._primitiveIndices[i];\r\n var numVertices = vIds[pIndex++];\r\n\r\n if (numVertices === 3) {\r\n functor.operatorTriangle(vIds[pIndex], vIds[pIndex + 1], vIds[pIndex + 2]);\r\n } else if (numVertices === 2) {\r\n functor.operatorLine(vIds[pIndex], vIds[pIndex + 1]);\r\n } else if (numVertices === 1) {\r\n functor.operatorPoint(vIds[pIndex]);\r\n } else {\r\n notify.error('KdTree::intersect() unsupported vertices count :' + numVertices);\r\n }\r\n }\r\n },\r\n\r\n intersect: function(functor, node) {\r\n if (node._first < 0) {\r\n this._intersectFunctor(functor, node);\r\n return;\r\n }\r\n\r\n if (functor.enter(node._bb)) {\r\n if (node._first > 0) {\r\n this.intersect(functor, this._kdNodes[node._first]);\r\n }\r\n\r\n if (node._second > 0) {\r\n this.intersect(functor, this._kdNodes[node._second]);\r\n }\r\n functor.leave();\r\n }\r\n },\r\n intersectLineSegment: function(functor, node, ls, le) {\r\n if (node._first < 0) {\r\n this._intersectFunctor(functor, node);\r\n return;\r\n }\r\n\r\n var s = node._nodeRayStart;\r\n var e = node._nodeRayEnd;\r\n vec3.copy(s, ls);\r\n vec3.copy(e, le);\r\n var kNodes = this._kdNodes;\r\n var kNode;\r\n if (node._first > 0) {\r\n kNode = kNodes[node._first];\r\n if (functor.enter(kNode._bb, s, e)) this.intersectLineSegment(functor, kNode, s, e);\r\n }\r\n\r\n if (node._second > 0) {\r\n vec3.copy(s, ls);\r\n vec3.copy(e, le);\r\n kNode = kNodes[node._second];\r\n if (functor.enter(kNode._bb, s, e)) this.intersectLineSegment(functor, kNode, s, e);\r\n }\r\n }\r\n },\r\n 'osg',\r\n 'KdTree'\r\n);\r\n\r\nexport default KdTree;\r\n","import utils from '../osg/utils';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport Uniform from '../osg/Uniform';\r\n\r\n/**\r\n * MorphAttribute encapsulate Animation State\r\n * @class MorphAttribute\r\n * @inherits StateAttribute\r\n */\r\nvar MorphAttribute = function(nbTarget, disable) {\r\n StateAttribute.call(this);\r\n this._nbTarget = nbTarget;\r\n this._enable = !disable;\r\n\r\n this._targetNames = {};\r\n this._hashNames = ''; // compute only once target hash names\r\n\r\n this._hash = ''; // cache of hash\r\n this._dirtyHash = true;\r\n};\r\n\r\nMorphAttribute.uniforms = {};\r\n\r\nutils.createPrototypeStateAttribute(\r\n MorphAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Morph',\r\n\r\n cloneType: function() {\r\n return new MorphAttribute(undefined, true);\r\n },\r\n\r\n hasTarget: function(name) {\r\n return !!this._targetNames[name];\r\n },\r\n\r\n copyTargetNames: function(names) {\r\n var tNames = this._targetNames;\r\n var hash = '';\r\n var nbNames = (tNames.length = names.length);\r\n\r\n for (var i = 0; i < nbNames; ++i) {\r\n var att = names[i];\r\n tNames[att] = true;\r\n hash += att;\r\n }\r\n\r\n this._hashNames = hash;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getOrCreateUniforms: function() {\r\n var obj = MorphAttribute;\r\n var unifHash = this.getNumTargets();\r\n\r\n if (obj.uniforms[unifHash]) return obj.uniforms[unifHash];\r\n\r\n obj.uniforms[unifHash] = {\r\n uTargetWeights: Uniform.createFloat4('uTargetWeights')\r\n };\r\n\r\n return obj.uniforms[unifHash];\r\n },\r\n\r\n setNumTargets: function(nb) {\r\n this._nbTarget = nb;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getNumTargets: function() {\r\n return this._nbTarget;\r\n },\r\n\r\n setTargetWeights: function(targetWeight) {\r\n this._targetWeights = targetWeight;\r\n },\r\n\r\n getTargetWeights: function() {\r\n return this._targetWeights;\r\n },\r\n\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n return this.getTypeMember() + this._hashNames + this.getNumTargets() + this.isEnabled();\r\n },\r\n\r\n apply: function() {\r\n if (!this._enable) return;\r\n\r\n var uniformMap = this.getOrCreateUniforms();\r\n uniformMap.uTargetWeights.setFloat4(this._targetWeights);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'MorphAttribute'\r\n);\r\n\r\nexport default MorphAttribute;\r\n","import notify from './notify';\r\nimport utils from './utils';\r\nimport Object from './Object';\r\nimport GLObject from './GLObject';\r\nimport Timer from './Timer';\r\n\r\nvar getAttributeType = function(array) {\r\n var type;\r\n\r\n if (array instanceof utils.Float32Array) type = 0x1406;\r\n\r\n if (array instanceof utils.Int16Array) type = 0x1402;\r\n if (array instanceof utils.Uint16Array) type = 0x1403;\r\n\r\n if (array instanceof utils.Int8Array) type = 0x1400;\r\n if (array instanceof utils.Uint8Array) type = 0x1401;\r\n if (array instanceof utils.Uint8ClampedArray) type = 0x1401;\r\n\r\n if (array instanceof utils.Int32Array) type = 0x1404; // webgl2 for vertexAttribPointer\r\n if (array instanceof utils.Uint32Array) type = 0x1405; // webgl2 for vertexAttribPointer\r\n\r\n return type;\r\n};\r\n\r\n/**\r\n * BufferArray manage vertex / normal / ... array used by webgl.\r\n * osgjs automatically converts array buffers to Float32Array and\r\n * element array buffers to Uint16Array if not said explicitly with\r\n * preserveArrayType variable in constructor.\r\n * @class BufferArray\r\n */\r\n\r\nvar BufferArray = function(target, elements, itemSize) {\r\n GLObject.call(this);\r\n // maybe could inherit from Object\r\n this._instanceID = Object.getInstanceID();\r\n\r\n this.dirty();\r\n\r\n this._itemSize = itemSize;\r\n this._target = typeof target === 'string' ? BufferArray[target] : target;\r\n\r\n // initialized by setElements\r\n this._type = undefined;\r\n this._normalize = false;\r\n\r\n if (elements) {\r\n // byteLength should be enough to detect typedArray\r\n if (elements.byteLength === undefined) {\r\n notify.warn('BufferArray with non typedArray elements is deprecated');\r\n if (this._target === BufferArray.ELEMENT_ARRAY_BUFFER) {\r\n elements = new utils.Uint16Array(elements);\r\n } else {\r\n elements = new utils.Float32Array(elements);\r\n }\r\n }\r\n this.setElements(elements);\r\n }\r\n\r\n this._usage = BufferArray.STATIC_DRAW;\r\n};\r\n\r\nBufferArray.ELEMENT_ARRAY_BUFFER = 0x8893;\r\nBufferArray.ARRAY_BUFFER = 0x8892;\r\nBufferArray.STATIC_DRAW = 0x88e4;\r\nBufferArray.DYNAMIC_DRAW = 0x88e8;\r\nBufferArray.STREAM_DRAW = 0x88e0;\r\n\r\n// static cache of glBuffers flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nBufferArray._sDeletedGLBufferArrayCache = new window.Map();\r\n\r\n// static method to delete Program\r\nBufferArray.deleteGLBufferArray = function(gl, buffer) {\r\n if (!BufferArray._sDeletedGLBufferArrayCache.has(gl))\r\n BufferArray._sDeletedGLBufferArrayCache.set(gl, []);\r\n BufferArray._sDeletedGLBufferArrayCache.get(gl).push(buffer);\r\n};\r\n\r\n// static method to flush all the cached glPrograms which need to be deleted in the GL context specified\r\nBufferArray.flushDeletedGLBufferArrays = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n if (!BufferArray._sDeletedGLBufferArrayCache.has(gl)) return availableTime;\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var deleteList = BufferArray._sDeletedGLBufferArrayCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteBuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nBufferArray.flushAllDeletedGLBufferArrays = function(gl) {\r\n if (!BufferArray._sDeletedGLBufferArrayCache.has(gl)) return;\r\n var deleteList = BufferArray._sDeletedGLBufferArrayCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0; i--) {\r\n gl.deleteBuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n};\r\n\r\nBufferArray.onLostContext = function(gl) {\r\n if (!BufferArray._sDeletedGLBufferArrayCache.has(gl)) return;\r\n var deleteList = BufferArray._sDeletedGLBufferArrayCache.get(gl);\r\n deleteList.length = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n BufferArray,\r\n utils.objectInherit(GLObject.prototype, {\r\n setUsage: function(usage) {\r\n this._usage = usage;\r\n },\r\n getUsage: function() {\r\n return this._usage;\r\n },\r\n getInstanceID: function() {\r\n return this._instanceID;\r\n },\r\n setItemSize: function(size) {\r\n this._itemSize = size;\r\n },\r\n isValid: function() {\r\n if (this._buffer) return true;\r\n if (this._elements && this._elements.length) return true;\r\n return false;\r\n },\r\n\r\n invalidate: function() {\r\n this._buffer = undefined;\r\n this.dirty();\r\n },\r\n\r\n releaseGLObjects: function() {\r\n if (this._buffer !== undefined && this._buffer !== null && this._gl !== undefined) {\r\n BufferArray.deleteGLBufferArray(this._gl, this._buffer);\r\n GLObject.removeObject(this._gl, this);\r\n }\r\n this.invalidate();\r\n },\r\n\r\n setNormalize: function(normalize) {\r\n this._normalize = normalize;\r\n },\r\n\r\n getNormalize: function() {\r\n return this._normalize;\r\n },\r\n\r\n bind: function(gl) {\r\n if (!this._gl) this.setGraphicContext(gl);\r\n var target = this._target;\r\n var buffer = this._buffer;\r\n\r\n if (buffer) {\r\n gl.bindBuffer(target, buffer);\r\n return;\r\n }\r\n\r\n if (!buffer && this._elements.length > 0) {\r\n this._buffer = gl.createBuffer();\r\n this._numItems = this._elements.length / this._itemSize;\r\n gl.bindBuffer(target, this._buffer);\r\n }\r\n },\r\n getItemSize: function() {\r\n return this._itemSize;\r\n },\r\n dirty: function() {\r\n this._dirty = true;\r\n },\r\n isDirty: function() {\r\n return this._dirty;\r\n },\r\n compile: function(gl) {\r\n if (this._dirty) {\r\n gl.bufferData(this._target, this._elements, this._usage);\r\n this._dirty = false;\r\n }\r\n },\r\n getElements: function() {\r\n return this._elements;\r\n },\r\n setElements: function(elements) {\r\n this._elements = elements;\r\n this._type = getAttributeType(elements);\r\n this._dirty = true;\r\n },\r\n getType: function() {\r\n return this._type;\r\n }\r\n }),\r\n 'osg',\r\n 'BufferArray'\r\n);\r\n\r\nexport default BufferArray;","var defaultOptions = {\r\n // prefix to built url to load resource\r\n prefixURL: '',\r\n\r\n // database URL for PagedLOD structures\r\n databasePath: '',\r\n\r\n // callback used when loading data\r\n progressXHRCallback: undefined,\r\n\r\n // replacement of readImageURL to use your own code to load Nodes\r\n // the function will be execute in the context of Input, see Input:readNodeURL\r\n readNodeURL: undefined,\r\n\r\n // replacement of readImageURL to use your own code to load osg.Image\r\n // the function will be execute in the context of Input, see Input:readImageURL\r\n readImageURL: undefined,\r\n\r\n // replacement of readBinaryArrayURL to use your own code to load binary array\r\n // the function will be execute in the context of Input, see Input:readBinaryArrayURL\r\n readBinaryArrayURL: undefined,\r\n\r\n imageLoadingUsePromise: true, // use promise to load image instead of returning Image\r\n imageOnload: undefined, // use callback when loading an image\r\n imageCrossOrigin: undefined // use callback when loading an image\r\n};\r\n\r\nexport default defaultOptions;\r\n","import P from 'bluebird';\r\nimport utils from '../osg/utils';\r\nimport osg from '../osg/osg';\r\nimport fileHelper from './fileHelper';\r\nimport Options from './options';\r\nimport zlib from './zlib';\r\nimport notify from '../osg/notify';\r\nimport Image from '../osg/Image';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport DrawArrayLengths from '../osg/DrawArrayLengths';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport primitiveSet from '../osg/primitiveSet';\r\n\r\nvar rejectObject = utils.rejectObject;\r\n\r\nconst Input = function(json, identifier) {\r\n this._json = json;\r\n var map = identifier;\r\n if (map === undefined) {\r\n map = {};\r\n }\r\n this._identifierMap = map;\r\n this._objectRegistry = {};\r\n\r\n this._cacheReadObject = {}; //wrappers\r\n\r\n // this._progressXHRCallback = undefined;\r\n // this._prefixURL = '';\r\n // this.setImageLoadingOptions( {\r\n // promise: true,\r\n // onload: undefined\r\n // } );\r\n\r\n this.setOptions(utils.objectMix({}, Options));\r\n\r\n // {\r\n // prefixURL: '',\r\n // progressXHRCallback: undefined,\r\n // readImageURL: undefined,\r\n // imageLoadingUsePromise: undefined,\r\n // imageOnload: undefined,\r\n // };\r\n};\r\n\r\n// keep one instance of image fallback\r\nif (!Input.imageFallback) {\r\n Input.imageFallback = (function() {\r\n var fallback = new window.Image();\r\n fallback.src =\r\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=';\r\n return fallback;\r\n })();\r\n}\r\n\r\nInput.prototype = {\r\n clone: function() {\r\n var input = new Input();\r\n input._objectRegistry = this._objectRegistry;\r\n input._cacheReadObject = this._cacheReadObject;\r\n return input;\r\n },\r\n\r\n setOptions: function(options) {\r\n this._defaultOptions = options;\r\n },\r\n getOptions: function() {\r\n return this._defaultOptions;\r\n },\r\n setProgressXHRCallback: function(func) {\r\n this._defaultOptions.progressXHRCallback = func;\r\n },\r\n setReadNodeURLCallback: function(func) {\r\n this._defaultOptions.readNodeURL = func;\r\n },\r\n // used to override the type from pathname\r\n // typically if you want to create proxy object\r\n registerObject: function(fullyQualifiedObjectname, constructor) {\r\n this._objectRegistry[fullyQualifiedObjectname] = constructor;\r\n },\r\n\r\n getJSON: function() {\r\n return this._json;\r\n },\r\n\r\n setJSON: function(json) {\r\n this._json = json;\r\n return this;\r\n },\r\n\r\n setPrefixURL: function(prefix) {\r\n this._defaultOptions.prefixURL = prefix;\r\n },\r\n\r\n getPrefixURL: function() {\r\n return this._defaultOptions.prefixURL;\r\n },\r\n\r\n setDatabasePath: function(path) {\r\n this._defaultOptions.databasePath = path;\r\n },\r\n\r\n getDatabasePath: function() {\r\n return this._defaultOptions.databasePath;\r\n },\r\n\r\n computeURL: function(url) {\r\n if (\r\n typeof this._defaultOptions.prefixURL === 'string' &&\r\n this._defaultOptions.prefixURL.length > 0\r\n ) {\r\n return this._defaultOptions.prefixURL + url;\r\n }\r\n\r\n return url;\r\n },\r\n\r\n requestFile: function(url, options) {\r\n return fileHelper.requestURI(url, options);\r\n },\r\n\r\n getObjectWrapper: function(path) {\r\n if (this._objectRegistry[path]) {\r\n return new this._objectRegistry[path]();\r\n }\r\n\r\n var scope = { osg };\r\n var splittedPath = path.split('.');\r\n for (var i = 0, l = splittedPath.length; i < l; i++) {\r\n var obj = scope[splittedPath[i]];\r\n if (obj === undefined) {\r\n return undefined;\r\n }\r\n scope = obj;\r\n }\r\n this._objectRegistry[path] = scope;\r\n // create the new obj\r\n return new scope();\r\n },\r\n\r\n fetchImage: function(image, url, options) {\r\n var checkInlineImage = 'data:image/';\r\n // crossOrigin does not work for inline data image\r\n var isInlineImage = url.substring(0, checkInlineImage.length) === checkInlineImage;\r\n var img = new window.Image();\r\n if (!isInlineImage && options.imageCrossOrigin) {\r\n img.crossOrigin = options.imageCrossOrigin;\r\n }\r\n image.setURL(url);\r\n image.setImage(img);\r\n img.src = url;\r\n\r\n return new P(function(resolve) {\r\n img.onerror = function() {\r\n notify.warn('warning use white texture as fallback instead of ' + url);\r\n image.setImage(Input.imageFallback);\r\n resolve(image);\r\n };\r\n\r\n img.onload = function() {\r\n if (options.imageOnload) options.imageOnload.call(image);\r\n resolve(image);\r\n };\r\n });\r\n },\r\n\r\n readImageURL: function(url, options) {\r\n if (options === undefined) {\r\n options = this._defaultOptions;\r\n }\r\n\r\n // hook reader\r\n if (options.readImageURL) {\r\n // be carefull if you plan to call hook the call and after\r\n // call the original readImageURL, you will need to remove\r\n // from options the readImageURL if you dont want an infinte\r\n // recursion call\r\n return options.readImageURL.call(this, url, options);\r\n }\r\n\r\n // if image is on inline image skip url computation\r\n if (url.substr(0, 10) !== 'data:image') {\r\n url = this.computeURL(url);\r\n }\r\n\r\n var image = new Image();\r\n return this.fetchImage(image, url, options);\r\n },\r\n\r\n readNodeURL: function(url, opt) {\r\n var options = opt;\r\n if (options === undefined) {\r\n options = this._defaultOptions;\r\n }\r\n\r\n // hook reader\r\n if (options.readNodeURL) {\r\n // be carefull if you plan to call hook the call and after\r\n // call the original readNodeURL, you will need to remove\r\n // from options the readNodeURL if you dont want an infinte\r\n // recursion call\r\n return options.readNodeURL.call(this, url, options);\r\n }\r\n\r\n url = this.computeURL(url);\r\n var that = this;\r\n // copy because we are going to modify it to have relative prefix to load assets\r\n options = utils.objectMix({}, options);\r\n\r\n // automatic prefix if non specfied\r\n if (!options.prefixURL) {\r\n var prefix = that.getPrefixURL();\r\n var index = url.lastIndexOf('/');\r\n if (index !== -1) {\r\n prefix = url.substring(0, index + 1);\r\n }\r\n options.prefixURL = prefix;\r\n }\r\n\r\n var ReaderParser = require('./readerParser').default;\r\n\r\n var readSceneGraph = function(data) {\r\n return ReaderParser.parseSceneGraph(data, options).then(function(child) {\r\n notify.log('loaded ' + url);\r\n return child;\r\n });\r\n };\r\n\r\n var ungzipFile = function(arrayBuffer) {\r\n function pad(n) {\r\n return n.length < 2 ? '0' + n : n;\r\n }\r\n\r\n function uintToString(uintArray) {\r\n var str = '';\r\n for (var i = 0, len = uintArray.length; i < len; ++i) {\r\n str += '%' + pad(uintArray[i].toString(16));\r\n }\r\n str = decodeURIComponent(str);\r\n return str;\r\n }\r\n\r\n var unpacked = arrayBuffer;\r\n if (zlib.isGunzipBuffer(arrayBuffer)) {\r\n unpacked = zlib.gunzip(arrayBuffer);\r\n }\r\n\r\n var typedArray = new Uint8Array(unpacked);\r\n var str = uintToString(typedArray);\r\n return str;\r\n };\r\n\r\n utils.time('osgjs.metric:Input.readNodeURL', notify.INFO);\r\n // try to get the file as responseText to parse JSON\r\n var fileTextPromise = that.requestFile(url);\r\n return fileTextPromise\r\n .then(function(str) {\r\n var data;\r\n try {\r\n data = JSON.parse(str);\r\n } catch (error) {\r\n // can't parse try with ungzip code path\r\n\r\n notify.error('cant parse url ' + url + ' try to gunzip');\r\n }\r\n // we have the json, read it\r\n if (data) return readSceneGraph(data);\r\n\r\n // no data try with gunzip\r\n var fileGzipPromise = that.requestFile(url, {\r\n responseType: 'arraybuffer'\r\n });\r\n return fileGzipPromise\r\n .then(function(file) {\r\n var strUnzip = ungzipFile(file);\r\n data = JSON.parse(strUnzip);\r\n return readSceneGraph(data);\r\n })\r\n .catch(function(status) {\r\n var err = 'cant read file ' + url + ' status ' + status;\r\n notify.error(err);\r\n return err;\r\n });\r\n })\r\n .catch(function(status) {\r\n var err = 'cant get file ' + url + ' status ' + status;\r\n notify.error(err);\r\n return err;\r\n })\r\n .finally(function() {\r\n // Stop the timer\r\n utils.timeEnd('osgjs.metric:Input.readNodeURL');\r\n });\r\n },\r\n\r\n _unzipTypedArray: function(binary) {\r\n var typedArray = new Uint8Array(binary);\r\n\r\n // check magic number 1f8b\r\n if (typedArray[0] === 0x1f && typedArray[1] === 0x8b) {\r\n var _zlib = require('zlibjs');\r\n\r\n if (!_zlib) {\r\n notify.error(\r\n 'osg failed to use a gunzip.min.js to uncompress a gz file.\\n You can add this vendors to enable this feature or adds the good header in your gzip file served by your server'\r\n );\r\n }\r\n\r\n var zdec = new _zlib.Gunzip(typedArray);\r\n var result = zdec.decompress();\r\n return result.buffer;\r\n }\r\n\r\n return binary;\r\n },\r\n\r\n readBinaryArrayURL: function(url, options) {\r\n if (options === undefined) {\r\n options = this._defaultOptions;\r\n }\r\n\r\n if (options.readBinaryArrayURL) {\r\n return options.readBinaryArrayURL.call(this, url, options);\r\n }\r\n\r\n url = this.computeURL(url);\r\n\r\n if (this._identifierMap[url] !== undefined) {\r\n return this._identifierMap[url];\r\n }\r\n\r\n var filePromise = this.requestFile(url, {\r\n responseType: 'arraybuffer',\r\n progress: this._defaultOptions.progressXHRCallback\r\n });\r\n\r\n var that = this;\r\n this._identifierMap[url] = filePromise.then(function(file) {\r\n return that._unzipTypedArray(file);\r\n });\r\n\r\n return this._identifierMap[url];\r\n },\r\n\r\n initializeBufferArray: function(vb, type, buf, options) {\r\n if (options === undefined) options = this.getOptions();\r\n\r\n if (options.initializeBufferArray) {\r\n return options.initializeBufferArray.call(this, vb, type, buf);\r\n }\r\n\r\n var url = vb.File;\r\n\r\n return this.readBinaryArrayURL(url).then(function(array) {\r\n var typedArray;\r\n // manage endianness\r\n var bigEndian;\r\n (function() {\r\n var a = new Uint8Array([0x12, 0x34]);\r\n var b = new Uint16Array(a.buffer);\r\n bigEndian = b[0].toString(16) === '1234';\r\n })();\r\n\r\n var offset = 0;\r\n if (vb.Offset !== undefined) {\r\n offset = vb.Offset;\r\n }\r\n\r\n var bytesPerElement = utils[type].BYTES_PER_ELEMENT;\r\n var nbItems = vb.Size;\r\n var nbCoords = buf.getItemSize();\r\n var totalSizeInBytes = nbItems * bytesPerElement * nbCoords;\r\n\r\n if (bigEndian) {\r\n notify.log('big endian detected');\r\n var TypedArray = utils[type];\r\n var tmpArray = new TypedArray(nbItems * nbCoords);\r\n var data = new DataView(array, offset, totalSizeInBytes);\r\n var i = 0,\r\n l = tmpArray.length;\r\n if (type === 'Uint16Array') {\r\n for (; i < l; i++) {\r\n tmpArray[i] = data.getUint16(i * bytesPerElement, true);\r\n }\r\n } else if (type === 'Float32Array') {\r\n for (; i < l; i++) {\r\n tmpArray[i] = data.getFloat32(i * bytesPerElement, true);\r\n }\r\n } else if (type === 'Uint32Array') {\r\n for (; i < l; i++) {\r\n tmpArray[i] = data.getUint32(i * bytesPerElement, true);\r\n }\r\n }\r\n typedArray = tmpArray;\r\n data = null;\r\n } else {\r\n typedArray = new utils[type](array, offset, nbCoords * nbItems);\r\n }\r\n\r\n buf.setElements(typedArray);\r\n return buf;\r\n });\r\n },\r\n\r\n readBufferArray: function(options) {\r\n var jsonObj = this.getJSON();\r\n\r\n var uniqueID = jsonObj.UniqueID;\r\n var osgjsObject;\r\n if (uniqueID !== undefined) {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject;\r\n }\r\n }\r\n\r\n if (options === undefined) options = this.getOptions();\r\n if (options.readBufferArray) return options.readBufferArray.call(this);\r\n\r\n if ((!jsonObj.Elements && !jsonObj.Array) || !jsonObj.ItemSize || !jsonObj.Type) {\r\n return rejectObject('BufferArray', jsonObj);\r\n }\r\n\r\n var promise;\r\n\r\n // inline array\r\n if (jsonObj.Elements) {\r\n promise = P.resolve(\r\n new BufferArray(BufferArray[jsonObj.Type], jsonObj.Elements, jsonObj.ItemSize)\r\n );\r\n } else if (jsonObj.Array) {\r\n var buf = new BufferArray(BufferArray[jsonObj.Type]);\r\n buf.setItemSize(jsonObj.ItemSize);\r\n\r\n var vb, type;\r\n if (jsonObj.Array.Float32Array) {\r\n vb = jsonObj.Array.Float32Array;\r\n type = 'Float32Array';\r\n } else if (jsonObj.Array.Uint16Array) {\r\n vb = jsonObj.Array.Uint16Array;\r\n type = 'Uint16Array';\r\n } else if (jsonObj.Array.Uint8Array) {\r\n vb = jsonObj.Array.Uint8Array;\r\n type = 'Uint8Array';\r\n }else if (jsonObj.Array.Uint32Array) {\r\n vb = jsonObj.Array.Uint32Array;\r\n type = 'Uint32Array';\r\n }\r\n\r\n if (vb === undefined) {\r\n return rejectObject('Typed Array ' + window.Object.keys(jsonObj.Array)[0]);\r\n }\r\n\r\n if (vb.File) {\r\n promise = this.initializeBufferArray(vb, type, buf);\r\n } else if (vb.Elements) {\r\n buf.setElements(new utils[type](vb.Elements));\r\n promise = P.resolve(buf);\r\n }\r\n }\r\n\r\n if (uniqueID !== undefined) {\r\n this._identifierMap[uniqueID] = promise;\r\n }\r\n return promise;\r\n },\r\n\r\n readUserDataContainer: function() {\r\n var jsonObj = this.getJSON();\r\n var osgjsObject;\r\n var uniqueID = jsonObj.UniqueID;\r\n if (uniqueID !== undefined) {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject.Values;\r\n }\r\n }\r\n\r\n this._identifierMap[uniqueID] = jsonObj;\r\n return jsonObj.Values;\r\n },\r\n\r\n readPrimitiveSet: function() {\r\n var jsonObj = this.getJSON();\r\n var uniqueID;\r\n var osgjsObject;\r\n\r\n var promise;\r\n var obj, mode, first, count;\r\n var drawElements =\r\n jsonObj.DrawElementUShort ||\r\n jsonObj.DrawElementUByte ||\r\n jsonObj.DrawElementUInt ||\r\n jsonObj.DrawElementsUShort ||\r\n jsonObj.DrawElementsUByte ||\r\n jsonObj.DrawElementsUInt;\r\n var drawArray = jsonObj.DrawArray || jsonObj.DrawArrays;\r\n var drawArrayLengths = jsonObj.DrawArrayLengths;\r\n\r\n if (drawElements) {\r\n uniqueID = drawElements.UniqueID;\r\n if (uniqueID !== undefined) {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject;\r\n }\r\n }\r\n\r\n mode = drawElements.Mode ? primitiveSet[drawElements.Mode] : primitiveSet.TRIANGLES;\r\n obj = new DrawElements(mode);\r\n\r\n this.setJSON(drawElements.Indices);\r\n promise = this.readBufferArray().then(function(array) {\r\n obj.setIndices(array);\r\n return obj;\r\n });\r\n this.setJSON(jsonObj);\r\n } else if (drawArray) {\r\n uniqueID = drawArray.UniqueID;\r\n if (uniqueID !== undefined) {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject;\r\n }\r\n }\r\n\r\n mode = drawArray.Mode || drawArray.mode;\r\n first = drawArray.First !== undefined ? drawArray.First : drawArray.first;\r\n count = drawArray.Count !== undefined ? drawArray.Count : drawArray.count;\r\n obj = new DrawArrays(primitiveSet[mode], first, count);\r\n promise = P.resolve(obj);\r\n } else if (drawArrayLengths) {\r\n uniqueID = drawArrayLengths.UniqueID;\r\n if (uniqueID !== undefined) {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject;\r\n }\r\n }\r\n\r\n mode = drawArrayLengths.Mode;\r\n first = drawArrayLengths.First;\r\n var array = drawArrayLengths.ArrayLengths;\r\n obj = new DrawArrayLengths(primitiveSet[mode], first, array);\r\n promise = P.resolve(obj);\r\n } else {\r\n promise = rejectObject('PrimitiveSet', jsonObj);\r\n }\r\n\r\n if (uniqueID !== undefined) {\r\n this._identifierMap[uniqueID] = promise;\r\n }\r\n\r\n return promise;\r\n },\r\n\r\n readObject: function() {\r\n var jsonObj = this.getJSON();\r\n var objKeys = window.Object.keys(jsonObj);\r\n var prop = objKeys[0];\r\n if (!prop) {\r\n return rejectObject(\"can't find property for object \" + objKeys);\r\n }\r\n\r\n var uniqueID = jsonObj[prop].UniqueID;\r\n var osgjsObject;\r\n if (uniqueID !== undefined ) {//if (uniqueID !== undefined && prop !== 'osg.StateSet') {\r\n osgjsObject = this._identifierMap[uniqueID];\r\n if (osgjsObject !== undefined) {\r\n return osgjsObject;\r\n }\r\n }\r\n\r\n var obj = this.getObjectWrapper(prop);\r\n\r\n if (!obj) {\r\n return rejectObject(\"can't instanciate object \" + prop);\r\n }\r\n\r\n var ReaderParser = require('./readerParser').default;\r\n var scope = ReaderParser.ObjectWrapper.serializers;\r\n\r\n if (this._cacheReadObject[prop]) {\r\n scope = this._cacheReadObject[prop];\r\n } else {\r\n var splittedPath = prop.split('.');\r\n for (var i = 0, l = splittedPath.length; i < l; i++) {\r\n var sub = splittedPath[i];\r\n var reader = scope[sub];\r\n if (!reader) {\r\n return rejectObject('Unknown scope ' + prop + '(' + sub + ')');\r\n }\r\n scope = reader;\r\n }\r\n this._cacheReadObject[prop] = scope;\r\n }\r\n\r\n var promise = scope(this.setJSON(jsonObj[prop]), obj);\r\n\r\n if (uniqueID !== undefined) {\r\n this._identifierMap[uniqueID] = promise;\r\n obj._uniqueID = uniqueID;\r\n }\r\n\r\n return promise;\r\n }\r\n};\r\n\r\nexport default Input;","import notify from './notify';\r\nimport WebGLUtils from '../osgViewer/webgl-utils';\r\nimport Options from './Options';\r\nvar Texture;\r\n\r\nvar WebGLCaps = function() {\r\n // circular deps with texture\r\n if (!Texture) Texture = require('./Texture').default;\r\n\r\n this._checkRTT = {};\r\n this._webGLExtensions = {};\r\n this._webGLParameters = {};\r\n this._webGLShaderMaxInt = 'NONE';\r\n this._webGLShaderMaxFloat = 'NONE';\r\n\r\n this._bugsDB = {};\r\n this._webGLPlatforms = {};\r\n\r\n // webgl minimum requirements as per webgl specs\r\n // useful for nodejs env\r\n this._webGLParameters['MAX_COMBINED_TEXTURE_IMAGE_UNITS'] = 8;\r\n this._webGLParameters['MAX_CUBE_MAP_TEXTURE_SIZE'] = 16;\r\n this._webGLParameters['MAX_FRAGMENT_UNIFORM_VECTORS'] = 16;\r\n this._webGLParameters['MAX_RENDERBUFFER_SIZE'] = 1;\r\n this._webGLParameters['MAX_TEXTURE_IMAGE_UNITS'] = 8;\r\n this._webGLParameters['MAX_TEXTURE_SIZE'] = 64;\r\n this._webGLParameters['MAX_VARYING_VECTORS'] = 8;\r\n this._webGLParameters['MAX_VERTEX_ATTRIBS'] = 8;\r\n this._webGLParameters['MAX_VERTEX_TEXTURE_IMAGE_UNITS'] = 0;\r\n this._webGLParameters['MAX_VERTEX_UNIFORM_VECTORS'] = 128;\r\n this._webGLParameters['MAX_VIEWPORT_DIMS'] = [1, 1];\r\n this._webGLParameters['NUM_COMPRESSED_TEXTURE_FORMATS'] = 0;\r\n this._webGLParameters['MAX_SHADER_PRECISION_FLOAT'] = 'none';\r\n this._webGLParameters['MAX_SHADER_PRECISION_INT'] = 'none';\r\n\r\n // for multiple context\r\n // allow checking we're on the good one\r\n this._gl = undefined;\r\n};\r\n\r\nWebGLCaps.instance = function(glParam, force) {\r\n if (!WebGLCaps._instance) {\r\n var oldWebGLInspector;\r\n var gl = glParam;\r\n\r\n if (!gl) {\r\n // make sure we don't break webglinspector\r\n // with our webglcaps canvas\r\n var webglInspector = typeof window !== 'undefined' && window.gli;\r\n\r\n if (webglInspector) {\r\n oldWebGLInspector = window.gli.host.inspectContext;\r\n window.gli.host.inspectContext = false;\r\n }\r\n\r\n var c = document.createElement('canvas');\r\n c.width = 32;\r\n c.height = 32;\r\n\r\n var options = new Options();\r\n // not necessary, but for some reasons it crashed on chromium vr build\r\n options.extend({\r\n antialias: false\r\n });\r\n // in case of webgl2\r\n options.extendWithOptionsURL();\r\n\r\n gl = WebGLUtils.setupWebGL(c, options, function() {});\r\n }\r\n\r\n WebGLCaps._instance = new WebGLCaps();\r\n if (gl) {\r\n WebGLCaps._instance.init(gl);\r\n } else {\r\n // gracefully handle non webgl\r\n // like nodejs, phantomjs\r\n // warns but no error so that nodejs/phantomjs\r\n // can still has some webglcaps object\r\n notify.warn('no support for webgl context detected.');\r\n }\r\n\r\n if (oldWebGLInspector) {\r\n window.gli.host.inspectContext = oldWebGLInspector;\r\n }\r\n\r\n //delete c;\r\n }\r\n\r\n if (glParam && (force || glParam !== WebGLCaps._instance.getContext())) {\r\n // webgl caps called with a different context or GPU\r\n // than the one we draw in, will result on hard crash\r\n // when using extension from another context\r\n WebGLCaps._instance.initContextDependant(glParam);\r\n }\r\n\r\n return WebGLCaps._instance;\r\n};\r\n\r\nWebGLCaps.prototype = {\r\n getContext: function() {\r\n return this._gl;\r\n },\r\n\r\n initContextDependant: function(gl) {\r\n // store context in case of multiple context\r\n this._gl = gl;\r\n // We need to check if this is a webGL2 context to get the extensions work.\r\n this._isGL2 =\r\n typeof window.WebGL2RenderingContext !== 'undefined' &&\r\n gl instanceof window.WebGL2RenderingContext;\r\n // Takes care of circular dependencies on Texture\r\n // Texture should be resolved at this point\r\n // Texture = require('./Texture').default;\r\n\r\n // get extensions\r\n this.initWebGLExtensions(gl);\r\n\r\n // get float support\r\n this.hasLinearHalfFloatRTT(gl);\r\n this.hasLinearFloatRTT(gl);\r\n this.hasHalfFloatRTT(gl);\r\n this.hasFloatRTT(gl);\r\n },\r\n\r\n init: function(gl) {\r\n // get capabilites\r\n this.initWebGLParameters(gl);\r\n\r\n // order is important\r\n // to allow webgl extensions filtering\r\n this.initPlatformSupport();\r\n this.initBugDB(gl);\r\n\r\n this.initContextDependant(gl);\r\n\r\n if (this._isGL2) {\r\n var nativeExtension = [\r\n 'OES_element_index_uint',\r\n 'EXT_sRGB',\r\n 'EXT_blend_minmax',\r\n 'EXT_frag_depth',\r\n 'WEBGL_depth_texture',\r\n 'EXT_shader_texture_lod',\r\n 'OES_standard_derivatives',\r\n 'OES_texture_float',\r\n 'OES_texture_half_float',\r\n 'OES_texture_half_float_linear',\r\n 'OES_texture_float_linear',\r\n 'OES_vertex_array_object',\r\n 'WEBGL_draw_buffers',\r\n 'OES_fbo_render_mipmap',\r\n 'ANGLE_instanced_arrays'\r\n ];\r\n\r\n var ext = WebGLCaps._instance.getWebGLExtensions();\r\n var dummyFunc = function() {};\r\n for (var i = 0, l = nativeExtension.length; i < l; i++) {\r\n ext[nativeExtension[i]] = dummyFunc;\r\n }\r\n }\r\n },\r\n\r\n isWebGL2: function() {\r\n return this._isGL2;\r\n },\r\n\r\n // inevitable bugs per platform (browser/OS/GPU)\r\n initBugDB: function(gl) {\r\n var p = this._webGLPlatforms;\r\n var ext = this._webGLParameters;\r\n\r\n // derivatives gives strange results on Shadow Shaders\r\n if (p.Apple) {\r\n if (!ext.UNMASKED_VENDOR_WEBGL || ext.UNMASKED_VENDOR_WEBGL.indexOf('Intel') !== -1) {\r\n // bug is on INTEL GPU on APPLE\r\n // we disable the ext on Apple if we cannot get GPU info\r\n this._bugsDB['OES_standard_derivatives'] = true;\r\n }\r\n }\r\n\r\n if (gl.getExtension('EXT_shader_texture_lod')) {\r\n // https://forums.imgtec.com/t/texturecubelod-is-removed-after-version-140/2260\r\n var test = {\r\n type: 'FRAGMENT_SHADER',\r\n text: [\r\n '#version 100',\r\n '#extension GL_EXT_shader_texture_lod : require',\r\n '#ifdef GL_FRAGMENT_PRECISION_HIGH',\r\n ' precision highp float;',\r\n '#else',\r\n ' precision mediump float;',\r\n '#endif',\r\n 'uniform samplerCube uT0;',\r\n 'varying vec3 vC;',\r\n 'void main(void) {',\r\n ' gl_FragColor = textureCubeLodEXT(uT0, vC, 1.0);',\r\n '}'\r\n ].join('\\n')\r\n };\r\n var hasSupport = this.checkShader(gl, test.type, test.text);\r\n if (!hasSupport) {\r\n this._bugsDB['EXT_shader_texture_lod'] = true;\r\n }\r\n }\r\n },\r\n\r\n checkShader: function(gl, t, text) {\r\n var type = t;\r\n if (typeof type === 'string') type = gl[t];\r\n var shader = gl.createShader(type);\r\n gl.shaderSource(shader, text);\r\n gl.compileShader(shader);\r\n\r\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\r\n notify.warn(gl.getShaderInfoLog(shader));\r\n return false;\r\n }\r\n return true;\r\n },\r\n\r\n initPlatformSupport: function() {\r\n var p = this._webGLPlatforms;\r\n\r\n p.Apple =\r\n navigator.vendor.indexOf('Apple') !== -1 || navigator.vendor.indexOf('OS X') !== -1;\r\n\r\n // degrades complexity on handhelds.\r\n p.Mobile = /Mobi/.test(navigator.userAgent) || /ablet/.test(navigator.userAgent);\r\n },\r\n\r\n getWebGLPlatform: function(str) {\r\n return this._webGLPlatforms[str];\r\n },\r\n\r\n getWebGLPlatforms: function() {\r\n return this._webGLPlatforms;\r\n },\r\n\r\n getWebGLParameter: function(str) {\r\n return this._webGLParameters[str];\r\n },\r\n\r\n getWebGLParameters: function() {\r\n return this._webGLParameters;\r\n },\r\n\r\n getShaderMaxPrecisionFloat: function() {\r\n return this._webGLParameters.MAX_SHADER_PRECISION_FLOAT;\r\n },\r\n\r\n getShaderMaxPrecisionInt: function() {\r\n return this._webGLParameters.MAX_SHADER_PRECISION_INT;\r\n },\r\n\r\n checkSupportRTT: function(gl, typeFloat, typeTexture) {\r\n var key = typeFloat + ',' + typeTexture;\r\n\r\n if (this._isGL2) {\r\n return !!this._webGLExtensions['EXT_color_buffer_float'];\r\n }\r\n\r\n // check once only\r\n if (this._checkRTT[key] !== undefined) return this._checkRTT[key];\r\n\r\n // no cached results, need gl context\r\n if (!gl) return false;\r\n\r\n // from http://codeflow.org/entries/2013/feb/22/how-to-write-portable-webgl/#how-can-i-detect-if-i-can-render-to-floating-point-textures\r\n\r\n // setup the texture\r\n var texture = gl.createTexture();\r\n gl.bindTexture(gl.TEXTURE_2D, texture);\r\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, typeFloat, null);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, typeTexture);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, typeTexture);\r\n\r\n // setup the framebuffer\r\n var framebuffer = gl.createFramebuffer();\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\r\n\r\n // check the framebuffer\r\n var status = (this._checkRTT[key] =\r\n gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE);\r\n\r\n // cleanup\r\n gl.deleteTexture(texture);\r\n gl.deleteFramebuffer(framebuffer);\r\n gl.bindTexture(gl.TEXTURE_2D, null);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n\r\n return status;\r\n },\r\n\r\n hasLinearHalfFloatRTT: function(gl) {\r\n return (\r\n this._webGLExtensions['OES_texture_half_float_linear'] &&\r\n this.checkSupportRTT(gl, Texture.HALF_FLOAT_OES, Texture.LINEAR)\r\n );\r\n },\r\n\r\n hasLinearFloatRTT: function(gl) {\r\n return (\r\n this._webGLExtensions['OES_texture_float_linear'] &&\r\n this.checkSupportRTT(gl, Texture.FLOAT, Texture.LINEAR)\r\n );\r\n },\r\n\r\n hasHalfFloatRTT: function(gl) {\r\n return (\r\n this._webGLExtensions['OES_texture_half_float'] &&\r\n this.checkSupportRTT(gl, Texture.HALF_FLOAT_OES, Texture.NEAREST)\r\n );\r\n },\r\n\r\n hasFloatRTT: function(gl) {\r\n return (\r\n this._webGLExtensions['OES_texture_float'] &&\r\n this.checkSupportRTT(gl, Texture.FLOAT, Texture.NEAREST)\r\n );\r\n },\r\n\r\n queryPrecision: function(gl, shaderType, precision) {\r\n var answer = gl.getShaderPrecisionFormat(shaderType, precision);\r\n if (!answer) return false;\r\n return answer.precision !== 0;\r\n },\r\n\r\n hasVAO: function() {\r\n return !!this._webGLExtensions['OES_vertex_array_object'];\r\n },\r\n\r\n getDisjointTimerQuery: function() {\r\n return (\r\n this._webGLExtensions['EXT_disjoint_timer_query_webgl2'] ||\r\n this._webGLExtensions['EXT_disjoint_timer_query']\r\n );\r\n },\r\n\r\n initWebGLParameters: function(gl) {\r\n if (!gl) return;\r\n var limits = [\r\n 'MAX_COMBINED_TEXTURE_IMAGE_UNITS',\r\n 'MAX_CUBE_MAP_TEXTURE_SIZE',\r\n 'MAX_FRAGMENT_UNIFORM_VECTORS',\r\n 'MAX_RENDERBUFFER_SIZE',\r\n 'MAX_TEXTURE_IMAGE_UNITS',\r\n 'MAX_TEXTURE_SIZE',\r\n 'MAX_VARYING_VECTORS',\r\n 'MAX_VERTEX_ATTRIBS',\r\n 'MAX_VERTEX_TEXTURE_IMAGE_UNITS',\r\n 'MAX_VERTEX_UNIFORM_VECTORS',\r\n 'MAX_VIEWPORT_DIMS',\r\n 'SHADING_LANGUAGE_VERSION',\r\n 'VERSION',\r\n 'VENDOR',\r\n 'RENDERER',\r\n 'ALIASED_LINE_WIDTH_RANGE',\r\n 'ALIASED_POINT_SIZE_RANGE',\r\n 'RED_BITS',\r\n 'GREEN_BITS',\r\n 'BLUE_BITS',\r\n 'ALPHA_BITS',\r\n 'DEPTH_BITS',\r\n 'STENCIL_BITS'\r\n ];\r\n var params = this._webGLParameters;\r\n for (var i = 0, len = limits.length; i < len; ++i) {\r\n var par = limits[i];\r\n params[par] = gl.getParameter(gl[par]);\r\n }\r\n\r\n //shader precisions for float\r\n if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.HIGH_FLOAT)) {\r\n params.MAX_SHADER_PRECISION_FLOAT = 'high';\r\n } else if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT)) {\r\n params.MAX_SHADER_PRECISION_FLOAT = 'medium';\r\n } else if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.LOW_FLOAT)) {\r\n params.MAX_SHADER_PRECISION_FLOAT = 'low';\r\n }\r\n\r\n //shader precisions for float\r\n if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.HIGH_INT)) {\r\n params.MAX_SHADER_PRECISION_INT = 'high';\r\n } else if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.MEDIUM_INT)) {\r\n params.MAX_SHADER_PRECISION_INT = 'medium';\r\n } else if (this.queryPrecision(gl, gl.FRAGMENT_SHADER, gl.LOW_INT)) {\r\n params.MAX_SHADER_PRECISION_INT = 'low';\r\n }\r\n\r\n // get GPU, Angle or not, Opengl/directx, etc.\r\n // ffx && chrome only\r\n var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');\r\n if (debugInfo) {\r\n params.UNMASKED_RENDERER_WEBGL = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);\r\n params.UNMASKED_VENDOR_WEBGL = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);\r\n }\r\n // TODO ?\r\n // try to compile a small shader to test the spec is respected\r\n },\r\n\r\n applyExtension: function(gl, name) {\r\n var ext = gl.getExtension(name);\r\n // Borrowed from https://webgl2fundamentals.org/webgl/lessons/webgl1-to-webgl2.html\r\n // make \"generalized\" functions and name\r\n // so that can be used in webgl1 & wegbl2\r\n var suffix = name.split('_')[0];\r\n var prefix = '_' + suffix;\r\n var suffixRE = new RegExp(suffix + '$');\r\n var prefixRE = new RegExp(prefix);\r\n for (var key in ext) {\r\n var val = ext[key];\r\n if (typeof val === 'function') {\r\n // remove suffix (eg: bindVertexArrayOES -> bindVertexArray)\r\n var unsuffixedKey = key.replace(suffixRE, '');\r\n if (gl[unsuffixedKey] === undefined) gl[unsuffixedKey] = ext[key].bind(ext);\r\n } else {\r\n var unprefixedKey = key.replace(prefixRE, '');\r\n if (gl[unprefixedKey] === undefined) gl[unprefixedKey] = ext[key];\r\n }\r\n }\r\n },\r\n\r\n getWebGLExtension: function(str) {\r\n return this._webGLExtensions[str];\r\n },\r\n\r\n getWebGLExtensions: function() {\r\n return this._webGLExtensions;\r\n },\r\n\r\n _checkShader: function(gl, t, text) {\r\n var type = t;\r\n if (typeof type === 'string') type = gl[t];\r\n var shader = gl.createShader(type);\r\n gl.shaderSource(shader, text);\r\n gl.compileShader(shader);\r\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n\r\n // some mobile reuse same driver\r\n // GPUs with different capabilities\r\n // double check if glsl compiler agree\r\n // with driver\r\n _doubleCheckExtension: function(gl, extension) {\r\n var shader = [\r\n '#version 100',\r\n '#extension GL_%ext% : require',\r\n 'precision mediump float;',\r\n 'varying vec3 vColor;',\r\n 'void main() {',\r\n 'gl_FragColor = vec4(vColor, 1.0);',\r\n '}'\r\n ].join('\\n');\r\n return this._checkShader(gl, 'FRAGMENT_SHADER', shader.replace(/\\%ext\\%/g, extension));\r\n },\r\n\r\n initWebGLExtensions: function(gl, filterBugs) {\r\n // nodejs, phantomjs\r\n if (!gl) return;\r\n\r\n var doFilter = filterBugs;\r\n if (doFilter === undefined) doFilter = true;\r\n\r\n var supported = gl.getSupportedExtensions();\r\n if (!supported) return;\r\n var ext = this._webGLExtensions;\r\n // we load all the extensions\r\n for (var i = 0, len = supported.length; i < len; ++i) {\r\n var sup = supported[i];\r\n\r\n if (doFilter && this._bugsDB[sup]) {\r\n // bugs on that configuration, do not enable\r\n continue;\r\n }\r\n\r\n ext[sup] = gl.getExtension(sup);\r\n if (!this._isGL2) this.applyExtension(gl, sup);\r\n }\r\n\r\n if (!this._isGL2) {\r\n // double check extensions support\r\n // for now only texture lod... might have to go in loop\r\n // and start a DB of ext to check.\r\n // time will tell\r\n var extToCheck = 'EXT_shader_texture_lod';\r\n if (ext[extToCheck] && !this._doubleCheckExtension(gl, extToCheck))\r\n delete ext[extToCheck];\r\n }\r\n\r\n var anisoExt = this.getWebGLExtension('EXT_texture_filter_anisotropic');\r\n if (anisoExt) {\r\n Texture.ANISOTROPIC_SUPPORT_EXT = true;\r\n Texture.ANISOTROPIC_SUPPORT_MAX = gl.getParameter(\r\n anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT\r\n );\r\n }\r\n }\r\n};\r\n\r\nexport default WebGLCaps;","import { vec3 } from './glMatrix';\r\nimport primitiveSet from './primitiveSet';\r\nimport DrawElements from './DrawElements';\r\nimport DrawArrays from './DrawArrays';\r\n\r\n/**\r\n * PrimitiveFunctor emulates the TemplatePrimitiveFunctor class in OSG and can\r\n * be used to get access to the vertices that compose the things drawn by osgjs.\r\n *\r\n * You have to feed it with an object that references 3 callbacks :\r\n *\r\n * var myObject = {\r\n * operatorPoint : function ( v ) { }, // Do your point operations here\r\n * operatorLine : function ( v1, v2 ){ }, // Do you line operations here\r\n * operatorTriangle : function ( v1, v2, v3 ) { } // Do your triangle operations here\r\n * };\r\n *\r\n */\r\n\r\nvar functorDrawElements = [];\r\nvar functorDrawArrays = [];\r\n\r\nfunctorDrawElements[primitiveSet.POINTS] = (function() {\r\n var v = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; ++i) {\r\n var j = indexes[i] * 3;\r\n v[0] = vertices[j];\r\n v[1] = vertices[j + 1];\r\n v[2] = vertices[j + 2];\r\n cb.operatorPoint(v);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.LINES] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var end = offset + count;\r\n for (var i = offset; i < end - 1; i += 2) {\r\n var j = indexes[i] * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = indexes[i + 1] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.LINE_STRIP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var end = offset + count;\r\n for (var i = offset; i < end - 1; ++i) {\r\n var j = indexes[i] * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = indexes[i + 1] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.LINE_LOOP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var last = offset + count - 1;\r\n for (var i = offset; i < last; ++i) {\r\n var j = indexes[i] * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = indexes[i + 1] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n last = indexes[last] * 3;\r\n v1[0] = vertices[last];\r\n v1[1] = vertices[last + 1];\r\n v1[2] = vertices[last + 2];\r\n var first = indexes[0] * 3;\r\n v2[0] = vertices[first];\r\n v2[1] = vertices[first + 1];\r\n v2[2] = vertices[first + 2];\r\n cb.operatorLine(v1, v2);\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLES] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; i += 3) {\r\n var j = indexes[i] * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = indexes[i + 1] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = indexes[i + 2] * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_STRIP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n for (var i = 2, pos = offset; i < count; ++i, ++pos) {\r\n var j = indexes[pos] * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = indexes[pos + 1] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = indexes[pos + 2] * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n if (i % 2) {\r\n cb.operatorTriangle(v1, v3, v2);\r\n } else {\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_FAN] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(offset, count, indexes, cb, vertices) {\r\n var first = indexes[offset];\r\n for (var i = 2, pos = offset + 1; i < count; ++i, ++pos) {\r\n v1[0] = vertices[first];\r\n v1[1] = vertices[first + 1];\r\n v1[2] = vertices[first + 2];\r\n var j = indexes[pos] * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = indexes[pos + 1] * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.POINTS] = (function() {\r\n var v = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = first; i < first + count; ++i) {\r\n var j = i * 3;\r\n v[0] = vertices[j];\r\n v[1] = vertices[j + 1];\r\n v[2] = vertices[j + 2];\r\n cb.operatorPoint(v);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.LINES] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = first; i < first + count - 1; i += 2) {\r\n var j = i * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = (i + 1) * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.LINE_STRIP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = first; i < first + count - 1; ++i) {\r\n var j = i * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = (i + 1) * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.LINE_LOOP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n var last = first + count - 1;\r\n for (var i = first; i < last; ++i) {\r\n var j = i * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = (i + 1) * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n cb.operatorLine(v1, v2);\r\n }\r\n last = last * 3;\r\n v1[0] = vertices[last];\r\n v1[1] = vertices[last + 1];\r\n v1[2] = vertices[last + 2];\r\n first = first * 3;\r\n v2[0] = vertices[first];\r\n v2[1] = vertices[first + 1];\r\n v2[2] = vertices[first + 2];\r\n cb.operatorLine(v1, v2);\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLES] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = first; i < first + count; i += 3) {\r\n var j = i * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = (i + 1) * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = (i + 2) * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_STRIP] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = 2, pos = first; i < count; ++i, ++pos) {\r\n var j = pos * 3;\r\n v1[0] = vertices[j];\r\n v1[1] = vertices[j + 1];\r\n v1[2] = vertices[j + 2];\r\n j = (pos + 1) * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = (pos + 2) * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n if (i % 2) {\r\n cb.operatorTriangle(v1, v3, v2);\r\n } else {\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n }\r\n };\r\n})();\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_FAN] = (function() {\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n return function(first, count, cb, vertices) {\r\n for (var i = 2, pos = first + 1; i < count; ++i, ++pos) {\r\n v1[0] = vertices[first];\r\n v1[1] = vertices[first + 1];\r\n v1[2] = vertices[first + 2];\r\n var j = pos * 3;\r\n v2[0] = vertices[j];\r\n v2[1] = vertices[j + 1];\r\n v2[2] = vertices[j + 2];\r\n j = (pos + 1) * 3;\r\n v3[0] = vertices[j];\r\n v3[1] = vertices[j + 1];\r\n v3[2] = vertices[j + 2];\r\n cb.operatorTriangle(v1, v2, v3);\r\n }\r\n };\r\n})();\r\n\r\nvar primitiveFunctor = function(geom, cb, vertices) {\r\n var primitives = geom.getPrimitiveSetList();\r\n if (!primitives) return;\r\n\r\n var cbFunctor;\r\n\r\n var nbPrimitives = primitives.length;\r\n for (var i = 0; i < nbPrimitives; i++) {\r\n var primitive = primitives[i];\r\n if (primitive instanceof DrawElements) {\r\n cbFunctor = functorDrawElements[primitive.getMode()];\r\n if (cbFunctor) {\r\n var indexes = primitive.indices.getElements();\r\n cbFunctor(\r\n primitive.getFirst() / indexes.BYTES_PER_ELEMENT,\r\n primitive.getCount(),\r\n indexes,\r\n cb,\r\n vertices\r\n );\r\n }\r\n } else if (primitive instanceof DrawArrays) {\r\n cbFunctor = functorDrawArrays[primitive.getMode()];\r\n if (cbFunctor) {\r\n cbFunctor(primitive.getFirst(), primitive.getCount(), cb, vertices);\r\n }\r\n }\r\n }\r\n};\r\n\r\nexport default primitiveFunctor;","import notify from '../../osg/notify';\r\n\r\nvar instance = 0;\r\nvar Node = function() {\r\n this._name = 'AbstractNode';\r\n this._inputs = [];\r\n this._outputs = null;\r\n\r\n // category of node\r\n // same name implies same\r\n // define/function\r\n //this.type = '';\r\n\r\n // uuid: unicity\r\n // allows multipe node of same type\r\n // declaring multipe code paths\r\n // inside the main\r\n this._id = instance++;\r\n\r\n this._text = undefined;\r\n};\r\n\r\nNode.prototype = {\r\n getID: function() {\r\n return this._id;\r\n },\r\n getName: function() {\r\n return this._name;\r\n },\r\n\r\n getType: function() {\r\n return this.type;\r\n },\r\n\r\n toString: function() {\r\n var str = 'name : ' + this._name;\r\n if (this.type) str += ' (' + this.type + ')';\r\n return str;\r\n },\r\n\r\n getInputs: function() {\r\n return this._inputs;\r\n },\r\n\r\n getOutputs: function() {\r\n return this._outputs;\r\n },\r\n\r\n checkInputsOutputs: function() {\r\n var i, key;\r\n if (this.validInputs) {\r\n for (i = 0; i < this.validInputs.length; i++) {\r\n key = this.validInputs[i];\r\n if (!this._inputs[key]) {\r\n notify.error(\r\n 'Shader node ' +\r\n this.type +\r\n ' validation error input ' +\r\n key +\r\n ' is missing'\r\n );\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n if (this.validOutputs) {\r\n for (i = 0; i < this.validOutputs.length; i++) {\r\n key = this.validOutputs[i];\r\n if (!this._outputs[key]) {\r\n notify.error(\r\n 'Shader node ' +\r\n this.type +\r\n ' validation error output ' +\r\n key +\r\n ' is missing'\r\n );\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n },\r\n\r\n // accepts inputs like that:\r\n // inputs( [ a, b, c , d] )\r\n // inputs( { a: x, b: y } )\r\n // inputs( a, b, c, d )\r\n inputs: function() {\r\n // handle inputs ( a, b, c, d)\r\n for (var i = 0, l = arguments.length; i < l; i++) {\r\n var input = arguments[i];\r\n if (!input) {\r\n notify.error('Shader node ' + this.type + ' input number ' + l + ' is undefined ');\r\n break;\r\n }\r\n\r\n // handle inputs( [a, b, c ,d] )\r\n if (Array.isArray(input)) {\r\n this.inputs.apply(this, input);\r\n return this;\r\n\r\n // check for an object {} and not something from base class Node\r\n } else if (\r\n typeof input === 'object' &&\r\n input !== null &&\r\n input instanceof Node === false\r\n ) {\r\n this._inputs = input;\r\n return this;\r\n } else {\r\n // add argument to the array\r\n this._inputs.push(input);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n // accepts inputs like that:\r\n // outputs( { a: x, b: y } )\r\n // outputs( a )\r\n outputs: function(outputs) {\r\n this._outputs = outputs;\r\n\r\n // single output\r\n if (this._outputs instanceof Node === true) {\r\n this.autoLink(this._outputs);\r\n } else {\r\n // iterate on objects keys\r\n for (var key in this._outputs) {\r\n this.autoLink(this._outputs[key]);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n autoLink: function(output) {\r\n if (output === undefined) return this;\r\n\r\n output.inputs(this);\r\n\r\n return this;\r\n },\r\n\r\n computeShader: function() {\r\n return this._text;\r\n },\r\n\r\n comment: function(txt) {\r\n this._comment = '//' + txt;\r\n },\r\n\r\n getComment: function() {\r\n return this._comment;\r\n }\r\n};\r\n\r\nexport default Node;\r\n","import P from 'bluebird';\r\n\r\nimport readerParser from './readerParser';\r\nimport Registry from './Registry';\r\nimport requestFile from './requestFile.js';\r\nimport notify from '../osg/notify';\r\n\r\nvar isString = function(str) {\r\n return typeof str === 'string' || str instanceof String;\r\n};\r\n\r\nvar isBlobURL = function(str) {\r\n return str.substr(0, 9) === 'blob:http';\r\n};\r\n\r\nvar isHttpURL = function(str) {\r\n return str.substr(0, 7) === 'http://' || str.substr(0, 8) === 'https://';\r\n};\r\n\r\nvar isURL = function(str) {\r\n if (!isString(str)) return false;\r\n\r\n return isBlobURL(str) || isHttpURL(str);\r\n};\r\n\r\nvar zip = window.zip;\r\n\r\nvar mimeTypes = new window.Map();\r\n\r\nvar createImageFromURL = function(url) {\r\n return new P(function(resolve, reject) {\r\n var img = new window.Image();\r\n img.onerror = function() {\r\n reject(img);\r\n };\r\n\r\n img.onload = function() {\r\n resolve(img);\r\n };\r\n img.src = url;\r\n });\r\n};\r\n\r\nvar createImageFromBlob = function(blob) {\r\n var privateURL = window.URL.createObjectURL(blob);\r\n var promise = createImageFromURL(privateURL);\r\n\r\n promise.finally(function() {\r\n window.URL.revokeObjectURL(privateURL);\r\n });\r\n return promise;\r\n};\r\n\r\nvar createArrayBufferFromBlob = function(blob) {\r\n return new P(function(resolve, reject) {\r\n var fr = new window.FileReader();\r\n\r\n fr.onerror = function() {\r\n reject(fr);\r\n };\r\n\r\n fr.onload = function() {\r\n resolve(this.result);\r\n };\r\n fr.readAsArrayBuffer(blob);\r\n });\r\n};\r\n\r\nvar createArrayBufferFromURL = function(url) {\r\n return requestFile(url, {\r\n responseType: 'arraybuffer'\r\n });\r\n};\r\n\r\nvar createJSONFromURL = function(url) {\r\n return requestFile(url).then(function(string) {\r\n return JSON.parse(string);\r\n });\r\n};\r\n\r\nvar createJSONFromString = function(str) {\r\n var obj = JSON.parse(str);\r\n return P.resolve(obj);\r\n};\r\n\r\nvar fileHelper = {\r\n createJSONFromURL: createJSONFromURL,\r\n createArrayBufferFromURL: createArrayBufferFromURL,\r\n createArrayBufferFromBlob: createArrayBufferFromBlob,\r\n createImageFromBlob: createImageFromBlob,\r\n createImageFromURL: createImageFromURL,\r\n\r\n requestURI: requestFile,\r\n requestResource: function(uri, options) {\r\n var extension = fileHelper.getExtension(uri);\r\n var mimetype = fileHelper.getMimeType(extension);\r\n\r\n var responseType =\r\n options && options.responseType ? options.responseType.toLowerCase() : undefined;\r\n if (responseType) return requestFile(uri, options);\r\n\r\n if (mimetype) {\r\n if (mimetype.match('image')) return createImageFromURL(uri);\r\n else if (mimetype.match('binary')) return createArrayBufferFromURL(uri);\r\n else if (mimetype.match('json')) return createJSONFromURL(uri);\r\n else if (mimetype.match('text')) return requestFile(uri);\r\n }\r\n\r\n return requestFile(uri);\r\n },\r\n\r\n // file.png : url -> fetch/createImage -> Image\r\n // file.png : blob -> createImage -> Image\r\n // file.png : Image -> passthroug -> Image\r\n // file.txt : blob -> FileReader -> String\r\n // file.txt : string -> passthroug -> String\r\n // file.txt : url -> fetch -> String\r\n // file.json: string -> JSON.parse -> Object\r\n // file.json: url -> fetch/JSON.parse -> Object\r\n // file.json: blob -> FileReader/JSON.parse -> Object\r\n // file.bin : blob -> FileReader/readAsArrayBuffer -> arrayBuffer\r\n // file.bin : url -> fetch as arra yBuffer -> arrayBuffer\r\n // file.bin : arrayBuffer -> passthroug -> arrayBuffer\r\n resolveData: function(uri, data) {\r\n var extension = fileHelper.getExtension(uri);\r\n var mimetype = fileHelper.getMimeType(extension);\r\n var createData;\r\n\r\n if (mimetype) {\r\n if (mimetype.match('image')) {\r\n if (isString(data)) createData = createImageFromURL;\r\n else if (data instanceof window.Blob) createData = createImageFromBlob;\r\n } else if (mimetype.match('json')) {\r\n if (isURL(data)) createData = createJSONFromURL;\r\n else createData = createJSONFromString;\r\n } else if (mimetype.match('binary')) {\r\n if (isString(data)) createData = createArrayBufferFromURL;\r\n else if (data instanceof window.Blob) createData = createArrayBufferFromBlob;\r\n }\r\n }\r\n\r\n var promise;\r\n if (createData) {\r\n promise = createData(data);\r\n } else {\r\n promise = P.resolve(data);\r\n }\r\n return promise;\r\n },\r\n\r\n resolveFilesMap: function(filesMap) {\r\n var promises = [];\r\n\r\n for (var filename in filesMap) {\r\n var data = filesMap[filename];\r\n var promise = fileHelper.resolveData(filename, data).then(\r\n function(fname, dataResolved) {\r\n this[fname] = dataResolved;\r\n }.bind(filesMap, filename)\r\n );\r\n promises.push(promise);\r\n }\r\n\r\n return P.all(promises).then(function() {\r\n return filesMap;\r\n });\r\n },\r\n\r\n _unzipEntry: function(entry) {\r\n return new P(function(resolve) {\r\n var filename = entry.filename;\r\n var extension = fileHelper.getExtension(filename);\r\n var mimetype = fileHelper.getMimeType(extension);\r\n\r\n var Writer = zip.BlobWriter;\r\n if (mimetype.match('text') !== null || mimetype.match('json') !== null)\r\n Writer = zip.TextWriter;\r\n // get data from the first file\r\n entry.getData(new Writer(mimetype), function(data) {\r\n resolve({\r\n filename: filename,\r\n data: data\r\n });\r\n });\r\n });\r\n },\r\n\r\n unzipBlob: function(blob) {\r\n return new P(function(resolve, reject) {\r\n // use a zip.BlobReader object to read zipped data stored into blob variable\r\n var filesMap = {};\r\n var filePromises = [];\r\n zip.createReader(\r\n new zip.BlobReader(blob),\r\n function(zipReader) {\r\n // get entries from the zip file\r\n zipReader.getEntries(function(entries) {\r\n for (var i = 0; i < entries.length; i++) {\r\n if (entries[i].directory) continue;\r\n\r\n var promise = fileHelper._unzipEntry(entries[i]);\r\n promise.then(function(result) {\r\n filesMap[result.filename] = result.data;\r\n });\r\n filePromises.push(promise);\r\n }\r\n\r\n P.all(filePromises).then(function() {\r\n zipReader.close();\r\n fileHelper.resolveFilesMap(filesMap).then(function(filesMapResolved) {\r\n resolve(filesMapResolved);\r\n });\r\n });\r\n });\r\n },\r\n function() {\r\n reject(this);\r\n }\r\n );\r\n });\r\n },\r\n\r\n unzip: function(input) {\r\n if (!window.zip)\r\n return P.reject(\r\n 'missing deps to unzip, require https://github.com/gildas-lormeau/zip.js'\r\n );\r\n\r\n if (isString(input)) {\r\n return fileHelper.requestResource(input).then(function(arrayBuffer) {\r\n var blob = new window.Blob([arrayBuffer], { type: mimeTypes.get('zip') });\r\n return fileHelper.unzipBlob(blob);\r\n });\r\n } else if (input instanceof window.Blob) {\r\n return fileHelper.unzipBlob(input);\r\n } else if (input instanceof window.ArrayBuffer) {\r\n var blob = new window.Blob([input], { type: mimeTypes.get('zip') });\r\n return fileHelper.unzipBlob(blob);\r\n }\r\n return P.reject('cant unzip input');\r\n },\r\n\r\n readFileList: function(fileList) {\r\n var fileName;\r\n var filesMap = {};\r\n var promiseArray = [];\r\n var i;\r\n\r\n for (i = 0; i < fileList.length; ++i) {\r\n var ext = fileHelper.getExtension(fileList[i].name);\r\n var readerWriter = Registry.instance().getReaderWriterForExtension(ext);\r\n // We need a hack for osgjs til it is converted to a readerwriter\r\n if (readerWriter !== undefined || ext === 'osgjs') {\r\n // So this is the main file to read\r\n fileName = fileList[i].name;\r\n }\r\n\r\n var mimeType = fileHelper.getMimeType(ext);\r\n var type;\r\n if (mimeType.match('image')) type = 'blob';\r\n else if (mimeType.match('json') || mimeType.match('text')) type = 'string';\r\n else type = 'arraybuffer';\r\n\r\n promiseArray.push(\r\n requestFile(fileList[i], {\r\n responseType: type\r\n })\r\n );\r\n }\r\n\r\n return P.all(promiseArray).then(function(files) {\r\n for (i = 0; i < files.length; ++i) {\r\n filesMap[fileList[i].name] = files[i];\r\n }\r\n return fileHelper.resolveFilesMap(filesMap).then(function(filesMapResolved) {\r\n return readerParser.readNodeURL(fileName, {\r\n filesMap: filesMapResolved\r\n });\r\n });\r\n });\r\n },\r\n\r\n getMimeType: function(extension) {\r\n return mimeTypes.get(extension);\r\n },\r\n\r\n getExtension: function(url) {\r\n return url.substr(url.lastIndexOf('.') + 1);\r\n },\r\n\r\n addMimeTypeForExtension: function(extension, mimeType) {\r\n if (mimeTypes.has(extension) !== undefined) {\r\n notify.warn(\r\n \"the '\" + extension + \"' already has a mimetype: \" + mimeTypes.get(extension)\r\n );\r\n }\r\n mimeTypes.set(extension, mimeType);\r\n }\r\n};\r\n\r\nmimeTypes.set('bin', 'application/octet-binary');\r\nmimeTypes.set('b3dm', 'application/octet-binary');\r\nmimeTypes.set('glb', 'application/octet-binary');\r\nmimeTypes.set('zip', 'application/octet-binary');\r\nmimeTypes.set('gz', 'application/octet-binary');\r\n// Image\r\nmimeTypes.set('png', 'image/png');\r\nmimeTypes.set('jpg', 'image/jpeg');\r\nmimeTypes.set('jpeg', 'image/jpeg');\r\nmimeTypes.set('gif', 'image/gif');\r\n// Text\r\nmimeTypes.set('json', 'application/json');\r\nmimeTypes.set('gltf', 'application/json');\r\nmimeTypes.set('osgjs', 'application/json');\r\nmimeTypes.set('txt', 'text/plain');\r\nmimeTypes.set('glsl', 'text/plain');\r\n\r\nexport default fileHelper;\r\n","import utils from './utils';\r\nimport Object from './Object';\r\n\r\nconst StateAttribute = function() {\r\n Object.call(this);\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n StateAttribute,\r\n utils.objectInherit(Object.prototype, {\r\n _attributeTypeIndex: undefined,\r\n\r\n getType: function() {\r\n return this.attributeType;\r\n },\r\n\r\n // basically, if you want two StateAttribute with the same attributeType in a stateSet/State\r\n // their typeMember should be different\r\n getTypeMember: function() {\r\n return this.attributeType;\r\n },\r\n\r\n apply: function() {},\r\n\r\n // getHash is used by the compiler to know if a change in a StateAttribute\r\n // must trigger a shader build\r\n // If you create your own attribute you will have to customize this function\r\n // a good rule is to that if you change uniform it should not rebuild a shader\r\n // but if you change a type or representation of your StateAttribute, then it should\r\n // if it impact the rendering.\r\n // check other attributes for examples\r\n getHash: function() {\r\n return this.getType();\r\n }\r\n }),\r\n 'osg',\r\n 'StateAttribute'\r\n);\r\n\r\nStateAttribute.OFF = 0;\r\nStateAttribute.ON = 1;\r\nStateAttribute.OVERRIDE = 2;\r\nStateAttribute.PROTECTED = 4;\r\nStateAttribute.INHERIT = 8;\r\nStateAttribute.OVERRIDE_ON = StateAttribute.OVERRIDE | StateAttribute.ON;\r\n\r\nexport default StateAttribute;\r\n","var CullSettings = function() {\r\n // Not doing a this.reset()\r\n // because of multiple inheritance\r\n // it will call the wrong reset\r\n // cullstack reset for isntance()\r\n CullSettings.prototype.reset.call(this);\r\n};\r\n\r\nCullSettings.prototype = {\r\n reset: function() {\r\n this._computeNearFar = true;\r\n this._nearFarRatio = 0.005;\r\n\r\n this._enableFrustumCulling = false;\r\n\r\n // who sets the parameter\r\n // if it's cullvisitor\r\n // it's an OVERRIDER for enableFrustumCulling\r\n // allowing for global EnableFrustimCulling\r\n this._settingsSourceOverrider = this;\r\n //LOD bias for the CullVisitor to use\r\n this._LODScale = 1.0;\r\n // Custom clampProjectionMatrix\r\n this._clampProjectionMatrixCallback = undefined;\r\n },\r\n\r\n setCullSettings: function(settings) {\r\n this._computeNearFar = settings._computeNearFar;\r\n this._nearFarRatio = settings._nearFarRatio;\r\n this._enableFrustumCulling = settings._enableFrustumCulling;\r\n this._settingsSourceOverrider = settings._settingsSourceOverrider;\r\n this._clampProjectionMatrixCallback = settings._clampProjectionMatrixCallback;\r\n },\r\n\r\n setNearFarRatio: function(ratio) {\r\n this._nearFarRatio = ratio;\r\n },\r\n getNearFarRatio: function() {\r\n return this._nearFarRatio;\r\n },\r\n setComputeNearFar: function(value) {\r\n this._computeNearFar = value;\r\n },\r\n getComputeNearFar: function() {\r\n return this._computeNearFar;\r\n },\r\n\r\n setEnableFrustumCulling: function(value) {\r\n this._enableFrustumCulling = value;\r\n },\r\n getEnableFrustumCulling: function() {\r\n return this._enableFrustumCulling;\r\n },\r\n\r\n getSettingSourceOverrider: function() {\r\n return this._settingsSourceOverrider;\r\n },\r\n\r\n setClampProjectionMatrixCallback: function(callback) {\r\n this._clampProjectionMatrixCallback = callback;\r\n },\r\n\r\n getClampProjectionMatrixCallback: function() {\r\n return this._clampProjectionMatrixCallback;\r\n },\r\n\r\n setLODScale: function(scale) {\r\n this._LODScale = scale;\r\n },\r\n getLODScale: function() {\r\n return this._LODScale;\r\n }\r\n};\r\n\r\nexport default CullSettings;\r\n","import notify from './notify';\r\n\r\n// Base class for GLResources: Textures, Buffers, Programs, Shaders, FrameBuffers and RenderBuffers\r\n// It holds a reference to the graphic context that is needed for resource deletion\r\nvar GLObject = function() {\r\n this._gl = undefined;\r\n this._onLostContextCallback = undefined;\r\n};\r\n\r\nGLObject.prototype = {\r\n setGraphicContext: function(gl) {\r\n this._gl = gl;\r\n GLObject.addObject(this._gl, this);\r\n },\r\n getGraphicContext: function() {\r\n return this._gl;\r\n },\r\n setLostContextCallback: function(cb) {\r\n this._onLostContextCallback = cb;\r\n },\r\n onLostContext: function() {\r\n if (this.invalidate && typeof this.invalidate === 'function') {\r\n this.invalidate();\r\n }\r\n /* develblock:start */\r\n if (!this.invalidate || typeof this.invalidate !== 'function') {\r\n notify.error('GLObject needs Dirty mechanism for webgl restore');\r\n }\r\n /* develblock:end */\r\n if (this._onLostContextCallback) this._onLostContextCallback();\r\n }\r\n};\r\n\r\n// handle webgl restore by indexing all GLObject\r\nGLObject._sResourcesArrayCache = new window.Map();\r\n\r\nGLObject.addObject = function(gl, glObject) {\r\n if (!GLObject._sResourcesArrayCache.has(gl)) GLObject._sResourcesArrayCache.set(gl, []);\r\n var resourcesArray = GLObject._sResourcesArrayCache.get(gl);\r\n\r\n if (resourcesArray.indexOf(glObject) !== -1) return;\r\n resourcesArray.push(glObject);\r\n};\r\n\r\nGLObject.removeObject = function(gl, glObject) {\r\n if (!GLObject._sResourcesArrayCache.has(gl)) return;\r\n\r\n var resourcesArray = GLObject._sResourcesArrayCache.get(gl);\r\n var i = resourcesArray.indexOf(glObject);\r\n if (i === -1) return;\r\n resourcesArray.splice(i, 1);\r\n};\r\n\r\nGLObject.onLostContext = function(gl) {\r\n if (!GLObject._sResourcesArrayCache.has(gl)) return;\r\n\r\n var resourcesArray = GLObject._sResourcesArrayCache.get(gl);\r\n for (var i = 0, l = resourcesArray.length; i < l; i++) {\r\n resourcesArray[i].onLostContext();\r\n }\r\n};\r\n\r\nexport default GLObject;","var primitiveSet = {};\r\nprimitiveSet.POINTS = 0x0000;\r\nprimitiveSet.LINES = 0x0001;\r\nprimitiveSet.LINE_LOOP = 0x0002;\r\nprimitiveSet.LINE_STRIP = 0x0003;\r\nprimitiveSet.TRIANGLES = 0x0004;\r\nprimitiveSet.TRIANGLE_STRIP = 0x0005;\r\nprimitiveSet.TRIANGLE_FAN = 0x0006;\r\n\r\nexport default primitiveSet;\r\n","import utils from './utils';\r\nimport { vec4 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\n\r\n/** @class Plane Operations */\r\nvar Plane = utils.objectInherit(vec4, {\r\n // Many case (frustum, convexity)\r\n // needs to know where from a plane it stands,\r\n // not just boolean intersection\r\n INSIDE: 1,\r\n INTERSECT: 2,\r\n OUTSIDE: 3,\r\n /* Transform the plane */\r\n transformProvidingInverse: function() {\r\n var iplane = Plane.create();\r\n return function(p, m) {\r\n //Matrix.transformVec4PostMult( matrix, plane, iplane );\r\n var x = p[0];\r\n var y = p[1];\r\n var z = p[2];\r\n var w = p[3];\r\n\r\n iplane[0] = m[0] * x + m[1] * y + m[2] * z + m[3] * w;\r\n iplane[1] = m[4] * x + m[5] * y + m[6] * z + m[7] * w;\r\n iplane[2] = m[8] * x + m[9] * y + m[10] * z + m[11] * w;\r\n iplane[3] = m[12] * x + m[13] * y + m[14] * z + m[15] * w;\r\n\r\n Plane.normalizeEquation(iplane);\r\n Plane.copy(iplane, p);\r\n return p;\r\n };\r\n },\r\n\r\n normalizeEquation: function(plane) {\r\n // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.\r\n var inv = 1.0 / Math.sqrt(plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2]);\r\n plane[0] *= inv;\r\n plane[1] *= inv;\r\n plane[2] *= inv;\r\n plane[3] *= inv;\r\n },\r\n /*only the normal Component*/\r\n getNormal: function(plane, result) {\r\n result[0] = plane[0];\r\n result[1] = plane[1];\r\n result[2] = plane[2];\r\n return result;\r\n },\r\n setNormal: function(plane, normal) {\r\n plane[0] = normal[0];\r\n plane[1] = normal[1];\r\n plane[2] = normal[2];\r\n },\r\n /* only the distance getter*/\r\n getDistance: function(plane) {\r\n return plane[3];\r\n },\r\n setDistance: function(plane, distance) {\r\n plane[3] = distance;\r\n },\r\n\r\n /* using the plane equation, compute distance to plane of a point*/\r\n distanceToPlane: function(plane, position) {\r\n return plane[0] * position[0] + plane[1] * position[1] + plane[2] * position[2] + plane[3];\r\n },\r\n\r\n intersectsOrContainsBoundingSphere: function(plane, bSphere) {\r\n if (!bSphere.valid()) return Plane.OUTSIDE;\r\n var position = bSphere.center();\r\n var radius = bSphere.radius();\r\n var d = this.distanceToPlane(plane, position);\r\n if (d < -radius) {\r\n return Plane.OUTSIDE;\r\n } else if (d <= radius) {\r\n return Plane.INTERSECT;\r\n }\r\n return Plane.INSIDE;\r\n },\r\n\r\n instersectsBoundingSphere: function(plane, bSphere) {\r\n return this.intersectsOrContainsBoundingSphere(plane, bSphere) === Plane.INTERSECT;\r\n },\r\n\r\n intersectsOrContainsBoundingBox: (function() {\r\n var retCorner = vec3.create();\r\n return function(plane, bbox) {\r\n var upperBBCorner =\r\n (plane[0] >= 0.0 ? 1 : 0) | (plane[1] >= 0.0 ? 2 : 0) | (plane[2] >= 0.0 ? 4 : 0);\r\n var lowerBBCorner = ~upperBBCorner & 7;\r\n\r\n if (this.distanceToPlane(plane, bbox.corner(lowerBBCorner, retCorner)) > 0.0)\r\n return Plane.INSIDE;\r\n if (this.distanceToPlane(plane, bbox.corner(upperBBCorner, retCorner)) < 0.0)\r\n return Plane.OUTSIDE;\r\n return Plane.INTERSECT; // partially inside\r\n };\r\n })(),\r\n\r\n intersectsBoundingBox: function(plane, bbox, absPlane) {\r\n return this.intersectsOrContainsBoundingBox(plane, bbox, absPlane) === Plane.INTERSECT;\r\n },\r\n\r\n intersectOrContainsVertices: function(plane, vertices) {\r\n var side = -1;\r\n // all points must be on one side only\r\n for (var i = 0; i < vertices.length; i++) {\r\n var d = this.distanceToPlane(plane, vertices[i]);\r\n if (d < 0.0) {\r\n if (side === 1) return Plane.INTERSECT;\r\n side = 2;\r\n } else if (d > 0.0) {\r\n if (side === 2) return Plane.INTERSECT;\r\n side = 1;\r\n } else {\r\n //if ( d === 0.0 )\r\n return Plane.INTERSECT;\r\n }\r\n }\r\n return side > 0 ? Plane.INSIDE : Plane.OUTSIDE;\r\n },\r\n intersectVertices: function(plane, vertices) {\r\n return this.intersectOrContainsVertices(plane, vertices) === Plane.INTERSECT;\r\n }\r\n});\r\n\r\nexport default Plane;","var clamp = function(x, min, max) {\r\n // http://jsperf.com/math-clamp\r\n // http://jsperf.com/clamping-methods/2\r\n return Math.min(max, Math.max(min, x));\r\n};\r\n\r\nvar smoothStep = function(edge0, edge1, x) {\r\n if (x <= edge0) return 0.0;\r\n if (x >= edge1) return 1.0;\r\n var y = (x - edge0) / (edge1 - edge0);\r\n return y * y * (3.0 - 2.0 * y);\r\n};\r\n\r\n// native isNaN is slow (e.g: https://jsperf.com/isnan-performance/2)\r\n// note : native isNaN will return true for undefined but\r\n// this function assume that x is a number\r\nvar fastIsNaN = function(x) {\r\n return x !== x;\r\n};\r\n\r\nexport default {\r\n clamp: clamp,\r\n smoothStep: smoothStep,\r\n isNaN: fastIsNaN\r\n};\r\n","import utils from '../osg/utils';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport Uniform from '../osg/Uniform';\r\n\r\n/**\r\n * SkinningAttribute encapsulate Animation State\r\n * @class SkinningAttribute\r\n * @inherits StateAttribute\r\n */\r\nvar SkinningAttribute = function(disable, boneUniformSize) {\r\n StateAttribute.call(this);\r\n this._enable = !disable;\r\n // optional, if it's not provided, it will fall back to the maximum bone uniform size\r\n // boneUniformSize represents the number of vec4 (uniform) used in the shader for all the bones\r\n this._boneUniformSize = boneUniformSize;\r\n\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nSkinningAttribute.uniforms = {};\r\nSkinningAttribute.maxBoneUniformSize = 1;\r\nSkinningAttribute.maxBoneUniformAllowed = Infinity; // can be overriden by application specific limit on startup (typically gl limit)\r\n\r\nutils.createPrototypeStateAttribute(\r\n SkinningAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Skinning',\r\n\r\n cloneType: function() {\r\n return new SkinningAttribute(true);\r\n },\r\n\r\n getBoneUniformSize: function() {\r\n return this._boneUniformSize !== undefined\r\n ? this._boneUniformSize\r\n : SkinningAttribute.maxBoneUniformSize;\r\n },\r\n\r\n getOrCreateUniforms: function() {\r\n var obj = SkinningAttribute;\r\n var boneSize = this.getBoneUniformSize();\r\n\r\n if (obj.uniforms[boneSize]) return obj.uniforms[boneSize];\r\n\r\n obj.uniforms[boneSize] = {\r\n uBones: Uniform.createFloat4Array('uBones', boneSize)\r\n };\r\n\r\n return obj.uniforms[boneSize];\r\n },\r\n\r\n setMatrixPalette: function(matrixPalette) {\r\n this._matrixPalette = matrixPalette;\r\n // update max bone size\r\n if (this._boneUniformSize === undefined) {\r\n SkinningAttribute.maxBoneUniformSize = Math.max(\r\n SkinningAttribute.maxBoneUniformSize,\r\n matrixPalette.length / 4\r\n );\r\n SkinningAttribute.maxBoneUniformSize = Math.min(\r\n SkinningAttribute.maxBoneUniformAllowed,\r\n SkinningAttribute.maxBoneUniformSize\r\n );\r\n }\r\n },\r\n\r\n getMatrixPalette: function() {\r\n return this._matrixPalette;\r\n },\r\n\r\n // need a isEnabled to let the ShaderGenerator to filter\r\n // StateAttribute from the shader compilation\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = true;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n // bone uniform size is hashed because the size of uniform is statically declared in the shader\r\n return this.getTypeMember() + this.getBoneUniformSize() + this.isEnabled();\r\n },\r\n\r\n apply: function() {\r\n if (!this._enable) return;\r\n\r\n this.getOrCreateUniforms()\r\n .uBones.getInternalArray()\r\n .set(this._matrixPalette);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'SkinningAttribute'\r\n);\r\n\r\nexport default SkinningAttribute;\r\n","// user performance if available or fallback\r\n\r\nvar now = (function() {\r\n var w = window || global; // eslint-disable-line\r\n\r\n // if no window.performance\r\n if (w.performance === undefined) {\r\n return function() {\r\n return Date.now();\r\n };\r\n }\r\n\r\n var fn =\r\n w.performance.now ||\r\n w.performance.mozNow ||\r\n w.performance.msNow ||\r\n w.performance.oNow ||\r\n w.performance.webkitNow ||\r\n function() {\r\n return Date.now();\r\n };\r\n return function() {\r\n return fn.apply(w.performance, arguments);\r\n };\r\n})();\r\n\r\nvar Timer = function() {};\r\n\r\nTimer.instance = function() {\r\n if (!Timer._instance) Timer._instance = new Timer();\r\n\r\n return Timer._instance;\r\n};\r\n\r\nTimer.tick = now;\r\n\r\nTimer.prototype = {\r\n // delta in seconds\r\n deltaS: function(t0, t1) {\r\n return (t1 - t0) / 1000.0;\r\n },\r\n\r\n // delta in milliseconds\r\n deltaM: function(t0, t1) {\r\n return t1 - t0;\r\n },\r\n\r\n tick: function() {\r\n return now();\r\n }\r\n};\r\n\r\nexport default Timer;\r\n","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar BillboardAttribute = function() {\r\n StateAttribute.call(this);\r\n this._attributeEnable = false;\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n BillboardAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Billboard',\r\n\r\n cloneType: function() {\r\n return new BillboardAttribute();\r\n },\r\n\r\n setEnabled: function(state) {\r\n this._attributeEnable = state;\r\n },\r\n\r\n isEnabled: function() {\r\n return this._attributeEnable;\r\n },\r\n\r\n apply: function() {}\r\n }),\r\n 'osg',\r\n 'Billboard'\r\n);\r\n\r\nexport default BillboardAttribute;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar ColorMask = function(red, green, blue, alpha) {\r\n StateAttribute.call(this);\r\n this._red = true;\r\n this._green = true;\r\n this._blue = true;\r\n this._alpha = true;\r\n\r\n if (red !== undefined && green !== undefined && blue !== undefined)\r\n this.setMask(red, green, blue, alpha);\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n ColorMask,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'ColorMask',\r\n cloneType: function() {\r\n return new ColorMask();\r\n },\r\n setMask: function(red, green, blue, alpha) {\r\n this._red = !!red;\r\n this._green = !!green;\r\n this._blue = !!blue;\r\n this._alpha = !!alpha;\r\n },\r\n apply: function(state) {\r\n state.applyColorMask(this);\r\n }\r\n }),\r\n 'osg',\r\n 'ColorMask'\r\n);\r\n\r\nexport default ColorMask;","import { mat4 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\n\r\nvar EllipsoidModel = function() {\r\n this._radiusEquator = EllipsoidModel.WGS_84_RADIUS_EQUATOR;\r\n this._radiusPolar = EllipsoidModel.WGS_84_RADIUS_POLAR;\r\n this.computeCoefficients();\r\n};\r\n\r\nEllipsoidModel.WGS_84_RADIUS_EQUATOR = 6378137.0;\r\nEllipsoidModel.WGS_84_RADIUS_POLAR = 6356752.3142;\r\n\r\nEllipsoidModel.prototype = {\r\n setRadiusEquator: function(radius) {\r\n this._radiusEquator = radius;\r\n this.computeCoefficients();\r\n },\r\n getRadiusEquator: function() {\r\n return this._radiusEquator;\r\n },\r\n setRadiusPolar: function(radius) {\r\n this._radiusPolar = radius;\r\n this.computeCoefficients();\r\n },\r\n getRadiusPolar: function() {\r\n return this._radiusPolar;\r\n },\r\n convertLatLongHeightToXYZ: function(latitude, longitude, height, result) {\r\n var sinLatitude = Math.sin(latitude);\r\n var cosLatitude = Math.cos(latitude);\r\n var N =\r\n this._radiusEquator /\r\n Math.sqrt(1.0 - this._eccentricitySquared * sinLatitude * sinLatitude);\r\n var X = (N + height) * cosLatitude * Math.cos(longitude);\r\n var Y = (N + height) * cosLatitude * Math.sin(longitude);\r\n var Z = (N * (1.0 - this._eccentricitySquared) + height) * sinLatitude;\r\n result[0] = X;\r\n result[1] = Y;\r\n result[2] = Z;\r\n return result;\r\n },\r\n convertXYZToLatLongHeight: function(X, Y, Z, result) {\r\n // http://www.colorado.edu/geography/gcraft/notes/datum/gif/xyzllh.gif\r\n var p = Math.sqrt(X * X + Y * Y);\r\n var theta = Math.atan2(Z * this._radiusEquator, p * this._radiusPolar);\r\n var eDashSquared =\r\n (this._radiusEquator * this._radiusEquator - this._radiusPolar * this._radiusPolar) /\r\n (this._radiusPolar * this._radiusPolar);\r\n\r\n var sinTheta = Math.sin(theta);\r\n var cosTheta = Math.cos(theta);\r\n\r\n var latitude = Math.atan(\r\n (Z + eDashSquared * this._radiusPolar * sinTheta * sinTheta * sinTheta) /\r\n (p -\r\n this._eccentricitySquared *\r\n this._radiusEquator *\r\n cosTheta *\r\n cosTheta *\r\n cosTheta)\r\n );\r\n var longitude = Math.atan2(Y, X);\r\n\r\n var sinLatitude = Math.sin(latitude);\r\n var N =\r\n this._radiusEquator /\r\n Math.sqrt(1.0 - this._eccentricitySquared * sinLatitude * sinLatitude);\r\n\r\n var cosLat = Math.cos(latitude);\r\n if (cosLat === 0) cosLat = 1;\r\n var height = p / cosLat - N;\r\n result[0] = latitude;\r\n result[1] = longitude;\r\n result[2] = height;\r\n return result;\r\n },\r\n computeLocalUpVector: function(X, Y, Z) {\r\n // Note latitude is angle between normal to ellipsoid surface and XY-plane\r\n var latitude, longitude;\r\n var coord = this.convertXYZToLatLongHeight(X, Y, Z, vec3.create());\r\n latitude = coord[0];\r\n longitude = coord[1];\r\n\r\n // Compute up vector\r\n return [\r\n Math.cos(longitude) * Math.cos(latitude),\r\n Math.sin(longitude) * Math.cos(latitude),\r\n Math.sin(latitude)\r\n ];\r\n },\r\n isWGS84: function() {\r\n return (\r\n this._radiusEquator === EllipsoidModel.WGS_84_RADIUS_EQUATOR &&\r\n this._radiusPolar === EllipsoidModel.WGS_84_RADIUS_POLAR\r\n );\r\n },\r\n\r\n computeCoefficients: function() {\r\n var flattening = (this._radiusEquator - this._radiusPolar) / this._radiusEquator;\r\n this._eccentricitySquared = 2.0 * flattening - flattening * flattening;\r\n },\r\n computeLocalToWorldTransformFromLatLongHeight: function(latitude, longitude, height, result) {\r\n var pos = this.convertLatLongHeightToXYZ(latitude, longitude, height, result);\r\n mat4.fromTranslation(result, pos);\r\n this.computeCoordinateFrame(latitude, longitude, result);\r\n return result;\r\n },\r\n computeLocalToWorldTransformFromXYZ: function(X, Y, Z) {\r\n var lla = this.convertXYZToLatLongHeight(X, Y, Z, vec3.create());\r\n var m = mat4.fromTranslation(mat4.create(), vec3.fromValues(X, Y, Z));\r\n this.computeCoordinateFrame(lla[0], lla[1], m);\r\n return m;\r\n },\r\n computeCoordinateFrame: (function() {\r\n var up = vec3.create();\r\n var east = vec3.create();\r\n var north = vec3.create();\r\n return function(latitude, longitude, localToWorld) {\r\n // Compute up vector\r\n up[0] = Math.cos(longitude) * Math.cos(latitude);\r\n up[1] = Math.sin(longitude) * Math.cos(latitude);\r\n up[2] = Math.sin(latitude);\r\n\r\n // Compute east vector\r\n east[0] = -Math.sin(longitude);\r\n east[1] = -Math.cos(longitude);\r\n\r\n // Compute north vector = outer product up x east\r\n vec3.cross(north, up, east);\r\n\r\n // set matrix\r\n mat4.set(\r\n localToWorld,\r\n east[0],\r\n east[1],\r\n east[2],\r\n 0,\r\n north[0],\r\n north[1],\r\n north[2],\r\n 0,\r\n up[0],\r\n up[1],\r\n up[2],\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n );\r\n };\r\n })()\r\n};\r\n\r\nexport default EllipsoidModel;","import P from 'bluebird';\r\nimport utils from './utils';\r\nimport Image from './Image';\r\n\r\nvar ImageStream = function(video) {\r\n Image.call(this, video);\r\n this._canPlayDefered = undefined;\r\n};\r\n\r\nImageStream.PAUSE = 0;\r\nImageStream.PLAYING = 1;\r\n\r\nutils.createPrototypeObject(\r\n ImageStream,\r\n utils.objectInherit(Image.prototype, {\r\n isDirty: function() {\r\n return this._status === ImageStream.PLAYING; // video is dirty if playing\r\n },\r\n\r\n setImage: function(video) {\r\n Image.prototype.setImage.call(this, video);\r\n\r\n this._status = ImageStream.STOP;\r\n\r\n // event at the end of the stream\r\n video.addEventListener(\r\n 'ended',\r\n function() {\r\n if (!this._imageObject.loop) this.stop();\r\n }.bind(this),\r\n true\r\n );\r\n\r\n this.dirty();\r\n },\r\n\r\n setLooping: function(bool) {\r\n this._imageObject.loop = bool;\r\n },\r\n\r\n play: function() {\r\n this._imageObject.play();\r\n this._status = ImageStream.PLAYING;\r\n },\r\n\r\n stop: function() {\r\n this._imageObject.pause();\r\n this._status = ImageStream.PAUSE;\r\n },\r\n\r\n whenReady: function() {\r\n if (!this._imageObject) {\r\n return P.reject();\r\n }\r\n var that = this;\r\n return new P(function(resolve) {\r\n if (!that._canPlayDefered) {\r\n that._canPlayDefered = resolve;\r\n // resolve directly if the event is already fired\r\n if (that._imageObject.readyState > 3) that._canPlayDefered(that);\r\n else\r\n that._imageObject.addEventListener(\r\n 'canplaythrough',\r\n that._canPlayDefered.bind(that._canPlayDefered, that),\r\n true\r\n );\r\n }\r\n });\r\n }\r\n }),\r\n 'osg',\r\n 'ImageStream'\r\n);\r\n\r\nexport default ImageStream;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar LineWidth = function(lineWidth) {\r\n StateAttribute.call(this);\r\n this.lineWidth = 1.0;\r\n if (lineWidth !== undefined) {\r\n this.lineWidth = lineWidth;\r\n }\r\n};\r\nutils.createPrototypeStateAttribute(\r\n LineWidth,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'LineWidth',\r\n cloneType: function() {\r\n return new LineWidth();\r\n },\r\n apply: function(state) {\r\n state.getGraphicContext().lineWidth(this.lineWidth);\r\n }\r\n }),\r\n 'osg',\r\n 'LineWidth'\r\n);\r\n\r\nexport default LineWidth;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport Uniform from './Uniform';\r\n\r\nvar PointSizeAttribute = function(disable) {\r\n StateAttribute.call(this);\r\n\r\n this._enable = !disable;\r\n this._pointSize = 1.0;\r\n // careful with this option if there is lines/triangles under the stateset\r\n this._circleShape = false;\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n PointSizeAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'PointSize',\r\n\r\n cloneType: function() {\r\n return new PointSizeAttribute(true);\r\n },\r\n\r\n setCircleShape: function(bool) {\r\n this._circleShape = bool;\r\n this._dirtyHash = true;\r\n },\r\n\r\n isCircleShape: function() {\r\n return this._circleShape;\r\n },\r\n\r\n setEnabled: function(state) {\r\n this._enable = state;\r\n this._dirtyHash = true;\r\n },\r\n\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n setPointSize: function(size) {\r\n this._pointSize = size;\r\n },\r\n\r\n getOrCreateUniforms: function() {\r\n var obj = PointSizeAttribute;\r\n if (obj.uniforms) return obj.uniforms;\r\n\r\n obj.uniforms = {\r\n pointSize: Uniform.createFloat(1.0, 'uPointSize')\r\n };\r\n\r\n return obj.uniforms;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n return (\r\n this.getTypeMember() +\r\n (this.isEnabled() ? '1' : '0') +\r\n (this._circleShape ? '1' : '0')\r\n );\r\n },\r\n\r\n apply: function() {\r\n if (!this._enable) return;\r\n\r\n var uniforms = this.getOrCreateUniforms();\r\n uniforms.pointSize.setFloat(this._pointSize);\r\n }\r\n }),\r\n 'osg',\r\n 'PointSizeAttribute'\r\n);\r\n\r\nexport default PointSizeAttribute;","import utils from './utils';\r\nimport Image from './Image';\r\nimport notify from './notify';\r\nimport Texture from './Texture';\r\n\r\n/**\r\n * TextureCubeMap\r\n * @class TextureCubeMap\r\n * @inherits Texture\r\n */\r\nvar TextureCubeMap = function() {\r\n Texture.call(this);\r\n this._images = {};\r\n\r\n // pre allocated all textures faces slots\r\n for (var i = 0; i < 6; i++) {\r\n this._images[Texture.TEXTURE_CUBE_MAP_POSITIVE_X + i] = new Image();\r\n }\r\n};\r\n\r\n/** @lends TextureCubeMap.prototype */\r\nutils.createPrototypeStateAttribute(\r\n TextureCubeMap,\r\n utils.objectInherit(Texture.prototype, {\r\n setDefaultParameters: function() {\r\n Texture.prototype.setDefaultParameters.call(this);\r\n this._textureTarget = Texture.TEXTURE_CUBE_MAP;\r\n\r\n this._flipY = false;\r\n },\r\n\r\n invalidate: function() {\r\n Texture.prototype.invalidate.call(this);\r\n for (\r\n var i = Texture.TEXTURE_CUBE_MAP_POSITIVE_X; i < Texture.TEXTURE_CUBE_MAP_POSITIVE_X + 6; i++\r\n ) {\r\n var faceImage = this._images[i];\r\n if (this._images[Texture.TEXTURE_CUBE_MAP_POSITIVE_X].getImage()) {\r\n faceImage.dirty();\r\n }\r\n }\r\n this.dirty();\r\n },\r\n\r\n cloneType: function() {\r\n return new TextureCubeMap();\r\n },\r\n\r\n setImage: function(imageFace, img, imageFormat) {\r\n var face = imageFace;\r\n\r\n if (typeof face === 'string') face = Texture[face];\r\n\r\n this._images[face].setImage(img, imageFormat);\r\n\r\n this.setImageFormat(imageFormat);\r\n this.setTextureSize(this._images[face].getWidth(), this._images[face].getHeight());\r\n\r\n this._textureNull = false;\r\n this.dirty();\r\n },\r\n\r\n getImage: function(face) {\r\n return this._images[face].getImage();\r\n },\r\n\r\n initCubemapContent: function(gl) {\r\n var internalFormat = this._internalFormat;\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_NEGATIVE_X,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_Y,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_Z,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n null\r\n );\r\n\r\n return true;\r\n },\r\n\r\n // handle mipmap logic, if images for mipmap are provided or not\r\n generateMipmap: function(gl, target) {\r\n if (!this.hasMipmapFilter()) return;\r\n\r\n // manual mipmap provided\r\n if (this._images[Texture.TEXTURE_CUBE_MAP_POSITIVE_X].hasMipmap()) {\r\n for (var face = 0; face < 6; face++) {\r\n var faceImage = this._images[Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face];\r\n if (!faceImage.hasMipmap()) {\r\n notify.error('mipmap not set correctly for TextureCubemap');\r\n }\r\n\r\n var internalFormat = this._internalFormat;\r\n for (var level = 1; level < faceImage.getMipmap().length; level++) {\r\n var size = faceImage.getMipmap()[level].getWidth();\r\n\r\n this.applyTexImage2D(\r\n gl,\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + face,\r\n level,\r\n internalFormat,\r\n size,\r\n size,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n faceImage.getMipmap()[level].getImage()\r\n );\r\n }\r\n }\r\n } else {\r\n // automatic mipmap\r\n gl.generateMipmap(target);\r\n }\r\n\r\n this._dirtyMipmap = false;\r\n },\r\n\r\n applyImageTarget: function(gl, internalFormat, target) {\r\n var faceImage = this._images[target];\r\n\r\n if (!faceImage.getImage()) return 0;\r\n\r\n if (!faceImage.isReady()) return 0;\r\n\r\n if (!faceImage.isDirty()) return 1;\r\n\r\n this.setTextureSize(faceImage.getWidth(), faceImage.getHeight());\r\n\r\n faceImage.setDirty(false);\r\n\r\n if (faceImage.isTypedArray()) {\r\n this.applyTexImage2D(\r\n gl,\r\n target,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n internalFormat,\r\n this._type,\r\n faceImage.getImage()\r\n );\r\n } else {\r\n this.applyTexImage2D(\r\n gl,\r\n target,\r\n 0,\r\n internalFormat,\r\n internalFormat,\r\n this._type,\r\n faceImage.getImage()\r\n );\r\n }\r\n\r\n // release here only if no mipmap\r\n if (this._unrefImageDataAfterApply && !(this.hasMipmap() && faceImage.hasMipmap())) {\r\n faceImage.release();\r\n }\r\n\r\n return 1;\r\n },\r\n\r\n initCubemapContentImage: function(gl) {\r\n var internalFormat = this._internalFormat;\r\n var valid = 0;\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_X);\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_X);\r\n\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_Y);\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y);\r\n\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_POSITIVE_Z);\r\n valid += this.applyImageTarget(gl, internalFormat, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z);\r\n\r\n if (valid === 6) return true;\r\n\r\n return false;\r\n },\r\n\r\n apply: function(state) {\r\n var gl = state.getGraphicContext();\r\n // if need to release the texture\r\n if (this._dirtyTextureObject) {\r\n this.releaseGLObjects();\r\n this.setGraphicContext(gl);\r\n }\r\n\r\n if (this._textureObject !== undefined && !this.isDirty()) {\r\n this._textureObject.bind(gl);\r\n\r\n // If we have modified the texture via Rtt or texSubImage2D and _need_ updated mipmaps,\r\n // then we must regenerate the mipmaps explicitely.\r\n // In all other cases, don't set this flag because it can be costly\r\n if (this.isDirtyMipmap()) {\r\n this.generateMipmap(gl, this._textureTarget);\r\n }\r\n } else if (this._textureNull) {\r\n gl.bindTexture(this._textureTarget, null);\r\n } else {\r\n if (!this._textureObject) {\r\n // must be called before init\r\n this.computeTextureFormat();\r\n\r\n this.init(state);\r\n }\r\n this._textureObject.bind(gl);\r\n\r\n var valid;\r\n\r\n // no images it's must be a cubemap filled from rtt\r\n if (!this._images[Texture.TEXTURE_CUBE_MAP_POSITIVE_X].getImage()) {\r\n valid = this.initCubemapContent(gl);\r\n } else {\r\n valid = this.initCubemapContentImage(gl);\r\n }\r\n\r\n if (valid) {\r\n this._dirty = false;\r\n this.applyFilterParameter(gl, this._textureTarget);\r\n this.generateMipmap(gl, this._textureTarget);\r\n }\r\n } // render to cubemap not yet implemented\r\n }\r\n }),\r\n 'osg',\r\n 'TextureCubeMap'\r\n);\r\n\r\nexport default TextureCubeMap;","import primitiveSet from './primitiveSet';\r\nimport DrawElements from './DrawElements';\r\nimport DrawArrays from './DrawArrays';\r\n\r\n// This class can be used to visit all the triangles of a geometry\r\nvar TriangleIndexFunctor = function() {};\r\n\r\nvar functorDrawElements = (TriangleIndexFunctor.functorDrawElements = []);\r\nvar functorDrawArrays = (TriangleIndexFunctor.functorDrawArrays = []);\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLES] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; i += 3) {\r\n cb(indexes[i], indexes[i + 1], indexes[i + 2]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_STRIP] = function(offset, count, indexes, cb) {\r\n for (var i = 2, j = offset; i < count; ++i, ++j) {\r\n if (i % 2) cb(indexes[j], indexes[j + 2], indexes[j + 1]);\r\n else cb(indexes[j], indexes[j + 1], indexes[j + 2]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_FAN] = function(offset, count, indexes, cb) {\r\n var first = indexes[offset];\r\n for (var i = 2, j = offset + 1; i < count; ++i, ++j) {\r\n cb(first, indexes[j], indexes[j + 1]);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLES] = function(first, count, cb) {\r\n for (var i = 2, pos = first; i < count; i += 3, pos += 3) {\r\n cb(pos, pos + 1, pos + 2);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_STRIP] = function(first, count, cb) {\r\n for (var i = 2, pos = first; i < count; ++i, ++pos) {\r\n if (i % 2) cb(pos, pos + 2, pos + 1);\r\n else cb(pos, pos + 1, pos + 2);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_FAN] = function(first, count, cb) {\r\n for (var i = 2, pos = first + 1; i < count; ++i, ++pos) {\r\n cb(first, pos, pos + 1);\r\n }\r\n};\r\n\r\nTriangleIndexFunctor.prototype = {\r\n // You feed it with a callback that will be called for each triangle\r\n // (with the 3 indexes of vertices as arguments)\r\n init: function(geom, cb) {\r\n this._geom = geom;\r\n this._cb = cb;\r\n },\r\n\r\n apply: function() {\r\n var geom = this._geom;\r\n var primitives = geom.getPrimitiveSetList();\r\n if (!primitives) return;\r\n\r\n var cb = this._cb;\r\n var cbFunctor;\r\n\r\n var nbPrimitives = primitives.length;\r\n for (var i = 0; i < nbPrimitives; i++) {\r\n var primitive = primitives[i];\r\n if (primitive instanceof DrawElements) {\r\n cbFunctor = functorDrawElements[primitive.getMode()];\r\n if (cbFunctor) {\r\n var indexes = primitive.indices.getElements();\r\n cbFunctor(\r\n primitive.getFirst() / indexes.BYTES_PER_ELEMENT,\r\n primitive.getCount(),\r\n indexes,\r\n cb\r\n );\r\n }\r\n } else if (primitive instanceof DrawArrays) {\r\n cbFunctor = functorDrawArrays[primitive.getMode()];\r\n if (cbFunctor) {\r\n cbFunctor(primitive.getFirst(), primitive.getCount(), cb);\r\n }\r\n }\r\n }\r\n }\r\n};\r\n\r\nexport default TriangleIndexFunctor;","import AutoTransform from './AutoTransform';\r\nimport BillboardAttribute from './BillboardAttribute';\r\nimport BlendColor from './BlendColor';\r\nimport BlendFunc from './BlendFunc';\r\nimport BoundingBox from './BoundingBox';\r\nimport BoundingSphere from './BoundingSphere';\r\nimport BufferArray from './BufferArray';\r\nimport BufferArrayProxy from './BufferArrayProxy';\r\nimport Camera from './Camera';\r\nimport ColorMask from './ColorMask';\r\nimport ComputeBoundsVisitor from './ComputeBoundsVisitor';\r\nimport ComputeMatrixFromNodePath from './computeMatrixFromNodePath';\r\nimport CullFace from './CullFace';\r\nimport FrontFace from './FrontFace';\r\nimport CullingSet from './CullingSet';\r\nimport CullSettings from './CullSettings';\r\nimport CullStack from './CullStack';\r\nimport CullVisitor from './CullVisitor';\r\nimport Depth from './Depth';\r\nimport DrawArrayLengths from './DrawArrayLengths';\r\nimport DrawArrays from './DrawArrays';\r\nimport DrawElements from './DrawElements';\r\nimport EllipsoidModel from './EllipsoidModel';\r\nimport FrameBufferObject from './FrameBufferObject';\r\nimport FrameStamp from './FrameStamp';\r\nimport Geometry from './Geometry';\r\nimport { glm } from './glMatrix';\r\nimport GLObject from './GLObject';\r\nimport Image from './Image';\r\nimport ImageStream from './ImageStream';\r\nimport KdTree from './KdTree';\r\nimport KdTreeBuilder from './KdTreeBuilder';\r\nimport Light from './Light';\r\nimport LightSource from './LightSource';\r\nimport LineWidth from './LineWidth';\r\nimport Lod from './Lod';\r\nimport Material from './Material';\r\nimport osgjsMath from './math';\r\nimport MatrixTransform from './MatrixTransform';\r\nimport PooledResource from './PooledResource';\r\nimport PooledArray from './PooledArray';\r\nimport PooledMap from './PooledMap';\r\nimport Node from './Node';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport notify from './notify';\r\nimport Object from './Object';\r\nimport Options from './Options';\r\nimport PagedLOD from './PagedLOD';\r\nimport Polytope from './Polytope';\r\nimport PointSizeAttribute from './PointSizeAttribute';\r\nimport Plane from './Plane';\r\nimport primitiveFunctor from './primitiveFunctor';\r\nimport primitiveIndexFunctor from './primitiveIndexFunctor';\r\nimport primitiveSet from './primitiveSet';\r\nimport Program from './Program';\r\nimport Projection from './Projection';\r\nimport RenderBin from './RenderBin';\r\nimport RenderLeaf from './RenderLeaf';\r\nimport RenderStage from './RenderStage';\r\nimport Shader from './Shader';\r\nimport Shape from './shape';\r\nimport StackObjectPairPool from './StackObjectPairPool';\r\nimport State from './State';\r\nimport StateAttribute from './StateAttribute';\r\nimport StateGraph from './StateGraph';\r\nimport StateSet from './StateSet';\r\nimport Switch from './Switch';\r\nimport Texture from './Texture';\r\nimport TextureCubeMap from './TextureCubeMap';\r\nimport Transform from './Transform';\r\nimport TriangleIndexFunctor from './TriangleIndexFunctor';\r\nimport Uniform from './Uniform';\r\nimport UpdateVisitor from './UpdateVisitor';\r\nimport utils from './utils';\r\nimport Viewport from './Viewport';\r\nimport Scissor from './Scissor';\r\nimport TransformEnums from './transformEnums';\r\nimport Timer from './Timer';\r\nimport TimerGPU from './TimerGPU';\r\nimport VertexArrayObject from './VertexArrayObject';\r\nimport WebGLCaps from './WebGLCaps';\r\n\r\nvar osg = {};\r\nosg.AutoTransform = AutoTransform;\r\nosg.BillboardAttribute = BillboardAttribute;\r\nosg.BlendColor = BlendColor;\r\nosg.BlendFunc = BlendFunc;\r\nosg.BoundingBox = BoundingBox;\r\nosg.BoundingSphere = BoundingSphere;\r\nosg.BufferArray = BufferArray;\r\nosg.BufferArrayProxy = BufferArrayProxy;\r\nosg.ColorMask = ColorMask;\r\nosg.Camera = Camera;\r\nosg.ColorMask = ColorMask;\r\nosg.ComputeBoundsVisitor = ComputeBoundsVisitor;\r\nutils.objectMix(osg, ComputeMatrixFromNodePath);\r\nosg.CullFace = CullFace;\r\nosg.FrontFace = FrontFace;\r\nosg.CullingSet = CullingSet;\r\nosg.CullSettings = CullSettings;\r\nosg.CullStack = CullStack;\r\nosg.CullVisitor = CullVisitor;\r\nosg.Depth = Depth;\r\nosg.DrawArrayLengths = DrawArrayLengths;\r\nosg.DrawArrays = DrawArrays;\r\nosg.DrawElements = DrawElements;\r\nosg.EllipsoidModel = EllipsoidModel;\r\nosg.WGS_84_RADIUS_EQUATOR = EllipsoidModel.WGS_84_RADIUS_EQUATOR;\r\nosg.WGS_84_RADIUS_POLAR = EllipsoidModel.WGS_84_RADIUS_POLAR;\r\nosg.FrameBufferObject = FrameBufferObject;\r\nosg.FrameStamp = FrameStamp;\r\nosg.Geometry = Geometry;\r\nosg.GLObject = GLObject;\r\nosg.Image = Image;\r\nosg.ImageStream = ImageStream;\r\nosg.KdTree = KdTree;\r\nosg.KdTreeBuilder = KdTreeBuilder;\r\nosg.Light = Light;\r\nosg.LightSource = LightSource;\r\nosg.LineWidth = LineWidth;\r\nosg.Lod = Lod;\r\nosg.Material = Material;\r\nutils.objectMix(osg, osgjsMath);\r\nosg.MatrixTransform = MatrixTransform;\r\nosg.PooledResource = PooledResource;\r\nosg.PooledArray = PooledArray;\r\nosg.PooledMap = PooledMap;\r\nosg.Node = Node;\r\nosg.NodeVisitor = NodeVisitor;\r\nutils.objectMix(osg, notify);\r\nosg.Object = Object;\r\nosg.Options = Options;\r\nosg.PagedLOD = PagedLOD;\r\nosg.Plane = Plane;\r\nosg.PointSizeAttribute = PointSizeAttribute;\r\nosg.Polytope = Polytope;\r\nosg.primitiveSet = primitiveSet;\r\nosg.primitiveFunctor = primitiveFunctor;\r\nosg.primitiveIndexFunctor = primitiveIndexFunctor;\r\nosg.Program = Program;\r\nosg.Projection = Projection;\r\nosg.RenderBin = RenderBin;\r\nosg.RenderLeaf = RenderLeaf;\r\nosg.RenderStage = RenderStage;\r\nosg.Shader = Shader;\r\nutils.objectMix(osg, Shape);\r\nosg.StackObjectPairPool = StackObjectPairPool;\r\nosg.State = State;\r\nosg.StateAttribute = StateAttribute;\r\nosg.StateGraph = StateGraph;\r\nosg.StateSet = StateSet;\r\nosg.Scissor = Scissor;\r\nosg.Switch = Switch;\r\nosg.Texture = Texture;\r\nosg.TextureCubeMap = TextureCubeMap;\r\nosg.Transform = Transform;\r\nosg.TriangleIndexFunctor = TriangleIndexFunctor;\r\nosg.Uniform = Uniform;\r\nosg.UpdateVisitor = UpdateVisitor;\r\nutils.objectMix(osg, utils);\r\nosg.Viewport = Viewport;\r\nosg.VertexArrayObject = VertexArrayObject;\r\nosg.vec2 = glm.vec2;\r\nosg.vec3 = glm.vec3;\r\nosg.vec4 = glm.vec4;\r\nosg.quat = glm.quat;\r\nosg.mat3 = glm.mat3;\r\nosg.mat4 = glm.mat4;\r\n\r\nosg.Transform.RELATIVE_RF = TransformEnums.RELATIVE_RF;\r\nosg.Transform.ABSOLUTE_RF = TransformEnums.ABSOLUTE_RF;\r\nosg.Timer = Timer;\r\nosg.TimerGPU = TimerGPU;\r\nosg.WebGLCaps = WebGLCaps;\r\n\r\nexport default osg;\r\n","var PooledResource = function(createFunction) {\r\n this._createFunction = createFunction;\r\n this._pool = [];\r\n this._length = 0;\r\n};\r\n\r\nPooledResource.prototype = {\r\n clean: function() {\r\n this._pool.length = 0;\r\n this._length = 0;\r\n },\r\n getLength: function() {\r\n return this._length;\r\n },\r\n reset: function() {\r\n this._length = 0;\r\n },\r\n /**\r\n * Creates or returns an existing object.\r\n * The returned object could contain invalid data from previous object values. User is responsible to reset/init the returned object for its (re)use.\r\n */\r\n getOrCreateObject: function() {\r\n var obj;\r\n if (this._length === this._pool.length) {\r\n obj = this._createFunction();\r\n this._pool.push(obj);\r\n } else {\r\n obj = this._pool[this._length];\r\n }\r\n this._length++;\r\n return obj;\r\n },\r\n forEach: function(func) {\r\n for (var i = 0; i < this._length; i++) func(this._pool[i]);\r\n }\r\n};\r\n\r\nexport default PooledResource;\r\n","import primitiveSet from './primitiveSet';\r\nimport DrawElements from './DrawElements';\r\nimport DrawArrays from './DrawArrays';\r\n\r\n/**\r\n * PrimitiveIndexFunctor emulates the TemplatePrimitiveIndexFunctor class in OSG and can\r\n * be used to get access to the vertices that compose the things drawn by osgjs.\r\n *\r\n * You have to feed it with an object that references 3 callbacks :\r\n *\r\n * var myObject = {\r\n * operatorPoint : function ( v ) { }, // Do your point operations here\r\n * operatorLine : function ( v1, v2 ){ }, // Do you line operations here\r\n * operatorTriangle : function ( v1, v2, v3 ) { } // Do your triangle operations here\r\n * };\r\n *\r\n */\r\n\r\nvar functorDrawElements = [];\r\nvar functorDrawArrays = [];\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLES] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; i += 3) {\r\n cb.operatorTriangle(indexes[i], indexes[i + 1], indexes[i + 2]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_STRIP] = function(offset, count, indexes, cb) {\r\n for (var i = 2, j = offset; i < count; ++i, ++j) {\r\n if (i % 2) cb.operatorTriangle(indexes[j], indexes[j + 2], indexes[j + 1]);\r\n else cb.operatorTriangle(indexes[j], indexes[j + 1], indexes[j + 2]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.TRIANGLE_FAN] = function(offset, count, indexes, cb) {\r\n var first = indexes[offset];\r\n for (var i = 2, j = offset + 1; i < count; ++i, ++j) {\r\n cb.operatorTriangle(first, indexes[j], indexes[j + 1]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.POINTS] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; ++i) {\r\n cb.operatorPoint(indexes[i]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.LINES] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; i += 2) {\r\n cb.operatorLine(indexes[i], indexes[i + 1]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.LINE_STRIP] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; ++i) {\r\n cb.operatorLine(indexes[i], indexes[i + 1]);\r\n }\r\n};\r\n\r\nfunctorDrawElements[primitiveSet.LINE_LOOP] = function(offset, count, indexes, cb) {\r\n var end = offset + count;\r\n for (var i = offset; i < end; ++i) {\r\n cb.operatorLine(indexes[i], indexes[i + 1]);\r\n }\r\n cb.operatorLine(indexes[indexes.length - 1], indexes[0]);\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLES] = function(first, count, cb) {\r\n for (var i = 2, pos = first; i < count; i += 3, pos += 3) {\r\n cb.operatorTriangle(pos, pos + 1, pos + 2);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_STRIP] = function(first, count, cb) {\r\n for (var i = 2, pos = first; i < count; ++i, ++pos) {\r\n if (i % 2) cb.operatorTriangle(pos, pos + 2, pos + 1);\r\n else cb.operatorTriangle(pos, pos + 1, pos + 2);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.TRIANGLE_FAN] = function(first, count, cb) {\r\n for (var i = 2, pos = first + 1; i < count; ++i, ++pos) {\r\n cb.operatorTriangle(first, pos, pos + 1);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.POINTS] = function(first, count, cb) {\r\n for (var i = 0, pos = first; i < count; ++i, ++pos) {\r\n cb.operatorPoint(pos);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.LINES] = function(first, count, cb) {\r\n for (var i = 1, pos = first; i < count; i += 2, pos += 2) {\r\n cb.operatorLine(pos, pos + 1);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.LINE_STRIP] = function(first, count, cb) {\r\n for (var i = 1, pos = first; i < count; ++i, ++pos) {\r\n cb.operatorLine(pos, pos + 1);\r\n }\r\n};\r\n\r\nfunctorDrawArrays[primitiveSet.LINE_LOOP] = function(first, count, cb) {\r\n for (var i = 1, pos = first; i < count; ++i, ++pos) {\r\n cb.operatorLine(pos, pos + 1);\r\n }\r\n cb.operatorLine(first + count - 1, first);\r\n};\r\n\r\nvar primitiveIndexFunctor = function(geom, cb) {\r\n var primitives = geom.getPrimitiveSetList();\r\n if (!primitives) return;\r\n\r\n var cbFunctor;\r\n\r\n var nbPrimitives = primitives.length;\r\n for (var i = 0; i < nbPrimitives; i++) {\r\n var primitive = primitives[i];\r\n if (primitive instanceof DrawElements) {\r\n cbFunctor = functorDrawElements[primitive.getMode()];\r\n if (cbFunctor) {\r\n var indexes = primitive.indices.getElements();\r\n cbFunctor(\r\n primitive.getFirst() / indexes.BYTES_PER_ELEMENT,\r\n primitive.getCount(),\r\n indexes,\r\n cb\r\n );\r\n }\r\n } else if (primitive instanceof DrawArrays) {\r\n cbFunctor = functorDrawArrays[primitive.getMode()];\r\n if (cbFunctor) {\r\n cbFunctor(primitive.getFirst(), primitive.getCount(), cb);\r\n }\r\n }\r\n }\r\n};\r\n\r\nexport default primitiveIndexFunctor;\r\n","import Object from './Object';\r\nimport StateAttribute from './StateAttribute';\r\nimport utils from './utils';\r\n\r\n/** Stores a set of modes and attributes which represent a set of OpenGL state.\r\n * Notice that a \\c StateSet contains just a subset of the whole OpenGL state.\r\n * <p>In OSG, each \\c Drawable and each \\c Node has a reference to a\r\n * \\c StateSet. These <tt>StateSet</tt>s can be shared between\r\n * different <tt>Drawable</tt>s and <tt>Node</tt>s (that is, several\r\n * <tt>Drawable</tt>s and <tt>Node</tt>s can reference the same \\c StateSet).\r\n * Indeed, this practice is recommended whenever possible,\r\n * as this minimizes expensive state changes in the graphics pipeline.\r\n */\r\n\r\nvar StateSet = function() {\r\n Object.call(this);\r\n\r\n this._parents = [];\r\n this._attributeArray = [];\r\n this._textureAttributeArrayList = [];\r\n\r\n // cache what is really used\r\n this._activeTextureAttributeUnit = [];\r\n this._activeAttribute = [];\r\n this._activeTextureAttribute = [];\r\n\r\n this._binName = undefined;\r\n this._binNumber = 0;\r\n\r\n // put the shader generator name in an AttributePair\r\n // so that we can use the mask value\r\n this._shaderGeneratorPair = null;\r\n\r\n this._updateCallbackList = [];\r\n\r\n this.uniforms = {};\r\n\r\n this._hasUniform = false;\r\n\r\n this._drawID = -1; // used by the RenderLeaf to decide if it should apply the stateSet\r\n};\r\n\r\nStateSet.AttributePair = function(attr, value) {\r\n this._object = attr;\r\n this._value = value;\r\n};\r\n\r\nStateSet.AttributePair.prototype = {\r\n getShaderGeneratorName: function() {\r\n return this._object;\r\n },\r\n getAttribute: function() {\r\n return this._object;\r\n },\r\n getUniform: function() {\r\n return this._object;\r\n },\r\n getValue: function() {\r\n return this._value;\r\n }\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StateSet,\r\n utils.objectInherit(Object.prototype, {\r\n setDrawID: function(id) {\r\n this._drawID = id;\r\n },\r\n\r\n getDrawID: function() {\r\n return this._drawID;\r\n },\r\n\r\n getAttributePair: function(attribute, value) {\r\n return new StateSet.AttributePair(attribute, value);\r\n },\r\n\r\n addUniform: function(uniform, originalMode) {\r\n var mode = originalMode !== undefined ? originalMode : StateAttribute.ON;\r\n var name = uniform.getName();\r\n this.uniforms[name] = this.getAttributePair(uniform, mode);\r\n this._hasUniform = true;\r\n },\r\n\r\n addParent: function(node) {\r\n this._parents.push(node);\r\n },\r\n\r\n removeParent: function(node) {\r\n var idx = this._parents.indexOf(node);\r\n if (idx === -1) return;\r\n this._parents.splice(idx, 1);\r\n },\r\n\r\n removeUniform: function(uniform) {\r\n this.removeUniformByName(uniform.getName());\r\n },\r\n\r\n removeUniformByName: function(uniformName) {\r\n delete this.uniforms[uniformName];\r\n this._hasUniform = window.Object.keys(this.uniforms).length ? true : false;\r\n },\r\n\r\n hasUniform: function() {\r\n return this._hasUniform;\r\n },\r\n\r\n getUniform: function(uniform) {\r\n var uniformMap = this.uniforms;\r\n if (uniformMap[uniform]) return uniformMap[uniform].getAttribute();\r\n return undefined;\r\n },\r\n\r\n getUniformList: function() {\r\n return this.uniforms;\r\n },\r\n\r\n setTextureAttributeAndModes: function(unit, attribute, mode) {\r\n this._setTextureAttribute(\r\n unit,\r\n this.getAttributePair(attribute, mode !== undefined ? mode : StateAttribute.ON)\r\n );\r\n },\r\n\r\n getNumTextureAttributeLists: function() {\r\n return this._textureAttributeArrayList.length;\r\n },\r\n\r\n getTextureAttribute: function(unit, typeMember) {\r\n var index = utils.getTextureIdFromTypeMember(typeMember);\r\n if (index === undefined || !this._hasTextureAttribute(unit, index)) return undefined;\r\n\r\n var textureArray = this._textureAttributeArrayList[unit];\r\n if (textureArray[index]) return textureArray[index].getAttribute();\r\n return undefined;\r\n },\r\n\r\n removeTextureAttribute: function(unit, typeMember) {\r\n var index = utils.getTextureIdFromTypeMember(typeMember);\r\n if (index === undefined || !this._hasTextureAttribute(unit, index)) return;\r\n\r\n var textureArray = this._textureAttributeArrayList[unit];\r\n\r\n textureArray[index] = undefined;\r\n this._computeValidTextureUnit();\r\n },\r\n\r\n getAttribute: function(typeMember) {\r\n var index = utils.getIdFromTypeMember(typeMember);\r\n if (index === undefined || !this._hasAttribute(index)) return undefined;\r\n\r\n return this._attributeArray[index].getAttribute();\r\n },\r\n\r\n setAttributeAndModes: function(attribute, mode) {\r\n this._setAttribute(\r\n this.getAttributePair(attribute, mode !== undefined ? mode : StateAttribute.ON)\r\n );\r\n },\r\n\r\n setAttribute: function(attribute, mode) {\r\n this.setAttributeAndModes(attribute, mode);\r\n },\r\n\r\n // TODO: check if it's an attribute type or a attribute to remove it\r\n removeAttribute: function(typeMember) {\r\n var index = utils.getIdFromTypeMember(typeMember);\r\n if (!this._hasAttribute(index)) return;\r\n\r\n this._attributeArray[index] = undefined;\r\n this._computeValidAttribute();\r\n },\r\n\r\n setRenderingHint: function(hint) {\r\n if (hint === 'OPAQUE_BIN') {\r\n this.setRenderBinDetails(0, 'RenderBin');\r\n } else if (hint === 'TRANSPARENT_BIN') {\r\n this.setRenderBinDetails(10, 'DepthSortedBin');\r\n } else {\r\n this.setRenderBinDetails(0, '');\r\n }\r\n },\r\n\r\n getUpdateCallbackList: function() {\r\n return this._updateCallbackList;\r\n },\r\n\r\n removeUpdateCallback: function(cb) {\r\n var idx = this._updateCallbackList.indexOf(cb);\r\n if (idx === -1) return;\r\n this._updateCallbackList.splice(idx, 1);\r\n\r\n if (this._updateCallbackList.length === 0) {\r\n var parents = this._parents;\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n var parent = parents[i];\r\n parent.setNumChildrenRequiringUpdateTraversal(\r\n parent.getNumChildrenRequiringUpdateTraversal() - 1\r\n );\r\n }\r\n }\r\n },\r\n\r\n requiresUpdateTraversal: function() {\r\n return !!this._updateCallbackList.length;\r\n },\r\n\r\n addUpdateCallback: function(cb) {\r\n var dontNoticeParents = Boolean(this._updateCallbackList.length);\r\n this._updateCallbackList.push(cb);\r\n\r\n // parent alreay know we have update callback\r\n if (dontNoticeParents) return;\r\n\r\n var parents = this._parents;\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n var parent = parents[i];\r\n parent.setNumChildrenRequiringUpdateTraversal(\r\n parent.getNumChildrenRequiringUpdateTraversal() + 1\r\n );\r\n }\r\n },\r\n\r\n hasUpdateCallback: function(cb) {\r\n return this._updateCallbackList.indexOf(cb) !== -1;\r\n },\r\n\r\n setRenderBinDetails: function(num, binName) {\r\n this._binNumber = num;\r\n this._binName = binName;\r\n },\r\n getAttributeMap: function() {\r\n // not efficieant at all but not really critique\r\n var obj = {};\r\n for (var i = 0, l = this._attributeArray.length; i < l; i++) {\r\n var attributePair = this._attributeArray[i];\r\n if (!attributePair) continue;\r\n var attribute = attributePair.getAttribute();\r\n obj[attribute.getTypeMember()] = attributePair;\r\n }\r\n return obj;\r\n },\r\n getBinNumber: function() {\r\n return this._binNumber;\r\n },\r\n getBinName: function() {\r\n return this._binName;\r\n },\r\n setBinNumber: function(binNum) {\r\n this._binNumber = binNum;\r\n },\r\n setBinName: function(binName) {\r\n this._binName = binName;\r\n },\r\n getAttributeList: function() {\r\n var attributeArray = this._attributeArray;\r\n var list = [];\r\n for (var i = 0, l = attributeArray.length; i < l; i++) {\r\n if (attributeArray[i]) list.push(attributeArray[i]);\r\n }\r\n return list;\r\n },\r\n setShaderGeneratorName: function(generatorName, mode) {\r\n this._shaderGeneratorPair = this.getAttributePair(\r\n generatorName,\r\n mode !== undefined ? mode : StateAttribute.ON\r\n );\r\n },\r\n getShaderGeneratorPair: function() {\r\n return this._shaderGeneratorPair;\r\n },\r\n getShaderGeneratorName: function() {\r\n return this._shaderGeneratorPair ?\r\n this._shaderGeneratorPair.getShaderGeneratorName() :\r\n undefined;\r\n },\r\n releaseGLObjects: function() {\r\n for (var i = 0, j = this._textureAttributeArrayList.length; i < j; i++) {\r\n var attribute = this.getTextureAttribute(i, 'Texture');\r\n if (attribute) attribute.releaseGLObjects();\r\n }\r\n var list = this.getAttributeList();\r\n for (var k = 0, l = list.length; k < l; k++) {\r\n // Remove only if we have releaseGLObject method.\r\n if (list[k]._object.releaseGLObjects) {\r\n list[k]._object.releaseGLObjects();\r\n }\r\n }\r\n },\r\n\r\n // for internal use, you should not call it directly\r\n _setTextureAttribute: function(unit, attributePair) {\r\n utils.arrayDense(unit, this._textureAttributeArrayList);\r\n if (!this._textureAttributeArrayList[unit]) this._textureAttributeArrayList[unit] = [];\r\n\r\n var index = utils.getOrCreateTextureStateAttributeTypeMemberIndex(\r\n attributePair.getAttribute()\r\n );\r\n utils.arrayDense(index, this._textureAttributeArrayList[unit]);\r\n\r\n this._textureAttributeArrayList[unit][index] = attributePair;\r\n this._computeValidTextureUnit();\r\n },\r\n\r\n _computeValidTextureUnit: function() {\r\n this._activeTextureAttributeUnit.length = 0;\r\n this._activeTextureAttribute.length = 0;\r\n var textureAttributeArrayList = this._textureAttributeArrayList;\r\n for (var i = 0, l = textureAttributeArrayList.length; i < l; i++) {\r\n var attributeList = textureAttributeArrayList[i];\r\n if (!attributeList || !attributeList.length) continue;\r\n var hasValidAttribute = false;\r\n for (var j = 0, k = attributeList.length; j < k; j++) {\r\n if (attributeList[j]) {\r\n hasValidAttribute = true;\r\n\r\n if (this._activeTextureAttribute.indexOf(j) === -1) {\r\n this._activeTextureAttribute.push(j);\r\n }\r\n }\r\n }\r\n\r\n if (hasValidAttribute) this._activeTextureAttributeUnit.push(i);\r\n }\r\n },\r\n _computeValidAttribute: function() {\r\n this._activeAttribute.length = 0;\r\n var attributeArray = this._attributeArray;\r\n for (var i = 0, l = attributeArray.length; i < l; i++) {\r\n if (attributeArray[i]) this._activeAttribute.push(i);\r\n }\r\n },\r\n // for internal use, you should not call it directly\r\n _setAttribute: function(attributePair) {\r\n var index = utils.getOrCreateStateAttributeTypeMemberIndex(\r\n attributePair.getAttribute()\r\n );\r\n utils.arrayDense(index, this._attributeArray);\r\n this._attributeArray[index] = attributePair;\r\n this._computeValidAttribute();\r\n },\r\n _hasAttribute: function(typeIndex) {\r\n if (typeIndex >= this._attributeArray.length) return false;\r\n return !!this._attributeArray[typeIndex];\r\n },\r\n _hasTextureAttribute: function(unit, typeIndex) {\r\n if (\r\n unit >= this._textureAttributeArrayList.length ||\r\n !this._textureAttributeArrayList[unit]\r\n )\r\n return false;\r\n if (typeIndex >= this._textureAttributeArrayList[unit].length) return false;\r\n return !!this._textureAttributeArrayList[unit][typeIndex];\r\n }\r\n }),\r\n 'osg',\r\n 'StateSet'\r\n);\r\n\r\nexport default StateSet;","import utils from './utils';\r\nimport Node from './Node';\r\nimport { mat4 } from './glMatrix';\r\nimport TransformEnums from './transformEnums';\r\n\r\n/**\r\n * Transform - base class for Transform type node ( Camera, MatrixTransform )\r\n * @class Transform\r\n * @inherits Node\r\n */\r\nvar Transform = function() {\r\n Node.call(this);\r\n this.referenceFrame = TransformEnums.RELATIVE_RF;\r\n};\r\n\r\n/** @lends Transform.prototype */\r\nutils.createPrototypeNode(\r\n Transform,\r\n utils.objectInherit(Node.prototype, {\r\n setReferenceFrame: function(value) {\r\n this.referenceFrame = value;\r\n },\r\n getReferenceFrame: function() {\r\n return this.referenceFrame;\r\n },\r\n\r\n computeBoundingSphere: (function() {\r\n var matrix = mat4.create();\r\n return function(bSphere) {\r\n Node.prototype.computeBoundingSphere.call(this, bSphere);\r\n if (!bSphere.valid()) {\r\n return bSphere;\r\n }\r\n\r\n mat4.identity(matrix);\r\n // local to local world (not Global World)\r\n this.computeLocalToWorldMatrix(matrix);\r\n bSphere.transformMat4(bSphere, matrix);\r\n return bSphere;\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'Transform'\r\n);\r\n\r\nexport default Transform;","import notify from './notify';\r\n\r\n/**\r\n * Uniform manage variable used in glsl shader.\r\n * @class Uniform\r\n */\r\nvar Uniform = function(name) {\r\n this._data = undefined;\r\n this._transpose = false;\r\n this._glCall = '';\r\n this._cache = undefined;\r\n this._name = name;\r\n this._type = undefined;\r\n this._isMatrix = false;\r\n};\r\n\r\nUniform.isUniform = function(obj) {\r\n if (typeof obj === 'object' && window.Object.getPrototypeOf(obj) === Uniform.prototype) {\r\n return true;\r\n }\r\n return false;\r\n};\r\n\r\n/** @lends Uniform.prototype */\r\nUniform.prototype = {\r\n getName: function() {\r\n return this._name;\r\n },\r\n\r\n getType: function() {\r\n return this._type;\r\n },\r\n\r\n apply: function UniformApply(gl, location) {\r\n this._cache = gl[this._glCall];\r\n\r\n if (this._isMatrix) {\r\n this._cache.call(gl, location, this._transpose, this._data);\r\n } else {\r\n this._cache.call(gl, location, this._data);\r\n }\r\n },\r\n\r\n // no type checking, so array should be valid\r\n setInternalArray: function(array) {\r\n notify.warn(\r\n 'setInternalArray deprecated, please use getInternalArray instead: ' + array.length\r\n );\r\n this._data = array;\r\n },\r\n\r\n getInternalArray: function() {\r\n return this._data;\r\n },\r\n\r\n setFloat: function(f) {\r\n this._data[0] = f;\r\n },\r\n\r\n setFloat1: function(f) {\r\n this._data[0] = f[0];\r\n },\r\n\r\n setFloat2: function(f) {\r\n this._data[0] = f[0];\r\n this._data[1] = f[1];\r\n },\r\n\r\n setFloat3: function(f) {\r\n this._data[0] = f[0];\r\n this._data[1] = f[1];\r\n this._data[2] = f[2];\r\n },\r\n\r\n setFloat4: function(f) {\r\n this._data[0] = f[0];\r\n this._data[1] = f[1];\r\n this._data[2] = f[2];\r\n this._data[3] = f[3];\r\n },\r\n\r\n setFloat9: function(f) {\r\n this._data[0] = f[0];\r\n this._data[1] = f[1];\r\n this._data[2] = f[2];\r\n this._data[3] = f[3];\r\n this._data[4] = f[4];\r\n this._data[5] = f[5];\r\n this._data[6] = f[6];\r\n this._data[7] = f[7];\r\n this._data[8] = f[8];\r\n },\r\n\r\n setFloat16: function(f) {\r\n this._data[0] = f[0];\r\n this._data[1] = f[1];\r\n this._data[2] = f[2];\r\n this._data[3] = f[3];\r\n this._data[4] = f[4];\r\n this._data[5] = f[5];\r\n this._data[6] = f[6];\r\n this._data[7] = f[7];\r\n this._data[8] = f[8];\r\n this._data[9] = f[9];\r\n this._data[10] = f[10];\r\n this._data[11] = f[11];\r\n this._data[12] = f[12];\r\n this._data[13] = f[13];\r\n this._data[14] = f[14];\r\n this._data[15] = f[15];\r\n }\r\n};\r\nUniform.prototype.setVec2 = Uniform.prototype.setFloat2;\r\nUniform.prototype.setVec3 = Uniform.prototype.setFloat3;\r\nUniform.prototype.setVec4 = Uniform.prototype.setFloat4;\r\nUniform.prototype.setMatrix4 = Uniform.prototype.setFloat16;\r\nUniform.prototype.setMatrix3 = Uniform.prototype.setFloat9;\r\nUniform.prototype.setInt = Uniform.prototype.setFloat;\r\nUniform.prototype.setInt1 = Uniform.prototype.setFloat1;\r\nUniform.prototype.setInt2 = Uniform.prototype.setFloat2;\r\nUniform.prototype.setInt3 = Uniform.prototype.setFloat3;\r\nUniform.prototype.setInt4 = Uniform.prototype.setFloat4;\r\n\r\nvar createUniformX = function(\r\n dataOrName,\r\n nameOrNbItem,\r\n internalArray,\r\n glSignature,\r\n type,\r\n isMatrix\r\n) {\r\n var data = nameOrNbItem && nameOrNbItem.length ? dataOrName : undefined;\r\n var uniform = new Uniform(data !== undefined ? nameOrNbItem : dataOrName);\r\n\r\n uniform._data = internalArray;\r\n\r\n if (data !== undefined) {\r\n if (data.length) {\r\n for (var i = 0, nbElts = data.length; i < nbElts; ++i) uniform._data[i] = data[i];\r\n } else {\r\n uniform._data[0] = data;\r\n }\r\n }\r\n\r\n uniform._glCall = glSignature;\r\n uniform._type = type;\r\n uniform._isMatrix = !!isMatrix;\r\n return uniform;\r\n};\r\n\r\nvar createMat2 = function(nbItem) {\r\n var out = new Float32Array(nbItem * 4);\r\n for (var i = 0; i < out.length; i += 4) out[i] = out[i + 3] = 1.0;\r\n return out;\r\n};\r\n\r\nvar createMat3 = function(nbItem) {\r\n var out = new Float32Array(nbItem * 9);\r\n for (var i = 0; i < out.length; i += 9) out[i] = out[i + 4] = out[i + 8] = 1.0;\r\n return out;\r\n};\r\n\r\nvar createMat4 = function(nbItem) {\r\n var out = new Float32Array(nbItem * 16);\r\n for (var i = 0; i < out.length; i += 16) out[i] = out[i + 5] = out[i + 10] = out[i + 15] = 1.0;\r\n return out;\r\n};\r\n\r\n// possibles signatures\r\n// name\r\n// data, name\r\n// name, nbItem\r\nvar _getNbItem = function(itemSize, dataOrName, nameOrNbItem) {\r\n if (nameOrNbItem && !nameOrNbItem.length) return nameOrNbItem; // name, nbItem\r\n if (typeof dataOrName !== 'string') return (dataOrName.length || 1) / itemSize; // data, name\r\n return 1; // name\r\n};\r\n\r\n// works also for float array but data must be given\r\nUniform.createFloat1 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Float32Array(1 * _getNbItem(1, dataOrName, nameOrNbItem)),\r\n 'uniform1fv',\r\n 'float'\r\n );\r\n};\r\nUniform.createFloat2 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Float32Array(2 * _getNbItem(2, dataOrName, nameOrNbItem)),\r\n 'uniform2fv',\r\n 'vec2'\r\n );\r\n};\r\nUniform.createFloat3 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Float32Array(3 * _getNbItem(3, dataOrName, nameOrNbItem)),\r\n 'uniform3fv',\r\n 'vec3'\r\n );\r\n};\r\nUniform.createFloat4 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Float32Array(4 * _getNbItem(4, dataOrName, nameOrNbItem)),\r\n 'uniform4fv',\r\n 'vec4'\r\n );\r\n};\r\n\r\nUniform.createInt1 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Int32Array(1 * _getNbItem(1, dataOrName, nameOrNbItem)),\r\n 'uniform1iv',\r\n 'int'\r\n );\r\n};\r\nUniform.createInt2 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Int32Array(2 * _getNbItem(2, dataOrName, nameOrNbItem)),\r\n 'uniform2iv',\r\n 'vec2i'\r\n );\r\n};\r\nUniform.createInt3 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Int32Array(3 * _getNbItem(3, dataOrName, nameOrNbItem)),\r\n 'uniform3iv',\r\n 'vec3i'\r\n );\r\n};\r\nUniform.createInt4 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n new Int32Array(4 * _getNbItem(4, dataOrName, nameOrNbItem)),\r\n 'uniform4iv',\r\n 'vec4i'\r\n );\r\n};\r\n\r\nUniform.createMatrix2 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n createMat2(_getNbItem(4, dataOrName, nameOrNbItem)),\r\n 'uniformMatrix2fv',\r\n 'mat2',\r\n true\r\n );\r\n};\r\n\r\nUniform.createMatrix3 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n createMat3(_getNbItem(9, dataOrName, nameOrNbItem)),\r\n 'uniformMatrix3fv',\r\n 'mat3',\r\n true\r\n );\r\n};\r\n\r\nUniform.createMatrix4 = function(dataOrName, nameOrNbItem) {\r\n return createUniformX(\r\n dataOrName,\r\n nameOrNbItem,\r\n createMat4(_getNbItem(16, dataOrName, nameOrNbItem)),\r\n 'uniformMatrix4fv',\r\n 'mat4',\r\n true\r\n );\r\n};\r\n\r\n// alias\r\nUniform.float = Uniform.createFloatArray = Uniform.createFloat = Uniform.createFloat1;\r\nUniform.vec2 = Uniform.createFloat2Array = Uniform.createFloat2;\r\nUniform.vec3 = Uniform.createFloat3Array = Uniform.createFloat3;\r\nUniform.vec4 = Uniform.createFloat4Array = Uniform.createFloat4;\r\n\r\nUniform.int = Uniform.createIntArray = Uniform.createInt = Uniform.createInt1;\r\nUniform.vec2i = Uniform.createInt2Array = Uniform.createInt2;\r\nUniform.vec3i = Uniform.createInt3Array = Uniform.createInt3;\r\nUniform.vec4i = Uniform.createInt4Array = Uniform.createInt4;\r\n\r\nUniform.mat2 = Uniform.createMat2Array = Uniform.createMat2 = Uniform.createMatrix2;\r\nUniform.mat3 = Uniform.createMat3Array = Uniform.createMat3 = Uniform.createMatrix3;\r\nUniform.mat4 = Uniform.createMat4Array = Uniform.createMat4 = Uniform.createMatrix4;\r\n\r\nexport default Uniform;","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\n\r\n/**\r\n * AnimationUpdateCallback\r\n * @class AnimationUpdateCallback\r\n */\r\nvar AnimationUpdateCallback = function() {\r\n Object.call(this);\r\n};\r\n\r\n// check if the path is animated, it could be elsewhere though\r\nAnimationUpdateCallback.checkPathIsAnimated = function(path) {\r\n for (var i = 0, nbNodes = path.length; i < nbNodes; ++i) {\r\n var node = path[i];\r\n\r\n if (node instanceof MatrixTransform) {\r\n var ups = node.getUpdateCallbackList();\r\n for (var j = 0, nbUp = ups.length; j < nbUp; ++j) {\r\n if (ups[j] instanceof AnimationUpdateCallback) return true;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n\r\n/** @lends AnimationUpdateCallback.prototype */\r\nutils.createPrototypeObject(\r\n AnimationUpdateCallback,\r\n utils.objectInherit(Object.prototype, {\r\n computeChannels: function() {},\r\n reset: function() {}\r\n }),\r\n 'osgAnimation',\r\n 'AnimationUpdateCallback'\r\n);\r\n\r\nexport default AnimationUpdateCallback;\r\n","import utils from '../osg/utils';\r\nimport CullSettings from '../osg/CullSettings';\r\nimport CullVisitor from '../osg/CullVisitor';\r\nimport Object from '../osg/Object';\r\nimport RenderStage from '../osg/RenderStage';\r\nimport State from '../osg/State';\r\nimport StateGraph from '../osg/StateGraph';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport osgShader from '../osgShader/osgShader';\r\nimport DisplayGraph from '../osgUtil/DisplayGraph';\r\n\r\nvar Renderer = function(camera) {\r\n Object.call(this);\r\n\r\n this._state = undefined;\r\n this._camera = camera;\r\n this._renderStage = undefined;\r\n this._stateGraph = undefined;\r\n\r\n this._frameStamp = undefined;\r\n\r\n this._previousCullsettings = new CullSettings();\r\n\r\n this.setDefaults();\r\n};\r\n\r\nRenderer.debugGraph = false;\r\n\r\nutils.createPrototypeObject(\r\n Renderer,\r\n utils.objectInherit(Object.prototype, {\r\n setDefaults: function() {\r\n this._state = new State(new osgShader.ShaderGeneratorProxy());\r\n\r\n this._cullVisitor = new CullVisitor();\r\n this._cullVisitor.setRenderer(this);\r\n this._stateGraph = new StateGraph();\r\n\r\n this.getCamera().setClearColor(vec4.create());\r\n this.setRenderStage(new RenderStage());\r\n\r\n var osg = require('../osg/osg').default;\r\n var stateSet = this.getCamera().getOrCreateStateSet();\r\n stateSet.setAttributeAndModes(new osg.Material());\r\n stateSet.setAttributeAndModes(new osg.Depth());\r\n stateSet.setAttributeAndModes(new osg.BlendFunc());\r\n stateSet.setAttributeAndModes(new osg.CullFace());\r\n stateSet.setAttributeAndModes(new osg.FrontFace());\r\n },\r\n\r\n getCullVisitor: function() {\r\n return this._cullVisitor;\r\n },\r\n\r\n setCullVisitor: function(cv) {\r\n if (cv && !cv.getRenderer()) cv.setRenderer(this);\r\n this._cullVisitor = cv;\r\n },\r\n\r\n setRenderStage: function(rs) {\r\n this._renderStage = rs;\r\n },\r\n\r\n getCamera: function() {\r\n return this._camera;\r\n },\r\n\r\n setFrameStamp: function(fs) {\r\n this._frameStamp = fs;\r\n },\r\n\r\n getFrameStamp: function() {\r\n return this._frameStamp;\r\n },\r\n\r\n getState: function() {\r\n return this._state;\r\n },\r\n\r\n setState: function(state) {\r\n this._state = state;\r\n },\r\n\r\n setGraphicContext: function(gc) {\r\n this._state.setGraphicContext(gc);\r\n },\r\n\r\n getGraphicContext: function() {\r\n return this._state.getGraphicContext();\r\n },\r\n\r\n cullAndDraw: function() {\r\n this.cull();\r\n this.draw();\r\n },\r\n\r\n cull: function() {\r\n var camera = this.getCamera();\r\n var view = camera.getView();\r\n\r\n this._cullVisitor.setFrameStamp(this._frameStamp);\r\n\r\n // reset stats\r\n this._cullVisitor.resetStats();\r\n\r\n // this part of code should be called for each view\r\n // right now, we dont support multi view\r\n\r\n // reset all stateGraph per frame\r\n StateGraph.reset();\r\n this._stateGraph.clean();\r\n\r\n this._renderStage.reset();\r\n\r\n this._cullVisitor.reset();\r\n this._cullVisitor.setStateGraph(this._stateGraph);\r\n this._cullVisitor.setRenderStage(this._renderStage);\r\n\r\n this._cullVisitor.pushStateSet(camera.getStateSet());\r\n\r\n // save cullSettings\r\n this._previousCullsettings.reset();\r\n this._previousCullsettings.setCullSettings(this._cullVisitor);\r\n this._cullVisitor.setCullSettings(camera);\r\n if (\r\n this._previousCullsettings.getSettingSourceOverrider() === this._cullVisitor &&\r\n this._previousCullsettings.getEnableFrustumCulling()\r\n ) {\r\n this._cullVisitor.setEnableFrustumCulling(true);\r\n }\r\n\r\n // Push reference on the projection stack, it means that if compute near/far\r\n // is activated, it will update the projection matrix of the camera\r\n this._cullVisitor.pushCameraModelViewProjectionMatrix(\r\n camera,\r\n camera.getViewMatrix(),\r\n camera.getProjectionMatrix()\r\n );\r\n\r\n // update bound\r\n camera.getBound();\r\n\r\n var light = view.getLight();\r\n var View = require('../osgViewer/View').default;\r\n\r\n if (light) {\r\n switch (view.getLightingMode()) {\r\n case View.LightingMode.HEADLIGHT:\r\n this._cullVisitor.addPositionedAttribute(null, light);\r\n break;\r\n\r\n case View.LightingMode.SKY_LIGHT:\r\n this._cullVisitor.addPositionedAttribute(camera.getViewMatrix(), light);\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n var viewport = camera.getViewport();\r\n var scissor = camera.getScissor();\r\n\r\n this._cullVisitor.pushViewport(viewport);\r\n\r\n this._renderStage.setClearDepth(camera.getClearDepth());\r\n this._renderStage.setClearColor(camera.getClearColor());\r\n this._renderStage.setClearMask(camera.getClearMask());\r\n this._renderStage.setViewport(viewport);\r\n this._renderStage.setScissor(scissor);\r\n\r\n // pass de dbpager to the cullvisitor, so plod's can do the requests\r\n this._cullVisitor.setDatabaseRequestHandler(this._camera.getView().getDatabasePager());\r\n // dont add camera on the stack just traverse it\r\n this._cullVisitor.handleCullCallbacksAndTraverse(camera);\r\n\r\n // fix projection matrix if camera has near/far auto compute\r\n this._cullVisitor.popCameraModelViewProjectionMatrix(camera);\r\n\r\n // Important notes about near/far\r\n // If you are using the picking on the main camera and\r\n // you use only children sub camera for RTT, your\r\n // main camera will keep +/-infinity for near/far because\r\n // the computation of near/far is done by camera and use Geometry\r\n\r\n // restore previous state of the camera\r\n this._cullVisitor.setCullSettings(this._previousCullsettings);\r\n\r\n this._cullVisitor.popViewport();\r\n this._cullVisitor.popStateSet();\r\n\r\n this._renderStage.sort();\r\n },\r\n\r\n draw: function() {\r\n var state = this.getState();\r\n\r\n // important because cache are used in cullvisitor\r\n state.resetCacheFrame();\r\n\r\n // reset stats counter\r\n state.resetStats();\r\n\r\n this._renderStage.setCamera(this._camera);\r\n this._renderStage.draw(state);\r\n\r\n if (Renderer.debugGraph) {\r\n DisplayGraph.instance().createRenderGraph(this._renderStage);\r\n Renderer.debugGraph = false;\r\n }\r\n\r\n this._renderStage.setCamera(undefined);\r\n\r\n state.applyDefault();\r\n }\r\n }),\r\n 'osgViewer',\r\n 'Renderer'\r\n);\r\n\r\nexport default Renderer;","var FrameStamp = function() {\r\n this._frame = 0;\r\n this._startSimulation = 0.0;\r\n this._currentSimulation = 0.0;\r\n this._deltaTime = 0.0; // last time elapsed since the next traversal\r\n};\r\n\r\nFrameStamp.prototype = {\r\n setReferenceTime: function(s) {\r\n this._startSimulation = s;\r\n },\r\n getReferenceTime: function() {\r\n return this._startSimulation;\r\n },\r\n setSimulationTime: function(s) {\r\n this._currentSimulation = s;\r\n },\r\n getSimulationTime: function() {\r\n return this._currentSimulation;\r\n },\r\n setDeltaTime: function(d) {\r\n this._deltaTime = d;\r\n },\r\n getDeltaTime: function() {\r\n return this._deltaTime;\r\n },\r\n setFrameNumber: function(n) {\r\n this._frame = n;\r\n },\r\n getFrameNumber: function() {\r\n return this._frame;\r\n }\r\n};\r\n\r\nexport default FrameStamp;\r\n","import utils from '../osg/utils';\r\nimport notify from '../osg/notify';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Compiler from './Compiler';\r\n//import ShaderProcessor from './ShaderProcessor';\r\nimport NextShaderProcessor from './NextShaderProcessor';\r\n\r\n\r\nvar ShaderGenerator = function() {\r\n this._cache = {};\r\n\r\n // ShaderProcessor singleton used by ShaderGenerator\r\n // but user can replace it if needed\r\n // this._shaderProcessor = new ShaderProcessor();\r\n this._shaderProcessor = NextShaderProcessor\r\n\r\n // ShaderCompiler Object to instanciate\r\n this._ShaderCompiler = undefined;\r\n\r\n this.setShaderCompiler(Compiler);\r\n};\r\n\r\nShaderGenerator.prototype = {\r\n // setShaderCompiler that will be used to createShader\r\n setShaderCompiler: function(ShaderCompiler) {\r\n this._ShaderCompiler = ShaderCompiler;\r\n if (!ShaderCompiler._validAttributeTypeMemberCache)\r\n this._computeStateAttributeCache(ShaderCompiler);\r\n },\r\n\r\n getShaderCompiler: function() {\r\n return this._ShaderCompiler;\r\n },\r\n\r\n getShaderProcessor: function() {\r\n return this._shaderProcessor;\r\n },\r\n\r\n setShaderProcessor: function(shaderProcessor) {\r\n this._shaderProcessor = shaderProcessor;\r\n },\r\n\r\n // filter input types and write the result in the outputs array\r\n filterAttributeTypes: function(attribute) {\r\n // works for attribute that contains isEnabled\r\n // Light, Shadow. It let us to filter them to build a shader if not enabled\r\n if (attribute.isEnabled && !attribute.isEnabled()) return true;\r\n\r\n return false;\r\n },\r\n\r\n // get actives attribute that comes from state listed by compiler cache type\r\n getActiveAttributeList: function(state, list) {\r\n var hash = '';\r\n var _attributeArray = state._attributeArray;\r\n var cacheType = this._ShaderCompiler._validAttributeTypeMemberCache;\r\n\r\n for (var j = 0, k = cacheType.length; j < k; j++) {\r\n var type = cacheType[j];\r\n var attributeStack = type < _attributeArray.length ? _attributeArray[type] : undefined;\r\n if (!attributeStack) continue;\r\n\r\n var attribute = attributeStack._lastApplied;\r\n\r\n if (!attribute || this.filterAttributeTypes(attribute)) continue;\r\n\r\n hash += attribute.getHash();\r\n list.push(attribute);\r\n }\r\n\r\n return hash;\r\n },\r\n\r\n // create a hash from actives attribute listed by compiler cache type\r\n getActiveAttributeListCache: function(state) {\r\n var hash = '';\r\n\r\n var cacheType = this._ShaderCompiler._validAttributeTypeMemberCache;\r\n for (var i = 0, l = cacheType.length; i < l; i++) {\r\n var type = cacheType[i];\r\n var attributeStack =\r\n type < state._attributeArray.length ? state._attributeArray[type] : undefined;\r\n if (attributeStack) {\r\n var attribute = attributeStack._lastApplied;\r\n if (!attribute || this.filterAttributeTypes(attribute)) continue;\r\n\r\n hash += attributeStack._lastApplied.getHash();\r\n }\r\n }\r\n\r\n return hash;\r\n },\r\n\r\n // create a hash from actives texture attribute listed by compiler cache type\r\n getActiveTextureAttributeListCache: function(state) {\r\n var hash = '';\r\n\r\n var cacheType = this._ShaderCompiler._validTextureAttributeTypeMemberCache;\r\n var textureUnitList = state._textureAttributeArrayList;\r\n for (var j = 0; j < textureUnitList.length; j++) {\r\n var textureUnit = textureUnitList[j];\r\n if (!textureUnit) continue;\r\n\r\n var textureUnitLength = textureUnit.length;\r\n for (var i = 0; i < cacheType.length; i++) {\r\n var type = cacheType[i];\r\n var attributeStack = type < textureUnitLength ? textureUnit[type] : undefined;\r\n if (attributeStack) {\r\n var attribute = attributeStack._lastApplied;\r\n\r\n if (\r\n !attribute ||\r\n this.filterAttributeTypes(attribute) ||\r\n attribute.isTextureNull()\r\n )\r\n continue;\r\n\r\n // we check to filter texture null in hash\r\n // but it's probably better to just set the hash correctly of a tetxure null, to remove this custom code\r\n hash += attribute.getHash();\r\n }\r\n }\r\n }\r\n\r\n return hash;\r\n },\r\n\r\n // get actives texture attribute that comes from state\r\n getActiveTextureAttributeList: function(state, list) {\r\n var hash = '';\r\n var _attributeArrayList = state._textureAttributeArrayList;\r\n var i, l;\r\n var cacheType = this._ShaderCompiler._validTextureAttributeTypeMemberCache;\r\n\r\n for (i = 0, l = _attributeArrayList.length; i < l; i++) {\r\n var _attributeArrayForUnit = _attributeArrayList[i];\r\n\r\n if (!_attributeArrayForUnit) continue;\r\n\r\n list[i] = [];\r\n\r\n for (var j = 0, m = cacheType.length; j < m; j++) {\r\n var type = cacheType[j];\r\n\r\n var attributeStack =\r\n type < _attributeArrayForUnit.length ? _attributeArrayForUnit[type] : undefined;\r\n if (!attributeStack) continue;\r\n\r\n var attribute = attributeStack._lastApplied;\r\n if (!attribute || this.filterAttributeTypes(attribute) || attribute.isTextureNull())\r\n continue;\r\n\r\n hash += attribute.getHash();\r\n list[i].push(attribute);\r\n }\r\n }\r\n return hash;\r\n },\r\n\r\n getActiveUniforms: function(state, attributeList, textureAttributeList) {\r\n var uniforms = {};\r\n\r\n for (var i = 0, l = attributeList.length; i < l; i++) {\r\n var at = attributeList[i];\r\n if (at.getOrCreateUniforms) {\r\n var attributeUniformMap = at.getOrCreateUniforms();\r\n // It could happen that uniforms are declared conditionally\r\n if (attributeUniformMap !== undefined) {\r\n for (var keyAttribute in attributeUniformMap) {\r\n var uniform = attributeUniformMap[keyAttribute];\r\n uniforms[uniform.getName()] = uniform;\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (var a = 0, n = textureAttributeList.length; a < n; a++) {\r\n var tat = textureAttributeList[a];\r\n if (tat) {\r\n for (var b = 0, o = tat.length; b < o; b++) {\r\n var attr = tat[b];\r\n\r\n var texUniformMap = attr.getOrCreateUniforms(a);\r\n\r\n for (var tname in texUniformMap) {\r\n var tuniform = texUniformMap[tname];\r\n uniforms[tuniform.getName()] = tuniform;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return uniforms;\r\n },\r\n\r\n _computeStateAttributeCache: function(CompilerShader) {\r\n var typeMemberNames = CompilerShader.stateAttributeConfig.attribute || [];\r\n var validTypeMemberList = [];\r\n var typeMemberName;\r\n var i, il, cache;\r\n var id;\r\n for (i = 0, il = typeMemberNames.length; i < il; i++) {\r\n typeMemberName = typeMemberNames[i];\r\n id = utils.getIdFromTypeMember(typeMemberName);\r\n if (id !== undefined) {\r\n if (validTypeMemberList.indexOf(id) !== -1) {\r\n notify.warn(\r\n 'Compiler ' +\r\n CompilerShader.name +\r\n ' contains duplicate attribute entry ' +\r\n typeMemberName +\r\n ', check the Compiler configuration'\r\n );\r\n } else {\r\n validTypeMemberList.push(id);\r\n }\r\n }\r\n }\r\n cache = new Uint8Array(validTypeMemberList);\r\n CompilerShader._validAttributeTypeMemberCache = cache;\r\n\r\n typeMemberNames = CompilerShader.stateAttributeConfig.textureAttribute || [];\r\n validTypeMemberList = [];\r\n for (i = 0, il = typeMemberNames.length; i < il; i++) {\r\n typeMemberName = typeMemberNames[i];\r\n id = utils.getTextureIdFromTypeMember(typeMemberName);\r\n if (validTypeMemberList.indexOf(id) !== -1) {\r\n notify.warn(\r\n 'Compiler ' +\r\n CompilerShader.name +\r\n ' contains duplicate texture attribute entry ' +\r\n typeMemberName +\r\n ', check the Compiler configuration'\r\n );\r\n } else {\r\n validTypeMemberList.push(id);\r\n }\r\n }\r\n cache = new Uint8Array(validTypeMemberList);\r\n CompilerShader._validTextureAttributeTypeMemberCache = cache;\r\n },\r\n\r\n _createWaitingProgram: function(state, attributes, textureAttributes) {\r\n var vsDefault =\r\n 'attribute vec3 Vertex;uniform mat4 uModelViewMatrix;uniform mat4 uProjectionMatrix;void main(void) { gl_Position = vec4(10.0,10.0,10.0,1.0);}\\n';\r\n\r\n var fsDefault =\r\n '#define SHADER_NAME WaitSafe\\nprecision lowp float; void main(void) { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);}\\n';\r\n\r\n var program = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vsDefault),\r\n new Shader(Shader.FRAGMENT_SHADER, fsDefault)\r\n );\r\n\r\n this.getActiveAttributeList(state, attributes);\r\n program.setActiveUniforms(this.getActiveUniforms(state, attributes, textureAttributes));\r\n program.generated = true;\r\n program.apply(state);\r\n return program;\r\n },\r\n\r\n getOrCreateProgram: (function() {\r\n var textureAttributes = [];\r\n var attributes = [];\r\n\r\n return function(state) {\r\n // extract valid attributes\r\n var hash =\r\n this.getActiveAttributeListCache(state) +\r\n this.getActiveTextureAttributeListCache(state);\r\n\r\n var cachedProgram = this._getProgram(hash, state, attributes, textureAttributes);\r\n if (cachedProgram !== undefined) {\r\n return cachedProgram;\r\n }\r\n\r\n var program = this._createProgram(hash, state, attributes, textureAttributes);\r\n\r\n return program;\r\n };\r\n })(),\r\n\r\n _getProgram: function(hash) {\r\n return this._cache[hash];\r\n },\r\n\r\n // slow path to generate shader\r\n _createProgram: function(hash, state, attributes, textureAttributes) {\r\n attributes.length = 0;\r\n textureAttributes.length = 0;\r\n\r\n this.getActiveAttributeList(state, attributes);\r\n this.getActiveTextureAttributeList(state, textureAttributes);\r\n\r\n // use ShaderCompiler, it can be overrided by a custom one\r\n var ShaderCompiler = this._ShaderCompiler;\r\n var shaderGen = new ShaderCompiler(attributes, textureAttributes, this._shaderProcessor);\r\n\r\n /* develblock:start */\r\n // Logs hash, attributes and compiler\r\n notify.debug('New Compilation ', false, true);\r\n notify.debug(\r\n {\r\n Attributes: attributes,\r\n Texture: textureAttributes,\r\n Hash: hash,\r\n Compiler: shaderGen.getFragmentShaderName()\r\n },\r\n false,\r\n true\r\n );\r\n /* develblock:end */\r\n\r\n var fragmentshader = shaderGen.createFragmentShader();\r\n var vertexshader = shaderGen.createVertexShader();\r\n\r\n var program = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vertexshader),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentshader)\r\n );\r\n\r\n program.hash = hash;\r\n program.setActiveUniforms(this.getActiveUniforms(state, attributes, textureAttributes));\r\n program.generated = true;\r\n this._cache[hash] = program;\r\n\r\n program.apply(state);\r\n\r\n return program;\r\n },\r\n resetCache: function() {\r\n this._cache = {};\r\n }\r\n};\r\n\r\nexport default ShaderGenerator;\r\n","import notify from './notify';\r\nimport utils from './utils';\r\nimport Timer from './Timer';\r\nimport GLObject from './GLObject';\r\n\r\n/**\r\n * Shader manage shader for vertex and fragment, you need both to create a glsl program.\r\n * @class Shader\r\n */\r\nvar Shader = function(type, text) {\r\n GLObject.call(this);\r\n var t = type;\r\n if (typeof type === 'string') {\r\n t = Shader[type];\r\n }\r\n this.type = t;\r\n this.setText(text);\r\n};\r\n\r\nShader.VERTEX_SHADER = 0x8b31;\r\nShader.FRAGMENT_SHADER = 0x8b30;\r\n\r\n// Debug Pink shader for when shader fails\r\nvar debugName = '\\n#define SHADER_NAME FailSafe';\r\nShader.VS_DBG =\r\n '#define _DEBUG 1\\n#ifdef _DEBUG\\nattribute vec3 Vertex;uniform mat4 uModelViewMatrix;uniform mat4 uProjectionMatrix;void main(void) { gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);}\\n';\r\nShader.FS_DBG =\r\n '#define _DEBUG 1\\n#ifdef _DEBUG\\n precision lowp float; void main(void) { gl_FragColor = vec4(1.0, 0.6, 0.6, 1.0);}\\n';\r\n\r\n// static cache of glShaders flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nShader._sDeletedGLShaderCache = new window.Map();\r\n\r\n// static method to delete Program\r\nShader.deleteGLShader = function(gl, shader) {\r\n if (!Shader._sDeletedGLShaderCache.has(gl)) Shader._sDeletedGLShaderCache.set(gl, []);\r\n Shader._sDeletedGLShaderCache.get(gl).push(shader);\r\n};\r\n\r\n// static method to flush all the cached glShaders which need to be deleted in the GL context specified\r\nShader.flushDeletedGLShaders = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n if (!Shader._sDeletedGLShaderCache.has(gl)) return availableTime;\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var deleteList = Shader._sDeletedGLShaderCache.get(gl);\r\n var numShaders = deleteList.length;\r\n for (var i = numShaders - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteShader(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nShader.flushAllDeletedGLShaders = function(gl) {\r\n if (!Shader._sDeletedGLShaderCache.has(gl)) return;\r\n var deleteList = Shader._sDeletedGLShaderCache.get(gl);\r\n var numShaders = deleteList.length;\r\n for (var i = numShaders - 1; i >= 0; i--) {\r\n gl.deleteShader(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n return;\r\n};\r\n\r\nShader.onLostContext = function(gl) {\r\n if (!Shader._sDeletedGLShaderCache.has(gl)) return;\r\n var deleteList = Shader._sDeletedGLShaderCache.get(gl);\r\n deleteList.length = 0;\r\n return;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Shader,\r\n utils.objectInherit(GLObject.prototype, {\r\n setText: function(text) {\r\n this.text = text;\r\n },\r\n getText: function() {\r\n return this.text;\r\n },\r\n // this is where it creates a fail safe shader that should work everywhere\r\n failSafe: function(gl, shaderText) {\r\n this.shader = gl.createShader(this.type);\r\n\r\n // concat failsafe and broken shader under separate _DEBUG defines blocks\r\n var shaderName = shaderText.match(/#define[\\s]+SHADER_NAME[\\s]+([\\S]+)(\\n|$)/);\r\n shaderName = shaderName ? shaderName[1] : '';\r\n var debugShaderTxt = this.type === Shader.VERTEX_SHADER ? Shader.VS_DBG : Shader.FS_DBG;\r\n debugShaderTxt += debugName + shaderName + '\\n#else\\n' + shaderText + '\\n#endif\\n';\r\n gl.shaderSource(this.shader, debugShaderTxt);\r\n gl.compileShader(this.shader);\r\n },\r\n // webgl shader compiler error to source contextualization\r\n // for better console log messages\r\n processErrors: function(errors, source) {\r\n // regex to extract error message and line from webgl compiler reporting\r\n var r = /ERROR: [\\d]+:([\\d]+): (.+)/gim;\r\n // split sources in indexable per line array\r\n var lines = source.split('\\n');\r\n var linesLength = lines.length;\r\n if (linesLength === 0) return;\r\n\r\n var i, m;\r\n\r\n // IE reporting is not the same\r\n if (r.exec(errors) === null) {\r\n r = /Shader compilation errors\\n\\((\\d+)\\, \\d+\\): (.+)/gim;\r\n }\r\n\r\n // we dont understand error try to print it instead of nothing\r\n if (r.exec(errors) === null) {\r\n notify.error(errors);\r\n return;\r\n }\r\n\r\n // reset index to start.\r\n r.lastIndex = 0;\r\n\r\n while ((m = r.exec(errors)) !== null) {\r\n if (m.index === r.lastIndex) {\r\n // moving between errors\r\n r.lastIndex++;\r\n }\r\n // get error line\r\n var line = parseInt(m[1], 10);\r\n\r\n if (line > linesLength) continue;\r\n // webgl error report.\r\n notify.error('ERROR ' + m[2] + ' in line ' + line);\r\n\r\n var minLine = Math.max(0, line - 7);\r\n var maxLine = Math.max(0, line - 2);\r\n // for context\r\n // log surrounding line priori to error with bof check\r\n for (i = minLine; i <= maxLine; i++) {\r\n notify.warn(lines[i].replace(/^[ \\t]+/g, ''));\r\n }\r\n\r\n // Warn adds a lovely /!\\ icon in front of the culprit line\r\n maxLine = Math.max(0, line - 1);\r\n notify.error(lines[maxLine].replace(/^[ \\t]+/g, ''));\r\n\r\n minLine = Math.min(linesLength, line);\r\n maxLine = Math.min(linesLength, line + 5);\r\n // for context\r\n // surrounding line posterior to error (with eof check)\r\n for (i = minLine; i < maxLine; i++) {\r\n notify.warn(lines[i].replace(/^[ \\t]+/g, ''));\r\n }\r\n }\r\n },\r\n\r\n compile: function(gl) {\r\n if (!this._gl) this.setGraphicContext(gl);\r\n this.shader = gl.createShader(this.type);\r\n gl.shaderSource(this.shader, this.text);\r\n gl.compileShader(this.shader);\r\n },\r\n getCompilationResult: function(gl, errorCallback) {\r\n if (!gl.getShaderParameter(this.shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\r\n var err = gl.getShaderInfoLog(this.shader);\r\n this.processErrors(err, this.text);\r\n var splittedText = this.text.split('\\n');\r\n var newText = '\\n';\r\n for (var i = 0, l = splittedText.length; i < l; ++i) {\r\n newText += i + ' ' + splittedText[i] + '\\n';\r\n }\r\n // still logging whole source but folded\r\n notify.errorFold(\"can't compile shader\", newText);\r\n if (errorCallback) errorCallback(this.text, newText, err);\r\n\r\n return false;\r\n }\r\n return true;\r\n },\r\n releaseGLObjects: function() {\r\n if (this._gl !== undefined) {\r\n Shader.deleteGLShader(this._gl, this.shader);\r\n GLObject.removeObject(this._gl, this);\r\n }\r\n this.invalidate();\r\n },\r\n invalidate: function() {\r\n this.shader = undefined;\r\n }\r\n }),\r\n 'osg',\r\n 'Shader'\r\n);\r\n\r\nexport default Shader;","class EventHandle {\r\n constructor(owner, name, fn) {\r\n this.owner = owner;\r\n this.name = name;\r\n this.fn = fn;\r\n }\r\n\r\n unbind() {\r\n if (!this.owner) return;\r\n this.owner.unbind(this.name, this.fn);\r\n this.owner = null;\r\n this.name = null;\r\n this.fn = null;\r\n }\r\n\r\n call() {\r\n if (!this.fn) return;\r\n\r\n this.fn.call(\r\n this.owner,\r\n arguments[0],\r\n arguments[1],\r\n arguments[2],\r\n arguments[3],\r\n arguments[4],\r\n arguments[5],\r\n arguments[6],\r\n arguments[7],\r\n );\r\n }\r\n\r\n on(name, fn) {\r\n return this.owner.on(name, fn);\r\n }\r\n}\r\n\r\nclass WeightEventHandle {\r\n constructor(owner, name, fn) {\r\n this.owner = owner;\r\n this.name = name;\r\n this.fn = fn;\r\n }\r\n\r\n unbind() {\r\n if (!this.owner) return;\r\n\r\n this.owner.unbindWeight(this.name, this.fn);\r\n this.owner = null;\r\n this.name = null;\r\n this.fn = null;\r\n }\r\n}\r\n\r\n\r\nclass Events {\r\n constructor() {\r\n this._events = {};\r\n this._suspendEvents = false;\r\n this._weightEvents = {};\r\n }\r\n\r\n get suspendEvents() {\r\n return this._suspendEvents;\r\n }\r\n set suspendEvents(value) {\r\n this._suspendEvents = !!value;\r\n }\r\n\r\n nextTick(name, fn) {\r\n this.on(name, (function() {\r\n let timer = null;\r\n return function(...args) {\r\n if (timer) clearTimeout(timer);\r\n timer = setTimeout(fn.bind(null, ...args))\r\n }\r\n }()))\r\n }\r\n\r\n on(name, fn) {\r\n let events = this._events[name];\r\n if (events === undefined) {\r\n this._events[name] = [fn];\r\n } else {\r\n if (events.indexOf(fn) == -1) events.push(fn);\r\n }\r\n return new EventHandle(this, name, fn);\r\n }\r\n\r\n //按高优先级进行响应\r\n onHighWeight(name, weight, fn) {\r\n\r\n let events = this._weightEvents[name];\r\n if (events === undefined) {\r\n this._weightEvents[name] = [{ weight: weight, fn }];\r\n } else {\r\n let event = { weight: weight, fn };\r\n let n = events.length;\r\n let ok = false;\r\n for (let i = 0; i < n; i++) {\r\n if (weight > events[i].weight) {\r\n events.splice(i, 0, event);\r\n ok = true;\r\n break;\r\n }\r\n }\r\n if (!ok) {\r\n events.push(event);\r\n }\r\n }\r\n return new WeightEventHandle(this, name, fn);\r\n }\r\n\r\n once(name, fn) {\r\n let self = this;\r\n let evt = this.on(\r\n name,\r\n function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {\r\n fn.call(self, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\r\n evt.unbind();\r\n },\r\n );\r\n return evt;\r\n }\r\n\r\n\r\n emit(name, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {\r\n if (this._suspendEvents) return;\r\n\r\n let events = this._events[name];\r\n if (!events) return this;\r\n\r\n events = events.slice(0);\r\n\r\n for (let i = 0; i < events.length; i++) {\r\n if (!events[i]) continue;\r\n\r\n try {\r\n events[i].call(this, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\r\n } catch (ex) {\r\n console.info(\r\n '%c%s %c(event error)',\r\n 'color: #06f',\r\n name,\r\n 'color: #f00',\r\n );\r\n console.error(ex);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n emitHighWeight(name, ...args) {\r\n if (this._suspendHighEvents) return;\r\n\r\n let events = this._weightEvents[name];\r\n if (!events) return this;\r\n\r\n let event = events[0];\r\n try {\r\n event.fn.call(this, ...args);\r\n } catch (ex) {\r\n console.info(\r\n '%c%s %c(emitHighWeight error)',\r\n 'color: #06f',\r\n name,\r\n 'color: #f00',\r\n );\r\n console.error(ex);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n\r\n unbindWeight(name, fn) {\r\n\r\n if (!name) {\r\n this._weightEvents = {};\r\n return this;\r\n }\r\n\r\n let events = this._weightEvents[name];\r\n if (!events) return this;\r\n\r\n if (!fn) {\r\n delete this._weightEvents[name];\r\n return this;\r\n }\r\n\r\n let n = events.length;\r\n while (n--) {\r\n if (events[n].fn == fn) {\r\n\r\n if (events.length === 1) {\r\n delete this._weightEvents[name];\r\n return this;\r\n }\r\n events.splice(n, 1);\r\n break;\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n unbind(name, fn) {\r\n if (name) {\r\n let events = this._events[name];\r\n if (!events) return this;\r\n\r\n if (fn) {\r\n let i = events.indexOf(fn);\r\n if (i !== -1) {\r\n if (events.length === 1) {\r\n delete this._events[name];\r\n } else {\r\n events.splice(i, 1);\r\n }\r\n }\r\n } else {\r\n delete this._events[name];\r\n }\r\n } else {\r\n this._events = {};\r\n }\r\n return this;\r\n }\r\n}\r\n\r\nexport {\r\n EventHandle,\r\n Events\r\n};","export default {\r\n allowSwiftShader: false,\r\n animationAutoplay: true,\r\n anisotropy: true,\r\n annotation: 0,\r\n annotationTooltipVisible: true,\r\n arkit: false,\r\n arkitDebug: false,\r\n asyncImage: false,\r\n asyncShader: 0,\r\n autoMaterial: 0,\r\n autospin: 0,\r\n autostart: true,\r\n camera: false,\r\n cameraConstraints: true,\r\n cameraFollowBones: 0,\r\n cardboard: 0,\r\n carmel: false,\r\n cleanShader: false,\r\n continuousRender: false,\r\n convertVertexColor8Bit: true,\r\n debug3D: false,\r\n depthMipmap: 0,\r\n dofAttenuateDistance: true,\r\n dofAttenuateSpeed: false,\r\n dofCircle: true,\r\n dofRes: 2,\r\n dofSticky: false,\r\n dofTransition: true,\r\n doubleClick: true,\r\n downloadPicture: false,\r\n drs: true,\r\n drsRatio: 1,\r\n drsFps: 15,\r\n drsMin: 0.8,\r\n drsTest: false,\r\n epsilonAlpha: 0.00001,\r\n floatRtt: 2,\r\n forceController: '',\r\n forceControllerOrientation: -0.5,\r\n forceControllerRayOrientation: -0.075,\r\n forceFallback: false,\r\n forceMs: 0,\r\n forceTriangles: false,\r\n fpsSpeed: 5,\r\n grainSpeed: 64,\r\n graphOptimizer: false,\r\n imageCompression: false,\r\n internal: false,\r\n isApp: false,\r\n keepEmptyGeometries: false,\r\n materialNames: 'main_material',\r\n materialPacking: true,\r\n materialShowcase: false,\r\n maxTextureUnits: 32,\r\n maxDevicePixelRatio: 3.0,\r\n maxTextureSize: 8192,\r\n maxVertexUniforms: 8192,\r\n mergeMaterials: false,\r\n morphEpsilon: 0.05,\r\n morphGpu: 4,\r\n navigation: 'orbit',\r\n orbitPanFactor: 1,\r\n orbitRotationFactor: 1,\r\n orbitZoomFactor: 1,\r\n panorama: false,\r\n powerPreference: 'high-performance',\r\n preload: false,\r\n preserveDrawingBuffer: false,\r\n processMaterial: false,\r\n processOptions: false,\r\n refractionRes: 1,\r\n resizeTimeout: 16,\r\n rgbm: true,\r\n scale: 1,\r\n scaleEpsilon: 0.00001,\r\n scrollwheel: true,\r\n shadow: true,\r\n shadowAtlas: true,\r\n shadowJitterOffset: 'default',\r\n shadowNormalOffset: false,\r\n shadowPCF: '1Tap(4texFetch)',\r\n shadowTextureSize: 1024,\r\n share: false,\r\n snapKeyframe: false,\r\n soundEnable: true,\r\n soundMute: false,\r\n soundPreload: false,\r\n splitLimit: 65535,\r\n ssaoNormal: false,\r\n ssrTransparent: false,\r\n sssJitter: 1,\r\n sssKernel: 17,\r\n stats: false,\r\n svgSize: 2048,\r\n substanceDisplacement: false,\r\n supersample: true,\r\n tracking: false,\r\n taaAnimation: false,\r\n taaFeedbackMax: 0.97,\r\n taaFeedbackMin: 0.88,\r\n textureFrameBudget: 512,\r\n transparent: false,\r\n uiAnimations: true,\r\n uiAnnotations: true,\r\n uiAr: false,\r\n uiArHelp: true,\r\n uiArQrcode: true,\r\n uiColor: '',\r\n uiControls: true,\r\n uiFadeout: false,\r\n uiFullscreen: true,\r\n uiGeneralControls: true,\r\n uiHelp: true,\r\n uiHint: 1,\r\n uiInfos: false,\r\n uiInspector: true,\r\n uiInspectorOpen: false,\r\n uiLoading: true,\r\n uiSettings: true,\r\n uiSnapshots: true,\r\n uiSound: true,\r\n uiStart: true,\r\n uiStop: false,\r\n uiTheatre: false,\r\n uiVr: true,\r\n uiWatermark: false,\r\n uiWatermarkLink: true,\r\n unitRenderLocal: false,\r\n unitRenderReporter: 'html',\r\n useVao: true,\r\n varyingSorting: true,\r\n vrAr: false,\r\n vrBrowserEnv: 'c0022acc4f3242e2bcae8043e08df8cc',\r\n vrFade: 200,\r\n vrLauncherAlphaCardFactor: 1,\r\n vrMirror: false,\r\n vrMobileMaxFaces: 50000,\r\n vrGenerateUiTextures: true,\r\n vrForceRaf: false,\r\n vrLinkNavigation: 0,\r\n vrInNavigation: 0,\r\n vrScaleRtt: 0,\r\n vrStereo: true,\r\n webglExt: true,\r\n webglRestore: 3,\r\n webglTimerGpu: false,\r\n webglUniforms: false,\r\n zoct: false,\r\n zq: true,\r\n zw: true,\r\n zratio: 50,\r\n zz: false,\r\n annotationCycleAutostart: false,\r\n annotationCycleDuration: 5000,\r\n sssHalfKernel: 9,\r\n preferOriginalNormalMap: false,\r\n};\r\n","export default {\r\n 'utils/common.glsl':\r\n '#define PI 3.141593\\n#define saturate(_x) clamp(_x, 0., 1.)\\n',\r\n 'utils/functions.glsl':\r\n \"// approximation such as http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html\\n// introduced slightly darker colors and more slight banding in the darks.\\n\\n// so we stick with the reference implementation (except we don't check if color >= 0.0):\\n// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt\\n#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055\\n#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)\\n\\nfloat linearTosRGB(const in float color) { return LIN_SRGB(color); }\\nvec3 linearTosRGB(const in vec3 color) { return vec3(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b)); }\\nvec4 linearTosRGB(const in vec4 color) { return vec4(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b), color.a); }\\n\\nfloat sRGBToLinear(const in float color) { return SRGB_LIN(color); }\\nvec3 sRGBToLinear(const in vec3 color) { return vec3(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b)); }\\nvec4 sRGBToLinear(const in vec4 color) { return vec4(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b), color.a); }\\n\\n//http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\\nvec3 RGBMToRGB( const in vec4 rgba ) {\\n const float maxRange = 8.0;\\n return rgba.rgb * maxRange * rgba.a;\\n}\\n\\nconst mat3 LUVInverse = mat3( 6.0013, -2.700, -1.7995, -1.332, 3.1029, -5.7720, 0.3007, -1.088, 5.6268 );\\n\\nvec3 LUVToRGB( const in vec4 vLogLuv ) {\\n float Le = vLogLuv.z * 255.0 + vLogLuv.w;\\n vec3 Xp_Y_XYZp;\\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;\\n Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;\\n vec3 vRGB = LUVInverse * Xp_Y_XYZp;\\n return max(vRGB, 0.0);\\n}\\n\\n// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\\nvec4 encodeRGBM(const in vec3 color, const in float range) {\\n if(range <= 0.0) return vec4(color, 1.0);\\n vec4 rgbm;\\n vec3 col = color / range;\\n rgbm.a = clamp( max( max( col.r, col.g ), max( col.b, 1e-6 ) ), 0.0, 1.0 );\\n rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;\\n rgbm.rgb = col / rgbm.a;\\n return rgbm;\\n}\\n\\nvec3 decodeRGBM(const in vec4 color, const in float range) {\\n if(range <= 0.0) return color.rgb;\\n return range * color.rgb * color.a;\\n}\\n\",\r\n 'shadowing/shadowReceive.glsl':\r\n \"#extension GL_OES_standard_derivatives : enable\\n\\n%UNROLL 4%\\n#ifdef HAS_SHADOW_%ID%\\n uniform float uShadowReceive%ID%_bias;\\n uniform float uStaticFrameNumShadow%ID%;\\n uniform vec2 uShadow_Texture%ID%_depthRange;\\n uniform vec3 uShadow_Texture%ID%_projection;\\n uniform vec4 uShadow_Texture%ID%_viewLook;\\n uniform vec4 uShadow_Texture%ID%_viewRight;\\n uniform vec4 uShadow_Texture%ID%_viewUp;\\n\\n #ifdef _ATLAS_SHADOW\\n uniform vec4 uShadow_Texture%ID%_mapSize;\\n #else\\n uniform vec2 uShadow_Texture%ID%_renderSize;\\n #endif\\n#endif // HAS_SHADOW\\n%%\\n\\n// TODO rename sampler uniform to be better and sync with light number (e.g: sShadow0, sShadow1, etc)\\n#ifdef _ATLAS_SHADOW\\n uniform vec2 uShadow_Texture0_renderSize;\\n uniform sampler2D Texture12;\\n#else\\n #ifdef HAS_SHADOW_0\\n uniform sampler2D Texture12;\\n #define TEX_SHADOW_0 Texture12\\n #endif\\n #ifdef HAS_SHADOW_1\\n uniform sampler2D Texture13;\\n #define TEX_SHADOW_1 Texture13\\n #endif\\n #ifdef HAS_SHADOW_2\\n uniform sampler2D Texture14;\\n #define TEX_SHADOW_2 Texture14\\n #endif\\n #ifdef HAS_SHADOW_3\\n uniform sampler2D Texture15;\\n #define TEX_SHADOW_3 Texture15\\n #endif\\n#endif // _ATLAS_SHADOW\\n\\n#ifdef _OUT_DISTANCE\\n#define OPT_ARG_outDistance ,out float outDistance\\n#define OPT_INSTANCE_ARG_outDistance ,outDistance\\n#else\\n#define OPT_ARG_outDistance\\n#define OPT_INSTANCE_ARG_outDistance\\n#endif\\n\\n#ifdef _ATLAS_SHADOW\\n#define OPT_ARG_atlasSize ,const in vec4 atlasSize\\n#else\\n#define OPT_ARG_atlasSize\\n#endif\\n\\n#ifdef _NORMAL_OFFSET\\n#define OPT_ARG_normalBias ,const in float normalBias\\n#else\\n#define OPT_ARG_normalBias\\n#endif\\n\\n#ifdef _JITTER_OFFSET\\n#define OPT_ARG_jitter ,const in float jitter\\n#define OPT_INSTANCE_ARG_jitter ,jitter\\n#else\\n#define OPT_ARG_jitter\\n#define OPT_INSTANCE_ARG_jitter\\n#endif\\n\\n#pragma include \\\"shadowing/tapPCF.glsl\\\"\\n\\nfloat shadowReceive(const in bool lighted,\\n const in vec3 normalWorld,\\n const in vec3 vertexWorld,\\n\\n const in sampler2D shadowTexture,\\n\\n const in vec2 shadowSize,\\n const in vec3 shadowProjection,\\n\\n const in vec4 shadowViewRight,\\n const in vec4 shadowViewUp,\\n const in vec4 shadowViewLook,\\n\\n\\n const in vec2 shadowDepthRange,\\n const in float shadowBias\\n OPT_ARG_atlasSize\\n OPT_ARG_normalBias\\n OPT_ARG_outDistance\\n OPT_ARG_jitter) {\\n\\n // 0 for early out\\n bool earlyOut = false;\\n\\n // Calculate shadow amount\\n float shadow = 1.0;\\n\\n if (!lighted) {\\n shadow = 0.0;\\n#ifndef _OUT_DISTANCE\\n earlyOut = true;\\n#endif // _OUT_DISTANCE\\n }\\n\\n if (shadowDepthRange.x == shadowDepthRange.y) {\\n earlyOut = true;\\n }\\n\\n vec4 shadowVertexEye;\\n vec4 shadowNormalEye;\\n float shadowReceiverZ = 0.0;\\n vec4 shadowVertexProjected;\\n vec2 shadowUV;\\n float N_Dot_L;\\n float invDepthRange;\\n\\n if (!earlyOut) {\\n\\n shadowVertexEye.x = dot(shadowViewRight.xyz, vertexWorld.xyz) + shadowViewRight.w;\\n shadowVertexEye.y = dot(shadowViewUp.xyz, vertexWorld.xyz) + shadowViewUp.w;\\n shadowVertexEye.z = dot(shadowViewLook.xyz, vertexWorld.xyz) + shadowViewLook.w;\\n shadowVertexEye.w = 1.0;\\n\\n\\n // derivated, only need z.\\n //vec3 shadowLightDir = vec3(0.0, 0.0, 1.0); // in shadow view light is camera\\n //shadowNormalEye = shadowViewMatrix * normalFront;\\n //shadowNormalEye.x = dot(shadowViewRight.xyz, normalWorld.xyz);\\n //shadowNormalEye.y = dot(shadowViewUp.xyz, normalWorld.xyz);\\n shadowNormalEye.z = dot(shadowViewLook.xyz, normalWorld.xyz);\\n //shadowNormalEye.w = 0.0;\\n\\n //N_Dot_L = dot(shadowNormalEye.xyz, shadowLightDir);\\n N_Dot_L = shadowNormalEye.z;\\n\\n if (!earlyOut) {\\n\\n invDepthRange = 1.0 / (shadowDepthRange.y - shadowDepthRange.x);\\n\\n#ifdef _NORMAL_OFFSET\\n\\n // http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png\\n float normalOffsetScale = clamp(1.0 - N_Dot_L, 0.0 , 1.0);\\n normalOffsetScale *= abs((shadowVertexEye.z - shadowDepthRange.x) * invDepthRange);\\n normalOffsetScale *= max(shadowProjection.x, shadowProjection.y);\\n normalOffsetScale *= normalBias * invDepthRange;\\n\\n\\n vec4 shadowNormalShift = vec4(normalWorld, 0.0) * normalOffsetScale;\\n shadowNormalEye.x = dot(shadowViewRight.xyz, shadowNormalShift.xyz);\\n shadowNormalEye.y = dot(shadowViewUp.xyz, shadowNormalShift.xyz);\\n shadowNormalEye.z = dot(shadowViewLook.xyz, shadowNormalShift.xyz);\\n shadowNormalEye.w = 0.0;\\n\\n vec4 viewShadow = shadowVertexEye + shadowNormalEye;\\n#else\\n vec4 viewShadow = shadowVertexEye;\\n#endif\\n\\n\\n if (shadowProjection.z == 0.0){\\n\\n // X, 0, 0, 0,\\n // 0, Y, 0, 0,\\n // 0, 0, -1, -1,\\n // 0, 0, -2.0*znear, 0\\n // mat4 shadowProjectionMatrix;\\n // shadowProjectionMatrix[0] = vec4(shadowProjection.x, 0.0, 0.0, 0.0 );\\n // shadowProjectionMatrix[1] = vec4(0.0, shadowProjection.y, 0.0, 0.0 );\\n // shadowProjectionMatrix[2] = vec4(0.0, 0.0, -1.0, -1.0 );\\n // shadowProjectionMatrix[3] = vec4(0.0, 0.0, -2.0*shadowDepthRange.x, 0.0 );\\n // shadowVertexProjected = shadowProjectionMatrix * shadowVertexEye;\\n\\n // derivated optimisation\\n shadowVertexProjected.x = shadowProjection.x * viewShadow.x;\\n shadowVertexProjected.y = shadowProjection.y * viewShadow.y;\\n\\n shadowVertexProjected.z = - viewShadow.z - (2.0 * shadowDepthRange.x * viewShadow.w);\\n shadowVertexProjected.w = - viewShadow.z;\\n\\n }\\n else{\\n // lr = 1/(left-right);\\n // bt = 1/(bottom-top);\\n // nf = 1/(near-far);\\n // -2*lr, 0, 0, 0,\\n // 0, -2*bt, 0, 0,\\n // 0, 0, 2*nf, 0.0,\\n // (left+right)*lr, (top+bottom)*bt, (far+near)*nf), 1\\n // here left = -right && top = -bottom\\n // float lr = 1.0 / (-2.0 * shadowProjection.x);\\n // float bt = 1.0 / (-2.0 * shadowProjection.y);\\n // float nf = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\\n float nfNeg = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\\n float nfPos = (shadowDepthRange.x + shadowDepthRange.y)*nfNeg;\\n\\n //mat4 shadowProjectionMatrix;\\n //shadowProjectionMatrix[0] = vec4(1.0 / shadowProjection.x, 0.0, 0.0, 0.0 );\\n //shadowProjectionMatrix[1] = vec4(0.0, 1.0 / shadowProjection.y, 0.0, 0.0 );\\n //shadowProjectionMatrix[2] = vec4(0.0, 0.0, 2.0*nfNeg, 0.0 );\\n //shadowProjectionMatrix[3] = vec4(0.0, 0.0, nfPos, 1.0 );\\n //shadowdertexProjected = shadowProjectionMatrix * shadowVertexEye;\\n\\n // derivated optimisation\\n shadowVertexProjected.x = viewShadow.x / shadowProjection.x;\\n shadowVertexProjected.y = viewShadow.y / shadowProjection.y;\\n\\n shadowVertexProjected.z = 2.0 * nfNeg* viewShadow.z + nfPos * viewShadow.w;\\n shadowVertexProjected.w = viewShadow.w;\\n\\n }\\n\\n\\n if (shadowVertexProjected.w < 0.0) {\\n earlyOut = true; // notably behind camera\\n }\\n\\n }\\n\\n if (!earlyOut) {\\n\\n shadowUV.xy = shadowVertexProjected.xy / shadowVertexProjected.w;\\n shadowUV.xy = shadowUV.xy * 0.5 + 0.5;// mad like\\n\\n if (any(bvec4 ( shadowUV.x > 1., shadowUV.x < 0., shadowUV.y > 1., shadowUV.y < 0.))) {\\n earlyOut = true;// limits of light frustum\\n }\\n\\n // most precision near 0, make sure we are near 0 and in [0,1]\\n shadowReceiverZ = - shadowVertexEye.z;\\n shadowReceiverZ = (shadowReceiverZ - shadowDepthRange.x) * invDepthRange;\\n\\n if(shadowReceiverZ < 0.0) {\\n earlyOut = true; // notably behind camera\\n }\\n\\n }\\n }\\n\\n // pcf pbias to add on offset\\n vec2 shadowBiasPCF = vec2 (0.);\\n\\n#ifdef GL_OES_standard_derivatives\\n#ifdef _RECEIVERPLANEDEPTHBIAS\\n vec2 biasUV;\\n\\n vec3 texCoordDY = dFdx(shadowVertexEye.xyz);\\n vec3 texCoordDX = dFdy(shadowVertexEye.xyz);\\n\\n biasUV.x = texCoordDY.y * texCoordDX.z - texCoordDX.y * texCoordDY.z;\\n biasUV.y = texCoordDX.x * texCoordDY.z - texCoordDY.x * texCoordDX.z;\\n biasUV *= 1.0 / ((texCoordDX.x * texCoordDY.y) - (texCoordDX.y * texCoordDY.x));\\n\\n // Static depth biasing to make up for incorrect fractional sampling on the shadow map grid\\n float fractionalSamplingError = dot(vec2(1.0, 1.0) * shadowSize.xy, abs(biasUV));\\n float receiverDepthBias = min(fractionalSamplingError, 0.01);\\n\\n shadowBiasPCF.x = biasUV.x;\\n shadowBiasPCF.y = biasUV.y;\\n\\n shadowReceiverZ += receiverDepthBias;\\n\\n#else // _RECEIVERPLANEDEPTHBIAS\\n shadowBiasPCF.x = clamp(dFdx(shadowReceiverZ) * shadowSize.x, -1.0, 1.0 );\\n shadowBiasPCF.y = clamp(dFdy(shadowReceiverZ) * shadowSize.y, -1.0, 1.0 );\\n#endif\\n\\n#endif // GL_OES_standard_derivatives\\n\\n\\n vec4 clampDimension;\\n\\n#ifdef _ATLAS_SHADOW\\n shadowUV.xy = ((shadowUV.xy * atlasSize.zw ) + atlasSize.xy) * shadowSize.xy;\\n\\n // clamp uv bias/filters by half pixel to avoid point filter on border\\n clampDimension.xy = atlasSize.xy + vec2(0.5);\\n clampDimension.zw = (atlasSize.xy + atlasSize.zw) - vec2(0.5);\\n\\n clampDimension = clampDimension * shadowSize.xyxy;\\n#else\\n clampDimension = vec4(0.0, 0.0, 1.0, 1.0);\\n#endif // _RECEIVERPLANEDEPTHBIAS\\n\\n\\n // now that derivatives is done and we don't access any mipmapped/texgrad texture we can early out\\n // see http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers\\n if (earlyOut) {\\n // empty statement because of weird gpu intel bug\\n } else {\\n\\n // depth bias: fighting shadow acne (depth imprecsion z-fighting)\\n // cosTheta is dot( n, l ), clamped between 0 and 1\\n // float shadowBias = 0.005*tan(acos(N_Dot_L));\\n // same but 4 cycles instead of 15\\n float depthBias = 0.05 * sqrt( 1.0 - N_Dot_L * N_Dot_L) / clamp(N_Dot_L, 0.0005, 1.0);\\n\\n // That makes sure that plane perpendicular to light doesn't flicker due to\\n // selfshadowing and 1 = dot(Normal, Light) using a min bias\\n depthBias = clamp(depthBias, 0.00005, 2.0 * shadowBias);\\n\\n // shadowZ must be clamped to [0,1]\\n // otherwise it's not comparable to shadow caster depth map\\n // which is clamped to [0,1]\\n // Not doing that makes ALL shadowReceiver > 1.0 black\\n // because they ALL becomes behind any point in Caster depth map\\n shadowReceiverZ = clamp(shadowReceiverZ, 0.0, 1.0 -depthBias) - depthBias;\\n\\n // Now computes Shadow\\n float res = getShadowPCF(shadowTexture,\\n shadowSize,\\n shadowUV,\\n shadowReceiverZ,\\n shadowBiasPCF,\\n clampDimension\\n OPT_INSTANCE_ARG_outDistance\\n OPT_INSTANCE_ARG_jitter);\\n#ifdef _OUT_DISTANCE\\n if (lighted) shadow = res;\\n outDistance *= shadowDepthRange.y - shadowDepthRange.x; // world space distance\\n#else\\n shadow = res;\\n#endif // _OUT_DISTANCE\\n }\\n\\n return shadow;\\n\\n}\\n\",\r\n 'shadowing/shadowLinearSoft.glsl':\r\n 'float decodeFloatRGBA(const in vec4 rgba) {\\n return dot(rgba, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\\n}\\n\\nfloat getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){\\n#ifndef _FLOATTEX\\n return decodeFloatRGBA(texture2D(depths, uv));\\n#else\\n return texture2D(depths, uv).x;\\n#endif\\n}\\n\\n// simulation of texture2Dshadow glsl call on HW\\n// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/\\nfloat texture2DCompare(const in sampler2D depths,\\n const in vec2 uv,\\n const in float compare,\\n const in vec4 clampDimension){\\n float depth = getSingleFloatFromTex(depths, clamp(uv, clampDimension.xy, clampDimension.zw));\\n return compare - depth;\\n}\\n\\n#ifdef _JITTER_OFFSET\\n// TODO could be in a random.glsl file\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\\nfloat shadowInterleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\\n}\\n#endif\\n\\n// simulates linear fetch like texture2d shadow\\nfloat texture2DShadowLerp(\\n const in sampler2D depths,\\n const in vec2 size,\\n const in vec2 uv,\\n const in float compare,\\n const in vec4 clampDimension\\n OPT_ARG_outDistance\\n OPT_ARG_jitter){\\n\\n vec2 centroidCoord = uv / size.xy;\\n\\n#ifdef _JITTER_OFFSET\\n if (jitter > 0.0){\\n centroidCoord += shadowInterleavedGradientNoise(gl_FragCoord.xy, jitter);\\n }\\n#endif\\n\\n centroidCoord = centroidCoord + 0.5;\\n vec2 f = fract(centroidCoord);\\n vec2 centroidUV = floor(centroidCoord) * size.xy;\\n\\n vec4 fetches;\\n const vec2 shift = vec2(1.0, 0.0);\\n fetches.x = texture2DCompare(depths, centroidUV + size.xy * shift.yy, compare, clampDimension);\\n fetches.y = texture2DCompare(depths, centroidUV + size.xy * shift.yx, compare, clampDimension);\\n fetches.z = texture2DCompare(depths, centroidUV + size.xy * shift.xy, compare, clampDimension);\\n fetches.w = texture2DCompare(depths, centroidUV + size.xy * shift.xx, compare, clampDimension);\\n\\n#ifdef _OUT_DISTANCE\\n float _a = mix(fetches.x, fetches.y, f.y);\\n float _b = mix(fetches.z, fetches.w, f.y);\\n outDistance = mix(_a, _b, f.x);\\n#endif\\n\\n vec4 st = step(fetches, vec4(0.0));\\n\\n float a = mix(st.x, st.y, f.y);\\n float b = mix(st.z, st.w, f.y);\\n return mix(a, b, f.x);\\n}\\n',\r\n 'shadowing/tapPCF.glsl':\r\n '#pragma include \"shadowing/shadowLinearSoft.glsl\"\\n\\nfloat getShadowPCF(\\n const in sampler2D depths,\\n const in vec2 size,\\n const in vec2 uv,\\n const in float compare,\\n const in vec2 biasPCF,\\n const in vec4 clampDimension\\n OPT_ARG_outDistance\\n OPT_ARG_jitter) {\\n\\n float res = 0.0;\\n\\n res += texture2DShadowLerp(depths, size, uv + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter);\\n\\n\\n#if defined(_PCFx1)\\n\\n#else\\n\\n float dx0 = -size.x;\\n float dy0 = -size.y;\\n float dx1 = size.x;\\n float dy1 = size.y;\\n\\n#define TSF(o1,o2) texture2DShadowLerp(depths, size, uv + vec2(o1, o2) + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter)\\n\\n res += TSF(dx0, dx0);\\n res += TSF(dx0, .0);\\n res += TSF(dx0, dx1);\\n\\n#if defined(_PCFx4)\\n\\n res /=4.0;\\n\\n#elif defined(_PCFx9)\\n res += TSF(.0, dx0);\\n res += TSF(.0, dx1);\\n\\n res += TSF(dx1, dx0);\\n res += TSF(dx1, .0);\\n res += TSF(dx1, dx1);\\n\\n\\n res /=9.0;\\n\\n#elif defined(_PCFx25)\\n\\n float dx02 = 2.0*dx0;\\n float dy02 = 2.0*dy0;\\n float dx2 = 2.0*dx1;\\n float dy2 = 2.0*dy1;\\n\\n // complete row above\\n res += TSF(dx0, dx02);\\n res += TSF(dx0, dx2);\\n\\n res += TSF(.0, dx02);\\n res += TSF(.0, dx2);\\n\\n res += TSF(dx1, dx02);\\n res += TSF(dx1, dx2);\\n\\n // two new col\\n res += TSF(dx02, dx02);\\n res += TSF(dx02, dx0);\\n res += TSF(dx02, .0);\\n res += TSF(dx02, dx1);\\n res += TSF(dx02, dx2);\\n\\n res += TSF(dx2, dx02);\\n res += TSF(dx2, dx0);\\n res += TSF(dx2, .0);\\n res += TSF(dx2, dx1);\\n res += TSF(dx2, dx2);\\n\\n\\n res/=25.0;\\n\\n#endif\\n\\n#undef TSF\\n\\n#endif\\n return res;\\n}\\n/////// end Tap\\n',\r\n 'utils/lightCommon.glsl':\r\n '#define LIGHT_SPOT 0\\n#define LIGHT_POINT 1\\n#define LIGHT_DIRECTION 2\\n#define LIGHT_HEMI 3\\n\\n%UNROLL 4%\\n#ifdef LIGHT_TYPE_%ID%\\n uniform vec4 uEditorLight%ID%_diffuse;\\n\\n #if LIGHT_TYPE_%ID% == LIGHT_DIRECTION\\n uniform vec3 uEditorLight%ID%_viewDirection;\\n #elif LIGHT_TYPE_%ID% == LIGHT_SPOT\\n uniform vec3 uEditorLight%ID%_viewDirection;\\n uniform vec4 uEditorLight%ID%_viewPosition;\\n uniform float uEditorLight%ID%_spotBlend;\\n uniform float uEditorLight%ID%_spotCutOff;\\n uniform vec4 uEditorLight%ID%_attenuation;\\n #elif LIGHT_TYPE_%ID% == LIGHT_POINT\\n uniform vec4 uEditorLight%ID%_viewPosition;\\n uniform vec4 uEditorLight%ID%_attenuation;\\n #elif LIGHT_TYPE_%ID% == LIGHT_HEMI\\n uniform vec4 uEditorLight%ID%_ground;\\n uniform vec3 uEditorLight%ID%_viewDirection;\\n #endif\\n#endif // LIGHT_TYPE\\n%%\\n\\nfloat getLightAttenuation(const in float dist, const in vec4 lightAttenuation) {\\n // lightAttenuation(constantEnabled, linearEnabled, quadraticEnabled)\\n // TODO find a vector alu instead of 4 scalar\\n float constant = lightAttenuation.x;\\n float linear = lightAttenuation.y * dist;\\n float quadratic = lightAttenuation.z * dist * dist;\\n return 1.0 / (constant + linear + quadratic);\\n}\\n\\nvoid precomputeSpot(\\n const in vec3 normal,\\n const in vec3 viewVertex,\\n \\n const in vec3 lightViewDirection,\\n const in vec4 lightAttenuation,\\n const in vec3 lightViewPosition,\\n const in float lightSpotCutOff,\\n const in float lightSpotBlend,\\n \\n out float attenuation,\\n out vec3 eyeLightDir,\\n out float dotNL) {\\n\\n eyeLightDir = lightViewPosition - viewVertex;\\n float dist = length(eyeLightDir);\\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\\n\\n float cosCurAngle = dot(-eyeLightDir, lightViewDirection);\\n float spot = cosCurAngle * smoothstep(0.0, 1.0, (cosCurAngle - lightSpotCutOff) / lightSpotBlend);\\n\\n dotNL = dot(eyeLightDir, normal);\\n attenuation = spot * getLightAttenuation(dist, lightAttenuation);\\n}\\n\\nvoid precomputePoint(\\n const in vec3 normal,\\n const in vec3 viewVertex,\\n\\n const in vec4 lightAttenuation,\\n const in vec3 lightViewPosition,\\n\\n out float attenuation,\\n out vec3 eyeLightDir,\\n out float dotNL) {\\n\\n eyeLightDir = lightViewPosition - viewVertex;\\n float dist = length(eyeLightDir);\\n\\n attenuation = getLightAttenuation(dist, lightAttenuation);\\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\\n dotNL = dot(eyeLightDir, normal);\\n}\\n\\nvoid precomputeSun(\\n const in vec3 normal,\\n const in vec3 lightViewDirection,\\n \\n out float attenuation,\\n out vec3 eyeLightDir,\\n out float dotNL) {\\n\\n attenuation = 1.0;\\n eyeLightDir = -lightViewDirection;\\n dotNL = dot(eyeLightDir, normal);\\n}',\r\n 'utils/lights.glsl':\r\n '#pragma include \"utils/lightCommon.glsl\"\\n\\n////////////////\\n// COOK TORRANCE\\n////////////////\\nvec3 specularCookTorrance(\\n const in vec3 normal,\\n const in vec3 lightDir,\\n const in vec3 eyeVector,\\n const in float materialShininess,\\n const in vec3 materialSpecular,\\n const in vec3 lightSpecular) {\\n \\n vec3 h = normalize(eyeVector + lightDir);\\n float nh = dot(normal, h);\\n float specfac = 0.0;\\n\\n if(nh > 0.0) {\\n float nv = max( dot(normal, eyeVector), 0.0 );\\n float i = pow(nh, materialShininess);\\n i = i / (0.1 + nv);\\n specfac = i;\\n }\\n // ugly way to fake an energy conservation (mainly to avoid super bright stuffs with low glossiness)\\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\\n return specfac * materialSpecular * lightSpecular * att;\\n}\\n\\nvec3 lambert(const in float dotNL, const in vec3 materialDiffuse, const in vec3 lightDiffuse) {\\n return dotNL * materialDiffuse * lightDiffuse;\\n}\\n\\nvoid computeLightLambertCookTorrance(\\n const in vec3 normal,\\n const in vec3 eyeVector,\\n const in float dotNL,\\n const in float attenuation,\\n\\n const in vec3 materialDiffuse,\\n const in vec3 materialSpecular,\\n const in float materialShininess,\\n\\n const in vec3 lightDiffuse,\\n const in vec3 lightSpecular,\\n const in vec3 eyeLightDir,\\n\\n out vec3 diffuseOut,\\n out vec3 specularOut,\\n out bool lighted) {\\n\\n lighted = dotNL > 0.0;\\n if (lighted == false) {\\n specularOut = diffuseOut = vec3(0.0);\\n return;\\n }\\n\\n specularOut = attenuation * specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular);\\n diffuseOut = attenuation * lambert(dotNL, materialDiffuse, lightDiffuse);\\n}\\n\\n///////\\n// HEMI\\n///////\\nvoid hemiLight(\\n const in vec3 normal,\\n const in vec3 eyeVector,\\n const in float dotNL,\\n const in vec3 eyeLightDir,\\n\\n const in vec3 materialDiffuse,\\n const in vec3 materialSpecular,\\n const in float materialShininess,\\n\\n const in vec3 lightDiffuse,\\n const in vec3 lightGround,\\n\\n out vec3 diffuseOut,\\n out vec3 specularOut,\\n out bool lighted) {\\n\\n lighted = false;\\n float weight = 0.5 * dotNL + 0.5;\\n diffuseOut = materialDiffuse * mix(lightGround, lightDiffuse, weight);\\n\\n // same cook-torrance as above for sky/ground\\n float skyWeight = 0.5 * dot(normal, normalize(eyeVector + eyeLightDir)) + 0.5;\\n float gndWeight = 0.5 * dot(normal, normalize(eyeVector - eyeLightDir)) + 0.5;\\n float skySpec = pow(skyWeight, materialShininess);\\n float skyGround = pow(gndWeight, materialShininess);\\n float divisor = (0.1 + max( dot(normal, eyeVector), 0.0 ));\\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\\n \\n specularOut = lightDiffuse * materialSpecular * weight * att * (skySpec + skyGround) / divisor;\\n}\\n',\r\n 'utils/lightsPBR.glsl':\r\n '#pragma include \"utils/common.glsl\"\\n#pragma include \"utils/lightCommon.glsl\"\\n\\nvec4 precomputeGGX(const in vec3 normal, const in vec3 eyeVector, const in float roughness) {\\n float NoV = saturate(dot(normal, eyeVector));\\n float r2 = roughness * roughness;\\n return vec4(r2, r2 * r2, NoV, NoV * (1.0 - r2));\\n}\\n\\n// Walter et al. 2007, \"Microfacet models for refraction through rough surfaces\"\\nfloat D_GGX(const vec4 precomputeGGX, const float NoH) {\\n float a2 = precomputeGGX.y;\\n float d = (NoH * a2 - NoH) * NoH + 1.0;\\n return a2 / (PI * d * d);\\n}\\n\\n// Schlick 1994, \"An Inexpensive BRDF Model for Physically-Based Rendering\"\\nvec3 F_Schlick(const vec3 f0, const float f90, const in float VoH) {\\n float VoH5 = pow(1.0 - VoH, 5.0);\\n return f90 * VoH5 + (1.0 - VoH5) * f0;\\n}\\n\\n// greyscale f0 version (clearcoat)\\nfloat F_Schlick(const float f0, const float f90, const in float VoH) {\\n return f0 + (f90 - f0) * pow(1.0 - VoH, 5.0);\\n}\\n\\n\\n// Heitz 2014, \"Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs\"\\nfloat V_SmithCorrelated(const vec4 precomputeGGX, const float NoL) {\\n float a = precomputeGGX.x;\\n float smithV = NoL * (precomputeGGX.w + a);\\n float smithL = precomputeGGX.z * (NoL * (1.0 - a) + a);\\n return 0.5 / (smithV + smithL);\\n // same as\\n // Hammon 2017, \"PBR Diffuse Lighting for GGX+Smith Microsurfaces\"\\n // return 0.5 / mix(2.0 * NoL * NoV, NoL + NoV, precomputeGGX.y)\\n}\\n\\nvec3 specularLobe(const vec4 precomputeGGX, const vec3 normal, const vec3 eyeVector, const vec3 eyeLightDir, const vec3 specular, const float NoL, const float f90) {\\n vec3 H = normalize(eyeVector + eyeLightDir);\\n float NoH = saturate(dot(normal, H));\\n float VoH = saturate(dot(eyeLightDir, H));\\n\\n // distribution / visibility / fresnel\\n float D = D_GGX(precomputeGGX, NoH);\\n float V = V_SmithCorrelated(precomputeGGX, NoL);\\n vec3 F = F_Schlick(specular, f90, VoH);\\n\\n return (D * V * PI) * F; // we multipy by PI because our diffuse is not divided by PI\\n}\\n\\n// pure compute Light PBR\\nvoid computeLightLambertGGX(\\n const in vec3 normal,\\n const in vec3 eyeVector,\\n const in float NoL,\\n const in vec4 precomputeGGX,\\n\\n const in vec3 diffuse,\\n const in vec3 specular,\\n\\n const in float attenuation,\\n const in vec3 lightColor,\\n const in vec3 eyeLightDir,\\n const in float f90,\\n\\n out vec3 diffuseOut,\\n out vec3 specularOut,\\n out bool lighted) {\\n\\n lighted = NoL > 0.0;\\n if (lighted == false) {\\n specularOut = diffuseOut = vec3(0.0);\\n return;\\n }\\n\\n vec3 colorAttenuate = attenuation * NoL * lightColor;\\n specularOut = colorAttenuate * specularLobe(precomputeGGX, normal, eyeVector, eyeLightDir, specular, NoL, f90);\\n diffuseOut = colorAttenuate * diffuse;\\n}\\n\\n/////////////\\n// ANISOTROPY\\n/////////////\\n\\nfloat V_SmithGGXCorrelated_Anisotropic(float at, float ab, float ToV, float BoV, float ToL, float BoL, float NoV, float NoL) {\\n // Heitz 2014, \"Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs\"\\n // UE4 version : https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L270-L286\\n float lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\\n float lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\\n return 0.5 / (lambdaV + lambdaL);\\n}\\n\\nfloat D_GGX_Anisotropic(const float at, const float ab, const float ToH, const float BoH, const float NoH) {\\n // Burley 2012, \"Physically-Based Shading at Disney\"\\n // https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L81\\n // similar to UE4 version https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L232-L238\\n float a2 = at * ab;\\n vec3 d = vec3(ab * ToH, at * BoH, a2 * NoH);\\n float x = a2 / dot(d, d);\\n return a2 * (x * x) / PI;\\n}\\n\\nvec3 anisotropicLobe(\\n const vec4 precomputeGGX,\\n const vec3 normal,\\n const vec3 eyeVector,\\n\\n const vec3 eyeLightDir,\\n const vec3 specular,\\n const float NoL,\\n const float f90,\\n\\n const in vec3 anisotropicT,\\n const in vec3 anisotropicB,\\n const in float anisotropy) {\\n\\n vec3 H = normalize(eyeVector + eyeLightDir);\\n float NoH = saturate(dot(normal, H));\\n float NoV = saturate(dot(normal, eyeVector));\\n float VoH = saturate(dot(eyeLightDir, H));\\n\\n float ToV = dot(anisotropicT, eyeVector);\\n float BoV = dot(anisotropicB, eyeVector);\\n float ToL = dot(anisotropicT, eyeLightDir);\\n float BoL = dot(anisotropicB, eyeLightDir);\\n float ToH = dot(anisotropicT, H);\\n float BoH = dot(anisotropicB, H);\\n\\n // slide 26, Disney 2012, \"Physically Based Shading at Disney\"\\n // https://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf\\n float aspect = sqrt(1.0 - abs(anisotropy) * 0.9);\\n if (anisotropy > 0.0) aspect = 1.0 / aspect;\\n float at = precomputeGGX.x * aspect;\\n float ab = precomputeGGX.x / aspect;\\n\\n // slide 24, Kulla 2017, \"Revisiting Physically Based Shading at Imageworks\"\\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf\\n // float at = max(0.002025, precomputeGGX.x * (1.0 + anisotropy));\\n // float ab = max(0.002025, precomputeGGX.x * (1.0 - anisotropy));\\n\\n // specular anisotropic BRDF\\n float D = D_GGX_Anisotropic(at, ab, ToH, BoH, NoH);\\n float V = V_SmithGGXCorrelated_Anisotropic(at, ab, ToV, BoV, ToL, BoL, NoV, NoL);\\n vec3 F = F_Schlick(specular, f90, VoH);\\n\\n return (D * V * PI) * F;\\n}\\n\\nvoid computeLightLambertGGXAnisotropy(\\n const in vec3 normal,\\n const in vec3 eyeVector,\\n const in float NoL,\\n const in vec4 precomputeGGX,\\n\\n const in vec3 diffuse,\\n const in vec3 specular,\\n\\n const in float attenuation,\\n const in vec3 lightColor,\\n const in vec3 eyeLightDir,\\n const in float f90,\\n\\n const in vec3 anisotropicT,\\n const in vec3 anisotropicB,\\n const in float anisotropy,\\n\\n out vec3 diffuseOut,\\n out vec3 specularOut,\\n out bool lighted) {\\n\\n lighted = NoL > 0.0;\\n if (lighted == false) {\\n specularOut = diffuseOut = vec3(0.0);\\n return;\\n }\\n\\n vec3 colorAttenuate = attenuation * NoL * lightColor;\\n specularOut = colorAttenuate * anisotropicLobe(precomputeGGX, normal, eyeVector, eyeLightDir, specular, NoL, f90, anisotropicT, anisotropicB, anisotropy);\\n diffuseOut = colorAttenuate * diffuse;\\n}\\n',\r\n 'utils/lightsSSS.glsl':\r\n '#pragma include \"utils/common.glsl\"\\n#pragma include \"utils/lightCommon.glsl\"\\n\\n///////////////////////////\\n/// SUBSURFACE TRANSLUCENCY\\n///////////////////////////\\nvec3 computeLightSSS(\\n const in float dotNL,\\n const in float attenuation,\\n const in float thicknessFactor,\\n const in vec3 translucencyColor,\\n const in float translucencyFactor,\\n const in float shadowDistance,\\n const in vec3 diffuse,\\n const in vec3 lightColor) {\\n\\n // http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/\\n // float scatter = 0.5;\\n // float wrap = saturate((dotNL + scatter) / ((1.0 + scatter) * (1.0 + scatter)));\\n\\n // https://github.com/iryoku/separable-sss/blob/master/SeparableSSS.h#L362\\n float wrap = saturate(0.3 - dotNL);\\n float thickness = max(0.0, shadowDistance / max(0.001, thicknessFactor));\\n\\n // http://www.crytek.com/download/2014_03_25_CRYENGINE_GDC_Schultz.pdf\\n // skin approximation vec3(0.98, 0.3, 0.2)\\n float finalAttenuation = translucencyFactor * attenuation * wrap;\\n return finalAttenuation * lightColor * diffuse * exp(-thickness / max(translucencyColor, vec3(0.001))); \\n}\\n',\r\n 'utils/skinning.glsl':\r\n \"//////////////////////////////\\n// UN-OPTIMIZED VERSION (WITH IF)\\n//////////////////////////////\\n\\n// //http://http.developer.nvidia.com/GPUGems/gpugems_ch04.html\\n// mat4 getMat4FromVec4(const int index, inout mat4 myMat) {\\n// // We have to use a global variable because we can't access dynamically\\n// // matrix is transpose so we should do vec * matrix\\n// myMat[0] = uBones[index];\\n// myMat[1] = uBones[index + 1];\\n// myMat[2] = uBones[index + 2];\\n// return myMat;\\n// }\\n\\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\\n// ivec4 idx = 3 * ivec4(bonesIndex);\\n// mat4 tmpMat = mat4(1.0);\\n// mat4 outMat = mat4(0.0);\\n\\n// // we handle negative weights\\n// if(all(equal(weights, vec4(0.0)))) return tmpMat;\\n\\n// if(weights.x != 0.0) outMat += weights.x * getMat4FromVec4(idx.x, tmpMat);\\n// if(weights.y != 0.0) outMat += weights.y * getMat4FromVec4(idx.y, tmpMat);\\n// if(weights.z != 0.0) outMat += weights.z * getMat4FromVec4(idx.z, tmpMat);\\n// if(weights.w != 0.0) outMat += weights.w * getMat4FromVec4(idx.w, tmpMat);\\n// return outMat;\\n// }\\n\\n//////////////////////////////\\n// UN-OPTIMIZED VERSION (NO IF)\\n//////////////////////////////\\n\\nmat4 skinning(const in vec4 weights, const in vec4 bonesIndex) {\\n ivec4 idx = 3 * ivec4(bonesIndex);\\n mat4 tmpMat = mat4(1.0);\\n\\n // if sum is 0, return identity\\n vec4 absWeights = -abs(weights);\\n mat4 outMat = step(0.0, absWeights.x + absWeights.y + absWeights.z + absWeights.w) * tmpMat;\\n\\n // we handle negative weights\\n // outMat[3][3] += weights.x + weights.y + weights.z + weights.w;\\n\\n tmpMat[0] = uBones[idx.x];\\n tmpMat[1] = uBones[idx.x + 1];\\n tmpMat[2] = uBones[idx.x + 2];\\n outMat += weights.x * tmpMat;\\n\\n tmpMat[0] = uBones[idx.y];\\n tmpMat[1] = uBones[idx.y + 1];\\n tmpMat[2] = uBones[idx.y + 2];\\n outMat += weights.y * tmpMat;\\n\\n tmpMat[0] = uBones[idx.z];\\n tmpMat[1] = uBones[idx.z + 1];\\n tmpMat[2] = uBones[idx.z + 2];\\n outMat += weights.z * tmpMat;\\n\\n tmpMat[0] = uBones[idx.w];\\n tmpMat[1] = uBones[idx.w + 1];\\n tmpMat[2] = uBones[idx.w + 2];\\n outMat += weights.w * tmpMat;\\n\\n return outMat;\\n}\\n\",\r\n 'utils/morphing.glsl':\r\n 'vec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0) {\\n return mix(vertex, target0, weights[0]);\\n}\\n\\nvec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0, const in vec3 target1) {\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1]));\\n vecOut += target0 * weights[0];\\n vecOut += target1 * weights[1];\\n return vecOut;\\n}\\n\\nvec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0, const in vec3 target1, const in vec3 target2) {\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2]));\\n vecOut += target0 * weights[0];\\n vecOut += target1 * weights[1];\\n vecOut += target2 * weights[2];\\n return vecOut;\\n}\\n\\nvec3 morphing(const in vec4 weights,const in vec3 vertex,const in vec3 target0,const in vec3 target1,const in vec3 target2,const in vec3 target3) {\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2] + weights[3]));\\n vecOut += target0 * weights[0];\\n vecOut += target1 * weights[1];\\n vecOut += target2 * weights[2];\\n vecOut += target3 * weights[3];\\n return vecOut;\\n}\\n',\r\n 'utils/environment.glsl':\r\n 'uniform float uEnvironmentExposure;\\r\\nuniform mat3 uEnvironmentTransform;\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\\r\\nuniform vec3 uDiffuseSPH[9];\\r\\n\\r\\n#ifdef HAS_ENVIRONMENT_BRDF\\r\\nuniform sampler2D sIntegrateBRDF;\\r\\n#endif\\r\\n\\r\\nvec3 computeDiffuseSPH(const in vec3 normal) {\\r\\n vec3 n = uEnvironmentTransform * normal;\\r\\n // https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\\r\\n vec3 result =\\r\\n uDiffuseSPH[0] +\\r\\n uDiffuseSPH[1] * n.y +\\r\\n uDiffuseSPH[2] * n.z +\\r\\n uDiffuseSPH[3] * n.x +\\r\\n uDiffuseSPH[4] * n.y * n.x +\\r\\n uDiffuseSPH[5] * n.y * n.z +\\r\\n uDiffuseSPH[6] * (3.0 * n.z * n.z - 1.0) +\\r\\n uDiffuseSPH[7] * (n.z * n.x) +\\r\\n uDiffuseSPH[8] * (n.x * n.x - n.y * n.y);\\r\\n return max(result, vec3(0.0));\\r\\n}\\r\\n\\r\\n#ifndef HAS_LEGACY_CLASSIC\\r\\n\\r\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L202\\r\\nvec3 integrateBRDF(const in vec3 specular, const in float roughness, const in float NoV, const in float f90) {\\r\\n#ifdef HAS_ENVIRONMENT_BRDF\\r\\n vec4 rgba = texture2D(sIntegrateBRDF, vec2(NoV, roughness));\\r\\n float b = (rgba[3] * 65280.0 + rgba[2] * 255.0);\\r\\n float a = (rgba[1] * 65280.0 + rgba[0] * 255.0);\\r\\n const float div = 1.0 / 65535.0;\\r\\n return (specular * a + b * f90) * div;\\r\\n#else\\r\\n // https://www.unrealengine.com/blog/physically-based-shading-on-mobile\\r\\n // TODO should we use somehow specular f0 ?\\r\\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\\r\\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\\r\\n vec4 r = roughness * c0 + c1;\\r\\n float a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\\r\\n vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\\r\\n return specular * AB.x + AB.y * f90;\\r\\n#endif\\r\\n}\\r\\n\\r\\n// Frostbite, Lagarde paper p67\\r\\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf\\r\\nfloat linRoughnessToMipmap(const in float roughnessLinear) {\\r\\n return sqrt(roughnessLinear);\\r\\n}\\r\\n\\r\\n#ifdef ENV_CUBEMAP\\r\\nuniform samplerCube sSpecularPBR;\\r\\n#pragma include \"utils/cubemapLod.glsl\"\\r\\n#endif\\r\\n\\r\\n#ifdef ENV_PANORAMA\\r\\nuniform sampler2D sSpecularPBR;\\r\\n#pragma include \"utils/panoramaLod.glsl\"\\r\\n#endif\\r\\n\\r\\nvec3 getSpecularDominantDir(const in vec3 N, const in vec3 R, const in float realRoughness) {\\r\\n float smoothness = 1.0 - realRoughness;\\r\\n float lerpFactor = smoothness * (sqrt(smoothness) + realRoughness);\\r\\n // The result is not normalized as we fetch in a cubemap\\r\\n return mix(N, R, lerpFactor);\\r\\n}\\r\\n\\r\\nvec3 getPrefilteredEnvMapColor(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 frontNormal) {\\r\\n vec3 R = reflect(-eyeVector, normal);\\r\\n\\r\\n // specular dominant dir is using the bentNormal in the anisotropy scenario\\r\\n // if we want to get rid of the dominant dir but still have a matching result with anisotropy=0 we could try:\\r\\n // R = mix(getSpecularDominantDir(normal, R, roughness), R, anisotropy);\\r\\n R = getSpecularDominantDir(normal, R, roughness);\\r\\n\\r\\n#ifdef ENV_CUBEMAP\\r\\n vec3 prefilteredColor = prefilterEnvMapCube(roughness, uEnvironmentTransform * R);\\r\\n#else\\r\\n vec3 prefilteredColor = prefilterEnvMapPanorama(roughness, uEnvironmentTransform * R);\\r\\n#endif\\r\\n\\r\\n // http://marmosetco.tumblr.com/post/81245981087\\r\\n // marmoset uses 1.3, we force it to 1.0\\r\\n float factor = clamp(1.0 + dot(R, frontNormal), 0.0, 1.0);\\r\\n prefilteredColor *= factor * factor;\\r\\n return prefilteredColor;\\r\\n}\\r\\n\\r\\nvec3 computeIBLSpecularUE4(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 specular, const in vec3 frontNormal, const in float f90) {\\r\\n float NoV = dot(normal, eyeVector);\\r\\n return getPrefilteredEnvMapColor(normal, eyeVector, roughness, frontNormal) * integrateBRDF(specular, roughness, NoV, f90);\\r\\n}\\r\\n\\r\\n#endif\\r\\n',\r\n 'utils/panoramaLod.glsl':\r\n '#pragma include \"utils/functions.glsl\"\\r\\n\\r\\nvec2 computeUVForMipmap(const in float level, const in vec2 uv) {\\r\\n // width for level\\r\\n float widthForLevel = exp2(uTextureEnvironmentSpecularPBRLodRange.x - level);\\r\\n\\r\\n // the height locally for the level in pixel\\r\\n // to opimitize a bit we scale down the v by two in the inputs uv\\r\\n float heightForLevel = widthForLevel * 0.5;\\r\\n\\r\\n // compact version\\r\\n float texelSize = 1.0 / uTextureEnvironmentSpecularPBRTextureSize.x;\\r\\n vec2 uvSpaceLocal = vec2(1.0) + uv * vec2(widthForLevel - 2.0, heightForLevel - 2.0);\\r\\n uvSpaceLocal.y += uTextureEnvironmentSpecularPBRTextureSize.x - widthForLevel;\\r\\n return uvSpaceLocal * texelSize;\\r\\n}\\r\\n\\r\\n//for y up\\r\\nvec2 normalToPanoramaUVY(const in vec3 dir) {\\r\\n float n = length(dir.xz);\\r\\n\\r\\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\\r\\n vec2 pos = vec2((n > 0.0000001) ? max(-1.0, dir.x / n) : 0.0, dir.y);\\r\\n\\r\\n // fix edge bleeding\\r\\n if (pos.x > 0.0) pos.x = min(0.999999, pos.x);\\r\\n\\r\\n pos = acos(pos) * 0.3183098861837907; // inv_pi\\r\\n\\r\\n pos.x = (dir.z > 0.0) ? pos.x * 0.5 : 1.0 - (pos.x * 0.5);\\r\\n\\r\\n // shift u to center the panorama to -z\\r\\n pos.x = mod(pos.x - 0.25 + 1.0, 1.0);\\r\\n pos.y = 1.0 - pos.y;\\r\\n return pos;\\r\\n}\\r\\n\\r\\nvec3 prefilterEnvMapPanorama(const in float rLinear, const in vec3 R) {\\r\\n float lod = min(uTextureEnvironmentSpecularPBRLodRange.x, linRoughnessToMipmap(rLinear) * uTextureEnvironmentSpecularPBRLodRange.y);\\r\\n vec2 uvBase = normalToPanoramaUVY(R);\\r\\n\\r\\n // // we scale down v here because it avoid to do twice in sub functions\\r\\n // uvBase.y *= 0.5;\\r\\n\\r\\n vec3 texel0 = LUVToRGB(texture2D(sSpecularPBR, computeUVForMipmap(floor(lod), uvBase)));\\r\\n vec3 texel1 = LUVToRGB(texture2D(sSpecularPBR, computeUVForMipmap(ceil(lod), uvBase)));\\r\\n\\r\\n return mix(texel0, texel1, fract(lod));\\r\\n}\\r\\n',\r\n 'utils/cubemapLod.glsl':\r\n '#pragma include \"utils/functions.glsl\"\\r\\n\\r\\n#extension GL_EXT_shader_texture_lod : enable\\r\\nvec3 prefilterEnvMapCube(const in float rLinear, const in vec3 R) {\\r\\n vec3 dir = R;\\r\\n float lod = min(uTextureEnvironmentSpecularPBRLodRange.x, linRoughnessToMipmap(rLinear) * uTextureEnvironmentSpecularPBRLodRange.y);\\r\\n\\r\\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\\r\\n float scale = 1.0 - exp2(lod) / uTextureEnvironmentSpecularPBRTextureSize.x;\\r\\n vec3 absDir = abs(dir);\\r\\n float M = max(max(absDir.x, absDir.y), absDir.z);\\r\\n\\r\\n if (absDir.x != M) dir.x *= scale;\\r\\n if (absDir.y != M) dir.y *= scale;\\r\\n if (absDir.z != M) dir.z *= scale;\\r\\n\\r\\n return LUVToRGB(textureCubeLodEXT(sSpecularPBR, dir, lod));\\r\\n}\\r\\n',\r\n 'utils/cubemap.glsl':\r\n '#pragma include \"utils/functions.glsl\"\\n\\n// used by background.frag\\nvec3 textureCubeFixed(const in samplerCube tex, const in vec3 R, const in float size) {\\n vec3 dir = R;\\n float scale = 1.0 - 1.0 / size;\\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\\n vec3 absDir = abs(dir);\\n float M = max(max(absDir.x, absDir.y), absDir.z);\\n\\n if (absDir.x != M) dir.x *= scale;\\n if (absDir.y != M) dir.y *= scale;\\n if (absDir.z != M) dir.z *= scale;\\n\\n return LUVToRGB(textureCube(tex, dir));\\n}\\n',\r\n 'utils/rand.glsl':\r\n '\\n// white vs interleaved vs blue noise\\n// https://blog.demofox.org/2017/10/31/animating-noise-for-integration-over-time/\\n\\n// to test in a shadertoy\\n// https://www.shadertoy.com/view/lsdfD4\\n\\n// https://www.shadertoy.com/view/4djSRW\\n// most combinations are possible : in[1,2,3] -> out[1,2,3]\\n#define INT_SCALE1 .1031\\nfloat pseudoRandom(const in vec2 fragCoord) {\\n vec3 p3 = fract(vec3(fragCoord.xyx) * INT_SCALE1);\\n p3 += dot(p3, p3.yzx + 19.19);\\n return fract((p3.x + p3.y) * p3.z);\\n}\\n\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\\nfloat interleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\\n}\\n\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/MaterialTemplate.ush#L1863\\n// we slighty change it by multiplying by 1.2 (to match with other noise), otherwise the range seems to be between [0 - 0.83]\\nfloat ditheringNoise(const in vec2 fragCoord, const in float frameMod) {\\n // float fm = mod(frameMod, 2.0) == 0.0 ? 1.0 : -1.0;\\n float fm = frameMod;\\n float dither5 = fract((fragCoord.x + fragCoord.y * 2.0 - 1.5 + fm) / 5.0);\\n float noise = fract(dot(vec2(171.0, 231.0) / 71.0, fragCoord.xy));\\n return (dither5 * 5.0 + noise) * (1.2 / 6.0);\\n}\\n\\nvoid ditheringMaskingDiscard(\\n const in vec4 fragCoord,\\n const in int dithering,\\n const in float alpha,\\n const in float factor,\\n\\n const in float thinLayer,\\n\\n const in float frameMod,\\n const in vec2 nearFar,\\n\\n const in vec4 halton) {\\n\\n float rnd;\\n\\n if (thinLayer == 0.0) {\\n float linZ = (1.0 / fragCoord.w - nearFar.x) / (nearFar.y - nearFar.x);\\n float sliceZ = floor(linZ * 500.0) / 500.0;\\n rnd = interleavedGradientNoise(fragCoord.xy + sliceZ, frameMod);\\n } else {\\n rnd = pseudoRandom(fragCoord.xy + halton.xy * 1000.0 + fragCoord.z * (abs(halton.z) == 2.0 ? 1000.0 : 1.0));\\n }\\n\\n if ((alpha * factor) < rnd) discard;\\n}\\n',\r\n 'utils/curvature.glsl':\r\n '#extension GL_OES_standard_derivatives : enable\\n\\nuniform float uMatcapCurvature;\\nuniform mat4 uProjectionMatrix;\\n\\n// http://madebyevan.com/shaders/curvature/\\nfloat getCurvature(const in vec3 normal) {\\n#ifndef GL_OES_standard_derivatives\\n return 1.0;\\n#else\\n if (uMatcapCurvature == 0.0) return 1.0;\\n\\n // Compute curvature\\n vec3 dx = dFdx(normal);\\n vec3 dy = dFdy(normal);\\n vec3 xneg = normal - dx;\\n vec3 xpos = normal + dx;\\n vec3 yneg = normal - dy;\\n vec3 ypos = normal + dy;\\n\\n float factor = uMatcapCurvature / (length(vViewVertex.xyz) * atan(-1.0 / uProjectionMatrix[2][3]));\\n float curvature = (cross(xneg, xpos).y - cross(yneg, ypos).x) * factor;\\n\\n float curvDirt = clamp(-curvature * 1.5, 0.0, 1.0);\\n float curvEdge = clamp(curvature * 2.5, 0.0, 1.0);\\n\\n float factorDirt = mix(1.0, 0.3, curvDirt);\\n float factorEdge = 2.0;\\n\\n return mix(factorDirt, factorEdge, curvEdge);\\n#endif\\n}\\n',\r\n 'utils/refraction.glsl':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\n// manual refract mostly to re-use dot(I, N)\\nvec3 batchRefract(const in vec3 I, const in vec3 N , const in float eta, const in float dotNI) {\\n float k = 1.0 - eta * eta * (1.0 - dotNI * dotNI);\\n return (k < 0.0) ? vec3(0.0) : eta * I - (eta * dotNI + sqrt(k)) * N;\\n}\\n\\nuniform float uOpacityIOR;\\nuniform vec3 uOpacityRefractionColor;\\n\\nuniform float uBoxRadius;\\nuniform int uIsVr;\\nuniform sampler2D uTextureToBeRefracted;\\nuniform vec2 uTextureToBeRefractedSize;\\nuniform mat4 uProjectionMatrix;\\nuniform vec4 uPreviousHalton;\\nuniform vec2 uPreviousGlobalTexRatio;\\nuniform vec2 uPreviousGlobalTexSize;\\nuniform vec2 uGlobalTexSize;\\n\\n#ifndef HAS_REFRACTION_NORMAL_OFFSET\\n uniform sampler2D uTextureMipmapDepth;\\n uniform vec2 uNearFar;\\n uniform vec2 uGlobalTexRatio;\\n uniform mat4 uPreviousProjection;\\n uniform vec4 uTaaCornersCSLeft[2];\\n#endif\\n\\nvec3 refraction(\\n const in float roughness,\\n const in vec3 normalSurface,\\n\\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\\n const in vec3 normalVertex\\n#else\\n const in vec3 eyeVector\\n#endif\\n)\\n\\n{\\n\\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\\n // no reprojection and no depth compare for the normal offset version (not worth it as for the moment)\\n vec2 uv = gl_FragCoord.xy / uGlobalTexSize.xy + (normalVertex.xy - normalSurface.xy) * (uOpacityIOR - 1.0);\\n#else\\n float dotNI = -dot(eyeVector, normalSurface);\\n\\n // compute UV at distortion point\\n // https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Curved_Glass\\n vec3 pos = vViewVertex.xyz + uBoxRadius * batchRefract(-eyeVector, normalSurface, 1.0 / uOpacityIOR, dotNI);\\n pos = (uProjectionMatrix * vec4(pos, 1.0)).xyw; // we discard z and only keep the perspective divide\\n vec2 uv = 0.5 + 0.5 * pos.xy / pos.z;\\n\\n if (uIsVr == 1) {\\n // no reprojection in vr (would require another uTaaCornersCSRight uniform)\\n uv.x *= 0.5;\\n if (gl_FragCoord.x > uGlobalTexSize.x * 0.5) uv.x += 0.5;\\n } else {\\n // we discard refraction on pixels that are in front of refracted surface by\\n // comparing current pixel depth with depth at refraction point\\n // if we are on the background we take the depth of the current position\\n #ifdef DEPTH_MIPMAP\\n vec3 pack = texture2D(uTextureMipmapDepth, uPreviousGlobalTexRatio * vec2(uv.x, (1.0 - uv.y) * 0.5)).xyz;\\n float depthRefracted = pack.x == 1.0 ? (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x) : decode24(pack);\\n #else\\n vec4 pack = texture2D(uTextureMipmapDepth, uGlobalTexRatio * uv);\\n float depthRefracted = pack.x == 1.0 ? (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x) : decodeDepth(pack);\\n #endif\\n\\n // compute view space refracted position from depth\\n vec4 AB = mix(uTaaCornersCSLeft[0], uTaaCornersCSLeft[1], uv.x);\\n pos = vec3(mix(AB.xy, AB.zw, uv.y), 1.0) * -(uNearFar.x + (uNearFar.y - uNearFar.x) * depthRefracted);\\n\\n // pos is computed with last frame projection which is not entirely correct\\n if (dot(pos.xyz - vViewVertex.xyz, normalSurface) > 0.00001) {\\n uv = gl_FragCoord.xy / uGlobalTexSize.xy;\\n } else {\\n // reproject view vector\\n pos = (uPreviousProjection * vec4(pos, 1.0)).xyw;\\n uv.xy = 0.5 + 0.5 * pos.xy / pos.z;\\n }\\n }\\n#endif\\n\\n // unjitter (so that the refraction is stable when doing supersampling)\\n uv -= 0.5 * uPreviousHalton.xy / uPreviousGlobalTexSize.xy;\\n\\n // repeat mirror for out of screen fetches (it\\'s better than a sudden cut)\\n // we can\\'t simply use MIRRORED_REPEAT because of manual mipmap\\n uv = abs(uv); \\n if (uv.x > 1.0) uv.x -= 2.0 * (uv.x - 1.0);\\n if (uv.y > 1.0) uv.y -= 2.0 * (uv.y - 1.0);\\n\\n // adjusts roughness-to-mipmap depending of distance from surface (aka: consistent blurring even when we unzoom)\\n float adjustRoughness = clamp(uProjectionMatrix[1][1] / 12.0 * uBoxRadius / -vViewVertex.z, 0.0, 1.0);\\n float adjustFactor = 0.05; // the higher it is, the sharper it will be when we are far away\\n adjustRoughness = (1.0 + adjustFactor) * adjustRoughness / (adjustFactor + adjustRoughness);\\n\\n // roughness support\\n float maxLod = 7.0;\\n float lodLevel = maxLod * min(0.99, roughness * adjustRoughness); // same as in pbr\\n\\n float lowerLevel = floor(lodLevel);\\n float higherLevel = min(maxLod, lowerLevel + 1.0);\\n float lerpFactor = lodLevel - lowerLevel; // [0,1]\\n\\n // see packMipmapRefraction.glsl\\n // mipmap packing of refracted texture (the packing is not optimal and is a bit naive):\\n // level0: (1-uv)/2\\n // level1: (3-uv)/4\\n // level2: (7-uv)/8\\n // level3: (15-uv)/16\\n // level4: (31-uv)/32\\n // etc...\\n\\n float powLevel = pow(2.0, higherLevel);\\n\\n // border pixel issue with bilinear...\\n vec2 pixelSize = 2.0 * powLevel / uTextureToBeRefractedSize;\\n uv = max(pixelSize, min(1.0 - pixelSize, uv));\\n\\n // lower uv\\n vec2 uvLower = vec2(2.0 * uv.x, powLevel - 1.0 - uv.y) * uPreviousGlobalTexRatio.xy / powLevel;\\n\\n // higher uv\\n powLevel *= 2.0;\\n vec2 uvHigher = vec2(2.0 * uv.x, powLevel - 1.0 - uv.y) * uPreviousGlobalTexRatio.xy / powLevel;\\n\\n // manual lerp, mixing rgbm colors exhibits visible seams\\n vec3 fetch = mix(decodeRGBM(texture2D(uTextureToBeRefracted, uvLower), 7.0), decodeRGBM(texture2D(uTextureToBeRefracted, uvHigher), 7.0), lerpFactor);\\n\\n#ifndef HAS_REFRACTION_NORMAL_OFFSET\\n // reduce bright fresnel effect, it darkens/accentuates the edges in some cases (very rough surface)\\n fetch.rgb -= fetch.rgb * pow(clamp(1.0 + dotNI, 0.0, 1.0), 4.0);\\n#endif\\n\\n return uOpacityRefractionColor * fetch.rgb;\\n}\\n',\r\n 'utils/clearCoat.glsl':\r\n '#pragma include \"utils/lightsPBR.glsl\"\\n\\n//https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law for translucent material absorbtion\\nvec3 beerLambert(const float NoV, const float NoL, const vec3 tint, const float d) {\\n // exp(tint * -distance * density)\\n return exp(tint * -(d * ((NoL + NoV) / max(NoL * NoV, 1e-3))));\\n}\\n\\nvec3 getClearCoatAbsorbtion(const in float NoV, const in float NoL, const in float clearCoatFactor) {\\n return mix(vec3(1.0), beerLambert(NoV, NoL, uClearCoatTint, uClearCoatThickness), clearCoatFactor);\\n}\\n\\n// compute Light PBR for clearCoat layer\\nvoid computeLightLambertGGXClearCoat(\\n const in float ccNoV,\\n const in vec3 normal,\\n const in vec3 eyeVector,\\n const in float dotNL,\\n const in vec4 precomputeGGX,\\n\\n const in float attenuation,\\n const in vec3 lightColor,\\n const in vec3 eyeLightDir,\\n\\n const in float clearCoatFactor,\\n\\n out vec3 clearCoatSpecular,\\n out vec3 clearCoatAttenuation) {\\n\\n if (dotNL <= 0.0) {\\n clearCoatSpecular = vec3(0.0);\\n clearCoatAttenuation = vec3(0.0);\\n return;\\n }\\n\\n float ccNoL = saturate(dot(normal, -refract(eyeLightDir, normal, 1.0 / uClearCoatIor)));\\n vec3 clearCoatAbsorption = getClearCoatAbsorbtion(ccNoV, ccNoL, clearCoatFactor);\\n\\n vec3 H = normalize(eyeVector + eyeLightDir);\\n float NoH = saturate(dot(normal, H));\\n float VoH = saturate(dot(eyeLightDir, H));\\n\\n // distribution / visibility / fresnel\\n float D = D_GGX(precomputeGGX, NoH);\\n float V = V_SmithCorrelated(precomputeGGX, ccNoL);\\n float F = F_Schlick(uClearCoatF0, 1.0, VoH);\\n\\n clearCoatSpecular = (attenuation * dotNL * clearCoatFactor * D * V * PI * F) * lightColor;\\n clearCoatAttenuation = (1.0 - F * clearCoatFactor) * clearCoatAbsorption;\\n}\\n',\r\n 'utils/ssr.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\n#define SSR_STEPS 8\\n\\n#define LOD_COLOR 7.0\\n#define LOD_DEPTH 5.0\\n\\nuniform int uDrawOpaque;\\nuniform float uFrameModTaaSS;\\nuniform float uQuality;\\nuniform float uSsrFactor;\\n\\nuniform sampler2D uTextureToBeRefracted;\\nuniform sampler2D uTextureMipmapDepth;\\n\\nuniform vec2 uTextureToBeRefractedSize;\\nuniform vec2 uPreviousGlobalTexRatio;\\nuniform vec2 uPreviousGlobalTexSize;\\nuniform vec2 uNearFar;\\nuniform vec2 uGlobalTexRatio;\\nuniform vec4 uTaaCornersCSLeft[2];\\n\\nuniform mat4 uProjectionMatrix;\\nuniform mat4 uReprojectViewProj;\\nuniform mat4 uPreviousViewInvView;\\nuniform mat4 uPreviousProjection; // DEPTH_MIPMAP\\n\\nvec3 computeLodNearestPixelSizePowLevel(const in float lodLevelIn, const in float maxLod, const in vec2 size) {\\n float lodLevel = min(maxLod - 0.01, lodLevelIn);\\n float lowerLevel = floor(lodLevel);\\n float higherLevel = min(maxLod, lowerLevel + 1.0);\\n\\n float powLevel = pow(2.0, higherLevel);\\n vec2 pixelSize = 2.0 * powLevel / size;\\n\\n if (lodLevel - lowerLevel > 0.5) powLevel *= 2.0;\\n return vec3(pixelSize, powLevel);\\n}\\n\\n// lerping between 2 mipmap is too costly (with no notable quality gain in the end)\\nvec2 computeLodUVNearest(const in vec2 uvIn, const in vec3 pixelSizePowLevel) {\\n // border pixel issue with bilinear...\\n vec2 uv = max(pixelSizePowLevel.xy, min(1.0 - pixelSizePowLevel.xy, uvIn));\\n return vec2(2.0 * uv.x, pixelSizePowLevel.z - 1.0 - uv.y) / pixelSizePowLevel.z;\\n}\\n\\nfloat fetchDepthLod(const in vec2 uv, const in vec3 pixelSizePowLevel) {\\n#ifdef DEPTH_MIPMAP\\n vec2 uvNearest = computeLodUVNearest(uv, pixelSizePowLevel);\\n float depth = decodeDepth(texture2D(uTextureMipmapDepth, uvNearest * uPreviousGlobalTexRatio));\\n#else\\n float depth = decodeDepth(texture2D(uTextureMipmapDepth, uv * uGlobalTexRatio));\\n#endif\\n\\n if (depth >= 1.0) return -uNearFar.y * 100.0; // very far so it won\\'t reflect background\\n return -uNearFar.x - depth * (uNearFar.y - uNearFar.x);\\n}\\n\\nvec4 fetchDepthLod(const in vec4 uv0, const in vec4 uv1, const in vec3 pixelSizePowLevel) {\\n vec4 result = vec4(0.0);\\n result.x = fetchDepthLod(uv0.xy, pixelSizePowLevel);\\n result.y = fetchDepthLod(uv0.zw, pixelSizePowLevel);\\n result.z = fetchDepthLod(uv1.xy, pixelSizePowLevel);\\n result.w = fetchDepthLod(uv1.zw, pixelSizePowLevel);\\n return result;\\n}\\n\\nvec3 ssrViewToScreen(const in mat4 projection, const in vec3 viewVertex) {\\n vec4 projected = projection * vec4(viewVertex, 1.0);\\n return vec3(0.5 + 0.5 * projected.xy / projected.w, projected.w);\\n}\\n\\nvec3 fetchColorLod(const in float level, const in vec2 uv) {\\n vec3 pixelSizePowLevel = computeLodNearestPixelSizePowLevel(LOD_COLOR * level, LOD_COLOR, uPreviousGlobalTexSize); \\n vec2 uvNearest = computeLodUVNearest(uv, pixelSizePowLevel);\\n return decodeRGBM(texture2D(uTextureToBeRefracted, uvNearest * uPreviousGlobalTexRatio), 7.0);\\n}\\n\\n// #define HASHSCALE1 .1031\\n// #define HASHSCALE3 vec3(.1031, .1030, .0973)\\n// #define HASHSCALE4 vec4(.1031, .1030, .0973, .1099)\\n\\n// vec2 hash23(vec3 p3)\\n// {\\n// p3 = fract(p3 * HASHSCALE3);\\n// p3 += dot(p3, p3.yzx + 19.19);\\n// return fract((p3.xx + p3.yz) * p3.zy);\\n// }\\n\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/ScreenSpaceReflections.usf#L143\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/MonteCarlo.ush#L169\\nvec3 unrealImportanceSampling(const in float frameMod, const in vec3 tangentX, const in vec3 tangentY, const in vec3 tangentZ, const in vec3 eyeVector, const in float rough4) {\\n vec2 E;\\n\\n // could be improved (visible patterns)\\n E.x = interleavedGradientNoise(gl_FragCoord.yx, frameMod);\\n E.y = fract(E.x * 52.9829189);\\n // E = hash23(vec3(gl_FragCoord.xy + frameMod * 150.2420, frameMod * 100.0));\\n\\n // Reduces BRDF tail is noisy, we clamp it\\n // https://www.slideshare.net/DICEStudio/stochastic-screenspace-reflections#p=67\\n E.y = mix(E.y, 1.0, 0.7);\\n\\n float phi = 2.0 * 3.14159 * E.x;\\n // float cosTheta = sqrt((1.0 - E.y) / (1.0 + (rough4 - 1.0) * E.y)); // ggx (long tail, more noisy)\\n float cosTheta = pow(max(E.y, 0.000001), rough4 / (2.0 - rough4)); // blinn\\n float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\\n\\n vec3 h = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);\\n h = h.x * tangentX + h.y * tangentY + h.z * tangentZ;\\n return normalize((2.0 * dot(eyeVector, h)) * h - eyeVector);\\n}\\n\\nfloat getStepOffset(const in float frameMod) {\\n return (interleavedGradientNoise(gl_FragCoord.xy, frameMod) - 0.5);\\n}\\n\\nvec3 computeRayDirUV(const in vec3 rayOriginUV, const in float rayLen, const in vec3 rayDirView) {\\n#ifdef DEPTH_MIPMAP\\n vec3 rayDirUV = ssrViewToScreen(uPreviousProjection, vViewVertex.xyz + rayDirView * rayLen);\\n#else\\n vec3 rayDirUV = ssrViewToScreen(uProjectionMatrix, vViewVertex.xyz + rayDirView * rayLen);\\n#endif\\n\\n rayDirUV.z = 1.0 / rayDirUV.z;\\n rayDirUV -= rayOriginUV;\\n\\n // clip the line to the viewport edges\\n // https://github.com/godotengine/godot/blob/master/drivers/gles3/shaders/screen_space_reflection.glsl#L124\\n float scaleMaxX = min(1.0, 0.99 * (1.0 - rayOriginUV.x) / max(1e-5, rayDirUV.x));\\n float scaleMaxY = min(1.0, 0.99 * (1.0 - rayOriginUV.y) / max(1e-5, rayDirUV.y));\\n float scaleMinX = min(1.0, 0.99 * rayOriginUV.x / max(1e-5, -rayDirUV.x));\\n float scaleMinY = min(1.0, 0.99 * rayOriginUV.y / max(1e-5, -rayDirUV.y));\\n return rayDirUV * min(scaleMaxX, scaleMaxY) * min(scaleMinX, scaleMinY);\\n}\\n\\n#define SSR_RAY_FETCH(void) \\\\\\nsampleUV = rayOriginUV + rayDirUV * diffSampleW.y; \\\\\\ndepth = fetchDepthLod(sampleUV.xy, pixelSizePowLevel); \\\\\\ndepthDiff = -1.0 / sampleUV.z - depth; \\\\\\nhit = abs(depthDiff + depthTolerance) < depthTolerance; \\\\\\ntimeLerp = clamp(diffSampleW.x / (diffSampleW.x - depthDiff), 0.0, 1.0); \\\\\\nhitTime = hit ? (diffSampleW.y + timeLerp * invNumSteps - invNumSteps) : 1.0; \\\\\\ndiffSampleW.z = min(diffSampleW.z, hitTime); \\\\\\ndiffSampleW.x = depthDiff; \\\\\\ndiffSampleW.y += invNumSteps; \\\\\\n\\n#define SSR_RAY_UNROLLED(void) \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\nSSR_RAY_FETCH() \\\\\\n\\nvec4 rayTraceUnrealSimple(\\n const in vec3 rayOriginUV,\\n const in float rayLen,\\n in float depthTolerance,\\n const in vec3 rayDirView,\\n\\n const in float roughness,\\n const in float frameMod) {\\n\\n vec3 pixelSizePowLevel = computeLodNearestPixelSizePowLevel(LOD_DEPTH * roughness, LOD_DEPTH, uTextureToBeRefractedSize); \\n\\n float invNumSteps = 1.0 / float(SSR_STEPS);\\n if (uQuality > 1.0) invNumSteps /= 2.0;\\n\\n depthTolerance *= invNumSteps;\\n\\n vec3 rayDirUV = computeRayDirUV(rayOriginUV, rayLen, rayDirView);\\n\\n float sampleTime = getStepOffset(frameMod) * invNumSteps + invNumSteps;\\n vec3 diffSampleW = vec3(0.0, sampleTime, 1.0);\\n\\n vec3 sampleUV;\\n float depth, depthDiff, timeLerp, hitTime;\\n bool hit;\\n\\n SSR_RAY_UNROLLED()\\n if (uQuality > 1.0) { SSR_RAY_UNROLLED() }\\n\\n // alternative : ray refinement around the intersected cell\\n // if (uQuality > 1.0) {\\n // rayOriginUV = rayOriginUV + rayDirUV * diffSampleW.z - rayDirUV * invNumSteps * 0.5;\\n // diffSampleW = vec3(0.0, sampleTime, 1.0);\\n // rayDirUV *= invNumSteps;\\n // depthTolerance *= invNumSteps;\\n // SSR_RAY_UNROLLED()\\n // }\\n\\n return vec4(rayOriginUV + rayDirUV * diffSampleW.z, 1.0 - diffSampleW.z);\\n}\\n\\nvec4 fetchColorContribution(\\n in vec4 resRay,\\n const in float maskSsr,\\n const in vec3 specularEnvironment,\\n const in vec3 specularColor,\\n const in float roughness) {\\n\\n // reprojection\\n vec4 AB = mix(uTaaCornersCSLeft[0], uTaaCornersCSLeft[1], resRay.x);\\n resRay.xyz = vec3(mix(AB.xy, AB.zw, resRay.y), 1.0) * -1.0 / resRay.z;\\n resRay.xyz = (uReprojectViewProj * vec4(resRay.xyz, 1.0)).xyw;\\n resRay.xy /= resRay.z;\\n\\n // fade edge of screen\\n float maskEdge = clamp(6.0 - 6.0 * max(abs(resRay.x), abs(resRay.y)), 0.0, 1.0);\\n\\n resRay.xy = 0.5 + 0.5 * resRay.xy;\\n\\n vec3 fetchColor = specularColor * fetchColorLod(roughness * (1.0 - resRay.w), resRay.xy);\\n\\n // fade ray count\\n // maskEdge *= resRay.w;\\n\\n return vec4(mix(specularEnvironment, fetchColor, maskSsr * maskEdge), 1.0);\\n}\\n\\nvec3 ssr(const in vec3 specularEnvironment, const in vec3 specularColor, const in float roughness, const in vec3 normal, const in vec3 eyeVector) {\\n\\n#if (defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)) && !defined(HAS_SSR_TRANSPARENT)\\n // no ssr for transparent pxiels for now (mainly performance reason)\\n if (uDrawOpaque == 0) return specularEnvironment;\\n#endif\\n\\n vec4 result = vec4(0.0);\\n\\n // precompute importance sampling roughness^4\\n float rough4 = roughness * roughness;\\n rough4 = rough4 * rough4;\\n\\n // precompute importance sampling basis tangent\\n vec3 upVector = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\\n vec3 tangentX = normalize(cross(upVector, normal));\\n vec3 tangentY = cross(normal, tangentX);\\n\\n // fade ray that points toward camera\\n float maskSsr = uSsrFactor * clamp(-4.0 * dot(eyeVector, normal) + 3.8, 0.0, 1.0);\\n maskSsr *= clamp(4.7 - roughness * 5.0, 0.0, 1.0); // fade out ssr for high roughness values\\n\\n // compute ray uv origin\\n vec3 rayOriginUV = ssrViewToScreen(uProjectionMatrix, vViewVertex.xyz);\\n rayOriginUV.z = 1.0 / rayOriginUV.z;\\n\\n // direction of reflection\\n vec3 rayDirView = unrealImportanceSampling(uFrameModTaaSS, tangentX, tangentY, normal, eyeVector, rough4);\\n\\n // if reflection is toward us, we cast [near, vertex], otherwise [vertex, far]\\n float rayLen = mix(uNearFar.y + vViewVertex.z, -vViewVertex.z - uNearFar.x, rayDirView.z * 0.5 + 0.5);\\n float depthTolerance = 0.5 * rayLen;\\n\\n // ray under the surface (normalmap or inverted normal)\\n if (dot(rayDirView, normal) > 0.001 && maskSsr > 0.0) {\\n vec4 resRay = rayTraceUnrealSimple(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, uFrameModTaaSS);\\n if (resRay.w > 0.0) result += fetchColorContribution(resRay, maskSsr, specularEnvironment, specularColor, roughness);\\n }\\n\\n // if (uQuality > 0.4) {\\n // for (int i = 1; i < 4; ++i) {\\n // float frameRay = frameMod + float(i) * 50.0;\\n // rayDirView = unrealImportanceSampling(frameRay, tangentX, tangentY, normal, eyeVector, rough4);\\n // rayLen = mix(uNearFar.y + vViewVertex.z, -vViewVertex.z - uNearFar.x, rayDirView.z * 0.5 + 0.5);\\n // depthTolerance = 0.5 * rayLen;\\n\\n // if (dot(rayDirView, normal) > 0.001) {\\n // vec4 resRay = rayTraceUnrealSimple(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, frameRay);\\n // if (resRay.w > 0.0) result += fetchColorContribution(resRay, maskSsr, specularEnvironment, specularColor, roughness);\\n // }\\n // }\\n // }\\n\\n return result.w > 0.0 ? result.rgb / result.w : specularEnvironment;\\n}\\n',\r\n 'utils/material.glsl':\r\n '#define MIN_ROUGHNESS 0.045\\n\\n#pragma include \"utils/functions.glsl\"\\n\\n#ifdef HAS_OPACITY_REFRACTION\\n float gRefractionRoughness; // global variable (simpler to handle in order to re-use rough/gloss fetch)\\n#endif\\n\\n#ifdef HAS_VERTEX_COLOR\\n varying vec4 vColor;\\n\\n vec3 getVertexColor() {\\n return COLOR_CONVERT_VERTEX_COLOR(vColor.rgb);\\n }\\n#endif\\n\\n// METALNESS WORKFLOW\\n#ifdef HAS_ALBEDOPBR\\n uniform float uAlbedoPBRFactor;\\n\\n vec3 getMaterialAlbedo() {\\n vec3 albedo;\\n #ifdef SAMPLER_ALBEDOPBR\\n albedo = uAlbedoPBRFactor * COLOR_CONVERT_ALBEDOPBR(texture2D(SAMPLER_ALBEDOPBR, UV_ALBEDOPBR).PACK_ALBEDOPBR);\\n #else\\n albedo = vec3(uAlbedoPBRFactor);\\n #endif\\n\\n #ifdef HAS_VERTEX_COLOR\\n albedo *= getVertexColor();\\n #endif\\n\\n return albedo;\\n }\\n#endif\\n\\n#ifdef HAS_METALNESSPBR\\n uniform float uMetalnessPBRFactor;\\n\\n float getMaterialMetalness() {\\n #ifdef SAMPLER_METALNESSPBR\\n return uMetalnessPBRFactor * COLOR_CONVERT_METALNESSPBR(texture2D(SAMPLER_METALNESSPBR, UV_METALNESSPBR).PACK_METALNESSPBR);\\n #else\\n return uMetalnessPBRFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_SPECULARF0\\n uniform float uSpecularF0Factor;\\n\\n float getMaterialF0() {\\n #ifdef SAMPLER_SPECULARF0\\n return uSpecularF0Factor * COLOR_CONVERT_SPECULARF0(texture2D(SAMPLER_SPECULARF0, UV_SPECULARF0).PACK_SPECULARF0);\\n #else\\n return uSpecularF0Factor;\\n #endif\\n }\\n#endif\\n\\n// SPECULAR WORKFLOW\\n#ifdef HAS_DIFFUSEPBR\\n uniform float uDiffusePBRFactor;\\n\\n vec3 getMaterialDiffuse() {\\n vec3 diffuse;\\n #ifdef SAMPLER_DIFFUSEPBR\\n diffuse = uDiffusePBRFactor * COLOR_CONVERT_DIFFUSEPBR(texture2D(SAMPLER_DIFFUSEPBR, UV_DIFFUSEPBR).PACK_DIFFUSEPBR);\\n #else\\n diffuse = vec3(uDiffusePBRFactor);\\n #endif\\n\\n #ifdef HAS_VERTEX_COLOR\\n diffuse *= getVertexColor();\\n #endif\\n\\n return diffuse;\\n }\\n#endif\\n\\n#ifdef HAS_SPECULARPBR\\n uniform float uSpecularPBRFactor;\\n\\n vec3 getMaterialSpecular() {\\n #ifdef SAMPLER_SPECULARPBR\\n return uSpecularPBRFactor * COLOR_CONVERT_SPECULARPBR(texture2D(SAMPLER_SPECULARPBR, UV_SPECULARPBR).PACK_SPECULARPBR);\\n #else\\n return vec3(uSpecularPBRFactor);\\n #endif\\n }\\n#endif\\n\\n// MICROSURFACE\\n#ifdef HAS_ROUGHNESSPBR\\n uniform float uRoughnessPBRFactor;\\n\\n float getMaterialRoughness() {\\n #ifdef SAMPLER_ROUGHNESSPBR\\n float fetch = COLOR_CONVERT_ROUGHNESSPBR(texture2D(SAMPLER_ROUGHNESSPBR, UV_ROUGHNESSPBR).PACK_ROUGHNESSPBR);\\n\\n #ifdef HAS_REFRACTION_MICROSURFACE\\n gRefractionRoughness *= fetch;\\n #endif\\n\\n return uRoughnessPBRFactor * fetch;\\n #else\\n return uRoughnessPBRFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_GLOSSINESSPBR\\n uniform float uGlossinessPBRFactor;\\n\\n float getMaterialGlossiness() {\\n #ifdef SAMPLER_GLOSSINESSPBR\\n float fetch = COLOR_CONVERT_GLOSSINESSPBR(texture2D(SAMPLER_GLOSSINESSPBR, UV_GLOSSINESSPBR).PACK_GLOSSINESSPBR);\\n\\n #ifdef HAS_REFRACTION_MICROSURFACE\\n gRefractionRoughness = mix(1.0 - fetch, 1.0, gRefractionRoughness);\\n #endif\\n\\n return uGlossinessPBRFactor * fetch;\\n #else\\n return uGlossinessPBRFactor;\\n #endif\\n }\\n#endif\\n\\n\\n#ifdef HAS_EMITCOLOR\\n uniform float uEmitColorFactor;\\n uniform int uEmitMultiplicative;\\n\\n vec3 getMaterialEmitColor() {\\n #ifdef SAMPLER_EMITCOLOR\\n return uEmitColorFactor * COLOR_CONVERT_EMITCOLOR(texture2D(SAMPLER_EMITCOLOR, UV_EMITCOLOR).PACK_EMITCOLOR);\\n #else\\n return vec3(0.0);\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_AOPBR\\n uniform float uAOPBRFactor;\\n uniform int uAOPBROccludeSpecular;\\n\\n float getMaterialAO() {\\n return mix(1.0, COLOR_CONVERT_AOPBR(texture2D(SAMPLER_AOPBR, UV_AOPBR).PACK_AOPBR), uAOPBRFactor);\\n }\\n#endif\\n\\n#ifdef HAS_CAVITYPBR\\n uniform float uCavityPBRFactor;\\n\\n float getMaterialCavity() {\\n return mix(1.0, COLOR_CONVERT_CAVITYPBR(texture2D(SAMPLER_CAVITYPBR, UV_CAVITYPBR).PACK_CAVITYPBR), uCavityPBRFactor);\\n }\\n#endif\\n\\n#ifdef HAS_SUBSURFACETRANSLUCENCY\\n uniform float uSubsurfaceTranslucencyFactor;\\n uniform float uSubsurfaceTranslucencyThicknessFactor;\\n uniform vec3 uSubsurfaceTranslucencyColor;\\n\\n float getMaterialTranslucency() {\\n #ifdef SAMPLER_SUBSURFACETRANSLUCENCY\\n return uSubsurfaceTranslucencyFactor * COLOR_CONVERT_SUBSURFACETRANSLUCENCY(texture2D(SAMPLER_SUBSURFACETRANSLUCENCY, UV_SUBSURFACETRANSLUCENCY).PACK_SUBSURFACETRANSLUCENCY);\\n #else\\n return uSubsurfaceTranslucencyFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_NORMALMAP\\n uniform float uNormalMapFactor;\\n uniform int uNormalMapFlipY;\\n\\n vec3 getMaterialNormalMap() {\\n vec3 nmap = COLOR_CONVERT_NORMALMAP(texture2D(SAMPLER_NORMALMAP, UV_NORMALMAP).PACK_NORMALMAP) * 2.0 - 1.0;\\n nmap.y = uNormalMapFlipY == 1 ? -nmap.y : nmap.y;\\n return nmap;\\n }\\n#endif\\n\\n#ifdef HAS_BUMPMAP\\n uniform float uBumpMapFactor;\\n uniform vec2 uBumpMapSize;\\n\\n vec2 getMaterialBumpMap() {\\n vec2 bump;\\n vec3 invSize = vec3(1.0 / uBumpMapSize, 0.0);\\n return uBumpMapFactor * vec2(COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP - invSize.xz).PACK_BUMPMAP)\\n - COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP + invSize.xz).PACK_BUMPMAP),\\n COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP - invSize.zy).PACK_BUMPMAP)\\n -COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP + invSize.zy).PACK_BUMPMAP));\\n }\\n#endif\\n\\n#ifdef HAS_SUBSURFACESCATTERING\\n uniform float uSubsurfaceScatteringProfile;\\n uniform float uSubsurfaceScatteringFactor;\\n uniform float uScatteringFactorPacker;\\n\\n float getMaterialScattering() {\\n #ifdef SAMPLER_SUBSURFACESCATTERING\\n return uScatteringFactorPacker * uSubsurfaceScatteringFactor * COLOR_CONVERT_SUBSURFACESCATTERING(texture2D(SAMPLER_SUBSURFACESCATTERING, UV_SUBSURFACESCATTERING).PACK_SUBSURFACESCATTERING);\\n #else\\n return uScatteringFactorPacker * uSubsurfaceScatteringFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_ALPHAMASK\\n uniform float uAlphaMaskFactor;\\n uniform int uAlphaMaskInvert;\\n\\n float getMaterialAlphaMask() {\\n float alpha = 1.0;\\n\\n #ifdef SAMPLER_ALPHAMASK\\n alpha = COLOR_CONVERT_ALPHAMASK(texture2D(SAMPLER_ALPHAMASK, UV_ALPHAMASK).PACK_ALPHAMASK);\\n if (uAlphaMaskInvert == 1) alpha = 1.0 - alpha;\\n #endif\\n\\n #ifdef HAS_VERTEX_ALPHA\\n alpha *= vColor.a;\\n #endif\\n\\n return alpha;\\n }\\n#endif\\n\\n#ifdef HAS_OPACITY\\n uniform float uOpacityFactor;\\n uniform int uOpacityInvert;\\n\\n #ifdef HAS_OPACITY_DITHER\\n uniform float uOpacityThinLayer;\\n uniform int uOpacityDithering;\\n #endif\\n\\n #ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n uniform int uOpacityAdditive;\\n #endif\\n\\n #ifdef HAS_OPACITY_REFRACTION\\n uniform float uOpacityRoughnessFactor;\\n #endif\\n\\n float getMaterialOpacity() {\\n float alpha = 1.0;\\n\\n #ifdef SAMPLER_OPACITY\\n alpha = COLOR_CONVERT_OPACITY(texture2D(SAMPLER_OPACITY, UV_OPACITY).PACK_OPACITY);\\n if (uOpacityInvert == 1) alpha = 1.0 - alpha;\\n #endif\\n\\n #ifndef HAS_OPACITY_DITHER\\n alpha *= uOpacityFactor;\\n #endif\\n\\n #ifdef HAS_VERTEX_ALPHA\\n alpha *= vColor.a;\\n #endif\\n\\n return alpha;\\n }\\n#endif // HAS_OPACITY\\n\\n\\n#ifdef HAS_CLEARCOAT\\n uniform vec3 uClearCoatTint;\\n uniform float uClearCoatThickness;\\n uniform float uClearCoatIor;\\n uniform float uClearCoatFactor;\\n uniform float uClearCoatF0;\\n\\n float getMaterialClearCoat() {\\n #ifdef SAMPLER_CLEARCOAT\\n return uClearCoatFactor * COLOR_CONVERT_CLEARCOAT(texture2D(SAMPLER_CLEARCOAT, UV_CLEARCOAT).PACK_CLEARCOAT);\\n #else\\n return uClearCoatFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_CLEARCOATROUGHNESS\\n uniform float uClearCoatRoughnessFactor;\\n\\n float getMaterialClearCoatRoughness() {\\n #ifdef SAMPLER_CLEARCOATROUGHNESS\\n return uClearCoatRoughnessFactor * COLOR_CONVERT_CLEARCOATROUGHNESS(texture2D(SAMPLER_CLEARCOATROUGHNESS, UV_CLEARCOATROUGHNESS).PACK_CLEARCOATROUGHNESS);\\n #else\\n return uClearCoatRoughnessFactor;\\n #endif\\n }\\n#endif\\n\\n#ifdef HAS_CLEARCOATNORMALMAP\\n uniform float uClearCoatNormalMapFactor;\\n uniform int uClearCoatNormalMapFlipY;\\n\\n vec3 getMaterialClearCoatNormal() {\\n vec3 nmap = COLOR_CONVERT_CLEARCOATNORMALMAP(texture2D(SAMPLER_CLEARCOATNORMALMAP, UV_CLEARCOATNORMALMAP).PACK_CLEARCOATNORMALMAP) * 2.0 - 1.0;\\n nmap.y = uClearCoatNormalMapFlipY == 1 ? -nmap.y : nmap.y;\\n return nmap;\\n }\\n#endif\\n\\n#ifdef HAS_ANISOTROPY\\n uniform float uAnisotropyFactor;\\n uniform float uAnisotropyDirection;\\n uniform int uAnisotropyFlipXY;\\n\\n #ifdef SAMPLER_ANISOTROPY\\n vec2 getMaterialDirectionAnisotropy() {\\n vec2 dir = COLOR_CONVERT_ANISOTROPY(texture2D(SAMPLER_ANISOTROPY, UV_ANISOTROPY).PACK_ANISOTROPY) * 2.0 - 1.0;\\n if (uAnisotropyFlipXY == 1) dir.xy = dir.yx;\\n return dir;\\n }\\n #endif\\n\\n#endif\\n\\n\\n#ifdef HAS_SHEEN\\n\\nuniform float uSheenFactor;\\nuniform vec3 uSheenColorFactor;\\nuniform float uSheenRoughnessFactor;\\n\\n\\nfloat sheenLobe(const float sheenRoughness, const float NdotV, const float NdotL, const float NdotH) {\\n // Charlie Sheen distribution, Conty Estevez and Kulla Production Friendly Microfacet Sheen BRDF\\n float r = sheenRoughness * sheenRoughness;\\n float invAlpha = 1.0 / r;\\n float cos2h = NdotH * NdotH;\\n // 0.0078125 => 2^(-14/2), so sin2h^2 > 0 in fp16\\n float sin2h = max(1.0 - cos2h, 0.0078125);\\n float D = (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\\n\\n // Sheen visibility (much faster than charlie sheen distribution)\\n // Ashikhmin and Premoze Distribution-based Brdfs\\n // also Neubelt and Pettineo Crafting a Next-gen Material Pipeline for The Order\\n float V = clamp(1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV)), 0.0, 1.0);\\n return (D * V);\\n}\\n\\nfloat getMaterialSheenRoughness(){\\n#if defined(SAMPLER_SHEENROUGHNESS)\\n return uSheenRoughnessFactor * texture2D(SAMPLER_SHEENROUGHNESS, UV_SHEENROUGHNESS).PACK_SHEENROUGHNESS;\\n#else\\n return uSheenRoughnessFactor;\\n#endif\\n}\\n\\nvec3 computeSheen(const vec3 normal, const vec3 lightDir, const vec3 eyeVector, const float sheenRoughness){\\n\\n float NdotL = dot(normal, lightDir);\\n float NdotV = dot(normal, eyeVector);\\n vec3 H = normalize(lightDir + eyeVector);\\n float NdotH = dot(normal, H);\\n\\n float sheenContribution = sheenLobe(max(0.04, sheenRoughness), NdotV, NdotL, NdotH);\\n\\n#if defined(SAMPLER_SHEEN)\\n vec3 sheenColor = uSheenFactor * uSheenColorFactor * COLOR_CONVERT_SHEEN(texture2D(SAMPLER_SHEEN, UV_SHEEN).PACK_SHEEN);\\n#else\\n vec3 sheenColor = uSheenFactor * uSheenColorFactor;\\n#endif\\n\\n return max(vec3(0.0), sheenContribution * sheenColor);\\n}\\n\\n#endif\\n\\n\\n\\n\\n\\n/////////////////\\n// LEGACY CLASSIC\\n/////////////////\\n#ifdef HAS_LEGACY_CLASSIC\\n uniform vec2 uTextureEnvironmentSpecularTextureSize;\\n uniform samplerCube sEnvironmentSpecular;\\n uniform mat3 uEnvironmentTransform;\\n\\n uniform float uReflection;\\n\\n uniform float uDiffuseColorFactor;\\n uniform float uDiffuseIntensityFactor;\\n vec3 getMaterialLegacyDiffuse() {\\n vec3 diffuse = vec3(0.0);\\n #if defined(SAMPLER_DIFFUSECOLOR)\\n diffuse = uDiffuseColorFactor * COLOR_CONVERT_DIFFUSECOLOR(texture2D(SAMPLER_DIFFUSECOLOR, UV_DIFFUSECOLOR).PACK_DIFFUSECOLOR);\\n #elif defined(HAS_DIFFUSECOLOR)\\n diffuse = vec3(uDiffuseColorFactor);\\n #endif\\n\\n #ifdef HAS_VERTEX_COLOR\\n diffuse *= getVertexColor();\\n #endif\\n\\n #ifdef HAS_DIFFUSEINTENSITY\\n #ifdef SAMPLER_DIFFUSEINTENSITY\\n diffuse *= uDiffuseIntensityFactor * COLOR_CONVERT_DIFFUSEINTENSITY(texture2D(SAMPLER_DIFFUSEINTENSITY, UV_DIFFUSEINTENSITY).PACK_DIFFUSEINTENSITY);\\n #else\\n diffuse *= uDiffuseIntensityFactor;\\n #endif\\n #endif\\n\\n return diffuse;\\n }\\n\\n uniform float uSpecularColorFactor;\\n vec3 getMaterialLegacySpecular() {\\n #if defined(SAMPLER_SPECULARCOLOR)\\n return uSpecularColorFactor * COLOR_CONVERT_SPECULARCOLOR(texture2D(SAMPLER_SPECULARCOLOR, UV_SPECULARCOLOR).PACK_SPECULARCOLOR);\\n #elif defined(HAS_SPECULARCOLOR)\\n return vec3(uSpecularColorFactor);\\n #else\\n return vec3(0.0);\\n #endif\\n }\\n\\n uniform float uSpecularHardnessFactor;\\n float getMaterialLegacyShininess() {\\n #if defined(SAMPLER_SPECULARHARDNESS)\\n return uSpecularHardnessFactor * COLOR_CONVERT_SPECULARHARDNESS(texture2D(SAMPLER_SPECULARHARDNESS, UV_SPECULARHARDNESS).PACK_SPECULARHARDNESS);\\n #elif defined(HAS_SPECULARHARDNESS)\\n return uSpecularHardnessFactor;\\n #else\\n return 0.0;\\n #endif\\n }\\n\\n#endif\\n',\r\n 'utils/normalBump.glsl':\r\n '// version for vertex shader\\nvec3 bumpMap(const in vec4 tangent, const in vec3 normal, const in vec2 gradient) {\\n vec3 tang = normalize(tangent.xyz);\\n vec3 binormal = tangent.w * normalize(cross(normal, tang));\\n return normalize(normal + gradient.x * tang + gradient.y * binormal);\\n}\\n\\n// #define transformNormal(f, tn, tex, b, n) n = f * n.xy; n = normalize(tex.x * t.xyz + tex.y * b + tex.z * n)\\nvec3 transformNormal(const in float factor, in vec3 normal, const in vec3 t, const in vec3 b, in vec3 n) {\\n normal.xy = factor * normal.xy;\\n return normalize(normal.x * t + normal.y * b + normal.z * n);\\n}\\n\\n// anisotropy transform\\nvec3 transformTangent(in vec2 tangent, const in vec3 t, const in vec3 b) {\\n return normalize(tangent.x * t + tangent.y * b);\\n}\\n\\n// #define transformBump(tex, t, b, n) n = normalize(tex.x * t.xyz + tex.y * b + n)\\nvec3 transformBump(in vec2 bump, const in vec3 t, const in vec3 b, in vec3 n) {\\n return normalize(bump.x * t + bump.y * b + n);\\n}\\n',\r\n 'utils/checkerboard.glsl':\r\n 'float checkerboard(const in vec2 uv, const in vec4 halton) {\\n vec2 flooredUV = floor(uv);\\n return mod((halton.z < 0.0 ? 0.0 : 1.0) + flooredUV.x + flooredUV.y, 2.0);\\n}\\n',\r\n 'utils/decodeDepth.glsl':\r\n 'int decodeProfile(const in vec4 pack) {\\n float packValue = floor(pack.b * 255.0 + 0.5);\\n // we extract the 2 lowest bits\\n float profile = mod(packValue, 2.0);\\n profile += mod(packValue - profile, 4.0);\\n return int(profile);\\n}\\n\\nfloat decodeDepth(const in vec4 pack) {\\n if(decodeProfile(pack) == 0){\\n const vec3 decode = 1.0 / vec3(1.0, 255.0, 65025.0);\\n return dot(pack.rgb, decode);\\n }\\n\\n return pack.r + pack.g / 255.0;\\n}\\n\\nfloat decodeScatter(const in vec4 pack) {\\n // avoid huge number, summation, division and associated loss of precision\\n // by deriving the whole computation to the end\\n // As floor is with mod(x,y) = x - y * floor(x/y)\\n\\n // float scatter = pack.b - mod(pack.b, 4.0 / 255.0);\\n // float scatter = pack.b - pack.b + (4.0 /255.0) * floor(pack.b / (4.0 /255.0));\\n // float scatter = (4.0 /255.0) * floor(pack.b / (4.0 / 255.0));\\n float scatter = (4.0 / 255.0) * floor(pack.b * 255.0 * 0.25);\\n\\n //return scatter * 255.0 / 4.0 / 63.0;\\n return scatter * 1.0119047619;\\n}\\n\\nfloat decodeAlpha(const in vec4 pack) {\\n return pack.a;\\n}\\n\\nfloat distanceToDepth(const in sampler2D depth, const in vec2 uv, const in vec4 viewPos, const vec2 nearFar) {\\n float fragDepth = clamp( (-viewPos.z * viewPos.w - nearFar.x) / (nearFar.y - nearFar.x), 0.0, 1.0);\\n return fragDepth - decodeDepth(texture2D(depth, uv));\\n}\\n',\r\n 'utils/encodeDepth.glsl':\r\n '// random links on packing :\\n// cesium attributes packing\\n// https://cesiumjs.org/2015/05/18/Vertex-Compression/\\n\\n// float packing in 24 bits or 32 bits\\n// https://skytiger.wordpress.com/2010/12/01/packing-depth-into-color/\\n\\nvec4 encodeDepthAlphaProfileScatter(const in float depth, const in float alpha, const in float profile, const in float scatter) {\\n vec4 pack = vec4(0.0);\\n\\n // opacity in alpha\\n pack.a = alpha;\\n\\n if(profile == 0.0) {\\n const vec3 code = vec3(1.0, 255.0, 65025.0);\\n pack.rgb = vec3(code * depth);\\n pack.gb = fract(pack.gb);\\n pack.rg -= pack.gb * (1.0 / 256.0);\\n } else {\\n // depth in rg\\n pack.g = fract(depth * 255.0);\\n pack.r = depth - pack.g / 255.0;\\n\\n // scatter 6 bits\\n pack.b = floor(0.5 + scatter * 63.0) * 4.0 / 255.0;\\n }\\n\\n // profile on 2 lower bits\\n pack.b -= mod(pack.b, 4.0 / 255.0);\\n pack.b += profile / 255.0; // 3 profile possible for sss\\n\\n return pack;\\n}\\n',\r\n 'utils/encodeDecode.glsl':\r\n 'vec3 encode24(const in float x){\\n const vec3 code = vec3(1.0, 255.0, 65025.0);\\n vec3 pack = vec3(code * x);\\n pack.gb = fract(pack.gb);\\n pack.rg -= pack.gb * (1.0 / 256.0);\\n return pack;\\n}\\n\\nfloat decode24(const in vec3 x) {\\n const vec3 decode = 1.0 / vec3(1.0, 255.0, 65025.0);\\n return dot(x, decode);\\n}\\n',\r\n 'utils/getLuminance.glsl':\r\n 'float getLuminance(const in vec3 color) {\\n // http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color\\n const vec3 colorBright = vec3(0.2126, 0.7152, 0.0722);\\n return dot(color, colorBright);\\n}\\n',\r\n 'base.vert':\r\n 'uniform float uDisplay2D;\\nuniform float uPointSize;\\n\\nuniform vec2 uGlobalTexRatio;\\nuniform vec2 uGlobalTexSize;\\nuniform vec4 uHalton;\\n\\nuniform mat3 uModelNormalMatrix;\\nuniform mat3 uModelViewNormalMatrix;\\n\\nuniform mat4 uProjectionMatrix;\\nuniform mat4 uModelMatrix;\\nuniform mat4 uViewMatrix;\\nuniform mat4 uModelViewMatrix;\\n\\n// in case of srgbToLinear texfetch\\n#ifdef HAS_DISPLACEMENT\\n#pragma include \"utils/functions.glsl\"\\n#endif\\n\\n#ifdef IS_IOS\\ninvariant gl_Position;\\n#endif\\n\\n\\n#if defined(HAS_COMPRESSION) && !defined(HAS_MORPHING)\\n #define HAS_POSITION_COMPRESSION\\n#endif\\n\\n/////////////////////////////////////\\n// ATTRIBUTES (NORMAL/VERTEX/TANGENT)\\n/////////////////////////////////////\\n\\n#ifdef HAS_ZW_COMPRESSION\\n attribute vec4 Vertex;\\n#else\\n attribute vec3 Vertex;\\n#endif\\n\\n// need normal to displace vertex\\n#if defined(HAS_VIEW_NORMAL) || defined(HAS_MODEL_NORMAL) || defined(HAS_EDITOR_DISPLACEMENT)\\n\\n #ifdef HAS_POSITION_COMPRESSION\\n attribute vec2 Normal;\\n #else\\n attribute vec3 Normal;\\n #endif\\n\\n #define NEED_LOCAL_NORMAL\\n#endif\\n\\n// if no normalmap, correct the normal with displacement (as bump)\\n#if defined(HAS_DISPLACEMENT) && !defined(HAS_NORMALMAP) && (defined(HAS_MODEL_NORMAL) || defined(HAS_VIEW_NORMAL))\\n #define CORRECT_BUMP_NORMAL\\n#endif\\n\\n// need tangent to correct normal\\n#if defined(HAS_VIEW_TANGENT) || defined(HAS_MODEL_TANGENT) || defined(CORRECT_BUMP_NORMAL)\\n\\n #ifdef HAS_POSITION_COMPRESSION\\n attribute vec3 Tangent;\\n #else\\n attribute vec4 Tangent;\\n #endif\\n\\n #define NEED_LOCAL_TANGENT\\n#endif\\n\\n#ifdef HAS_VERTEX_COLOR\\n attribute vec4 Color;\\n#endif\\n\\n////////////////////\\n// VARYING/VARIABLES\\n////////////////////\\n\\n// view\\n#ifdef HAS_VIEW_VERTEX\\n varying vec4 vViewVertex;\\n#else\\n vec4 vViewVertex;\\n#endif\\n\\n#ifdef HAS_VIEW_NORMAL\\n varying vec3 vViewNormal;\\n#endif\\n\\n#ifdef HAS_VIEW_TANGENT\\n varying vec4 vViewTangent;\\n#endif\\n\\n// model\\n#if defined(HAS_MODEL_VERTEX)\\n varying vec3 vModelVertex;\\n#elif defined(HAS_DISPLACEMENT)\\n vec3 vModelVertex;\\n#endif\\n\\n#if defined(HAS_MODEL_NORMAL)\\n varying vec3 vModelNormal;\\n#elif defined(HAS_EDITOR_DISPLACEMENT)\\n vec3 vModelNormal;\\n#endif\\n\\n#if defined(HAS_MODEL_TANGENT)\\n varying vec3 vModelTangent;\\n#endif\\n\\n#ifdef HAS_VERTEX_COLOR\\n varying vec4 vColor;\\n uniform float uArrayColorEnabled;\\n#endif\\n\\n////////////\\n// ANIMATION\\n////////////\\n\\n#ifdef HAS_MORPHING\\n uniform vec4 uTargetWeights;\\n\\n%UNROLL 4%\\n #if NUM_TARGETS > %ID%\\n attribute vec3 Vertex_%ID%;\\n #define ARG_MORPH_VERTEX_%ID% , Vertex_%ID%\\n\\n #ifdef HAS_MORPHING_NORMAL\\n attribute vec3 Normal_%ID%;\\n #define ARG_MORPH_NORMAL_%ID% , Normal_%ID%\\n #endif\\n\\n #ifdef HAS_MORPHING_TANGENT\\n attribute vec3 Tangent_%ID%;\\n #define ARG_MORPH_TANGENT_%ID% , Tangent_%ID%.xyz\\n #endif\\n #else\\n #define ARG_MORPH_VERTEX_%ID%\\n #define ARG_MORPH_NORMAL_%ID%\\n #define ARG_MORPH_TANGENT_%ID%\\n #endif\\n%%\\n\\n #pragma include \"utils/morphing.glsl\"\\n#endif\\n\\n#ifdef HAS_SKINNING\\n #ifndef NUM_BONES\\n #define NUM_BONES 1\\n #endif\\n\\n attribute vec4 Bones;\\n attribute vec4 Weights;\\n uniform vec4 uBones[NUM_BONES];\\n\\n #pragma include \"utils/skinning.glsl\"\\n#endif\\n\\n#ifdef HAS_DISPLACEMENT\\n uniform float uDisplacementFactor;\\n#endif\\n\\n#ifdef CORRECT_BUMP_NORMAL\\n uniform float uDisplacementNormal;\\n uniform vec2 uDisplacementSize;\\n #pragma include \"utils/normalBump.glsl\"\\n#endif\\n\\n#ifdef HAS_POSITION_COMPRESSION\\n uniform vec3 uQVT;\\n uniform vec3 uQVS;\\n\\n #ifdef HAS_OCT_COMPRESSION\\n #define UNCOMPRESS_DIR(n) n.z = 1.0 - abs(n.x) - abs(n.y); n.xy = n.z >= 0.0 ? n.xy : (1.0 - abs(n.yx)) * sign(n.xy);\\n #else\\n #define UNCOMPRESS_DIR(n) n.z = dot(n.xy, n.xy); n.xyz = vec3(2.0 * n.xy * sqrt(1.0 - n.z), 1.0 - 2.0 * n.z);\\n #endif\\n#endif\\n\\n// attribute -> morph -> skin -> model -> displace -> view -> screen\\n// localVertex = skin(morph(Vertex))\\n// modelVertex = displacement(modelMatrix * localVertex)\\n// viewVertex = viewMatrix * modelVertex\\n\\nvoid main() {\\n#ifdef ASSIGN_UV\\n ASSIGN_UV\\n#endif\\n\\n#ifdef HAS_VERTEX_COLOR\\n vColor = uArrayColorEnabled == 1.0 ? Color : vec4(1.0);\\n#endif\\n\\n#ifdef HAS_SKINNING\\n mat4 boneMatrix = skinning(Weights, Bones);\\n#endif\\n\\n /////////////////////\\n // LOCAL/MODEL VERTEX\\n /////////////////////\\n vec3 localVertex = Vertex.xyz;\\n#ifdef HAS_POSITION_COMPRESSION\\n #ifdef HAS_ZW_COMPRESSION\\n localVertex += Vertex.w;\\n #endif\\n localVertex = localVertex * uQVS RAND_SCALE + uQVT;\\n#endif\\n\\n#ifdef HAS_MORPHING\\n localVertex = morphing(uTargetWeights, localVertex ARG_MORPH_VERTEX_0 ARG_MORPH_VERTEX_1 ARG_MORPH_VERTEX_2 ARG_MORPH_VERTEX_3);\\n#endif\\n\\n#ifdef HAS_SKINNING\\n localVertex = (vec4(localVertex, 1.0) * boneMatrix).xyz;\\n#endif\\n\\n#if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\\n vModelVertex = (uModelMatrix * vec4(localVertex, 1.0)).xyz;\\n#endif\\n\\n#if (defined(NEED_LOCAL_NORMAL) && defined(HAS_MORPHING_NORMAL)) || (defined(NEED_LOCAL_TANGENT) && defined(HAS_MORPHING_TANGENT))\\n // normalize weights for direction morphing\\n vec4 nTargetWeights = abs(uTargetWeights);\\n nTargetWeights = uTargetWeights / max(1.0, nTargetWeights.x + nTargetWeights.y + nTargetWeights.z + nTargetWeights.w);\\n#endif\\n\\n /////////\\n // NORMAL\\n /////////\\n#ifdef NEED_LOCAL_NORMAL\\n #ifdef HAS_POSITION_COMPRESSION\\n vec3 localNormal = Normal.xyy;\\n UNCOMPRESS_DIR(localNormal);\\n #else\\n vec3 localNormal = Normal;\\n #endif\\n\\n #ifdef HAS_MORPHING_NORMAL\\n localNormal = morphing(nTargetWeights, localNormal ARG_MORPH_NORMAL_0 ARG_MORPH_NORMAL_1 ARG_MORPH_NORMAL_2 ARG_MORPH_NORMAL_3);\\n #endif\\n\\n #ifdef HAS_SKINNING\\n localNormal = (vec4(localNormal, 0.0) * boneMatrix).xyz;\\n #endif\\n\\n #if defined(HAS_MORPHING) || defined(HAS_SKINNING)\\n localNormal.xyz = normalize(localNormal);\\n #endif\\n\\n #if defined(HAS_MODEL_NORMAL) || defined(HAS_EDITOR_DISPLACEMENT)\\n vModelNormal = uModelNormalMatrix * localNormal;\\n #endif\\n\\n // view normal computed later if we need to correct it (displacement)\\n #if defined(HAS_VIEW_NORMAL) && !defined(CORRECT_BUMP_NORMAL)\\n vViewNormal = uModelViewNormalMatrix * localNormal;\\n #endif\\n#endif\\n\\n //////////\\n // TANGENT\\n //////////\\n#ifdef NEED_LOCAL_TANGENT\\n #ifdef HAS_POSITION_COMPRESSION\\n vec4 localTangent = Tangent.xyzz;\\n UNCOMPRESS_DIR(localTangent);\\n #else\\n vec4 localTangent = Tangent;\\n #endif\\n\\n #ifdef HAS_MORPHING_TANGENT\\n localTangent.xyz = morphing(nTargetWeights, localTangent.xyz ARG_MORPH_TANGENT_0 ARG_MORPH_TANGENT_1 ARG_MORPH_TANGENT_2 ARG_MORPH_TANGENT_3);\\n #endif\\n\\n #ifdef HAS_SKINNING\\n localTangent.xyz = (vec4(localTangent.xyz, 0.0) * boneMatrix).xyz;\\n #endif\\n\\n #if defined(HAS_MORPHING) || defined(HAS_SKINNING)\\n localTangent.xyz = normalize(localTangent.xyz);\\n #endif\\n\\n #ifdef HAS_MODEL_TANGENT\\n vModelTangent = vec4(uModelNormalMatrix * localTangent.xyz, localTangent.w).xyz;\\n #endif\\n\\n #ifdef HAS_VIEW_TANGENT\\n vViewTangent = vec4(uModelViewNormalMatrix * localTangent.xyz, localTangent.w);\\n #endif\\n#endif\\n\\n //////////////////\\n // DISPLACE VERTEX\\n //////////////////\\n#ifdef HAS_DISPLACEMENT\\n // we multiply by 1 - uDisplay2D here as we don\\'t want the displacement to appear in the 2D view of the inspector\\n float displacement = (COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT).PACK_DISPLACEMENT) - 0.5) * uDisplacementFactor * (1.0 - uDisplay2D);\\n #ifdef HAS_EDITOR_DISPLACEMENT\\n vModelVertex += normalize(vModelNormal) * displacement;\\n #else\\n vModelVertex += vec3(0.0, 0.0, 1.0) * (vModelVertex.z > 0.01 ? displacement : 0.0);\\n #endif\\n vViewVertex = uViewMatrix * vec4(vModelVertex, 1.0);\\n#else\\n vViewVertex = uModelViewMatrix * vec4(localVertex, 1.0);\\n#endif\\n\\n //////////////////\\n // DISPLACE NORMAL\\n //////////////////\\n#ifdef CORRECT_BUMP_NORMAL\\n // if there is no normal map, use displacement to correct normal\\n vec3 invSize = vec3(1.0 / uDisplacementSize, 0.0);\\n vec2 gradient = vec2(COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT - invSize.xz).PACK_DISPLACEMENT)\\n - COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT + invSize.xz).PACK_DISPLACEMENT),\\n COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT - invSize.zy).PACK_DISPLACEMENT)\\n -COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT + invSize.zy).PACK_DISPLACEMENT));\\n\\n localNormal = bumpMap(localTangent, localNormal, uDisplacementNormal * gradient);\\n\\n #if defined(HAS_VIEW_NORMAL)\\n vModelNormal = uModelNormalMatrix * localNormal;\\n #endif\\n\\n #ifdef HAS_VIEW_NORMAL\\n vViewNormal = uModelViewNormalMatrix * localNormal;\\n #endif\\n#endif\\n\\n ///////////////////////\\n // PROJECTION JITTERING (could be done on the CPU)\\n ///////////////////////\\n mat4 jitteredProjection = uProjectionMatrix;\\n#if defined(WIREFRAME)\\n vViewVertex.w += 0.005 / uProjectionMatrix[1][1];\\n#elif defined(SHADOW_CAST)\\n float doPersp = jitteredProjection[3][3] == 0.0 ? 1.0 : 0.0;\\n vec2 jitter = (abs(uHalton.z) == 2.0 ? 1.0 : 0.0) * (uHalton.xy / uShadowMapSize.xy);\\n jitteredProjection[2].xy += doPersp * jitter;\\n jitteredProjection[3].xy += (1.0 - doPersp) * jitter;\\n#elif !defined(NO_JITTER)\\n jitteredProjection[2].xy += (1.0 - uDisplay2D) * (uHalton.xy * uGlobalTexRatio.xy / uGlobalTexSize.xy);\\n#endif\\n\\n gl_Position = jitteredProjection * vViewVertex;\\n\\n#ifdef HAS_POINT_SIZE\\n gl_PointSize = min(64.0, max(1.0, -uPointSize / vViewVertex.z));\\n#else\\n gl_PointSize = 1.0;\\n#endif\\n\\n// probably not the best solution (in case you need custom things while including base.vert)\\n#ifdef INJECT_VERT\\n INJECT_VERT\\n#endif\\n}\\n',\r\n 'earlyz.vert': '#define HAS_VIEW_VERTEX\\n#pragma include \"base.vert\"\\n',\r\n // 'earlyz.frag':\r\n // '// opacity\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\nvarying vec4 vViewVertex;\\n\\n#pragma include \"utils/encodeDepth.glsl\"\\n\\n#pragma include \"utils/material.glsl\"\\n\\n#ifdef HAS_OPACITY\\n#pragma include \"utils/rand.glsl\"\\n#endif\\n\\nvoid main() {\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n#ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n float alpha = 1.0;\\n#if defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)\\n alpha = getMaterialOpacity();\\n if (uDrawOpaque == 1 && alpha < EPSILON_ALPHA) discard;\\n alpha = uDrawOpaque == 1 ? 1.0 : alpha;\\n#endif\\n\\n float depth = (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x);\\n float scatter = 0.0;\\n float profile = 0.0;\\n\\n#ifdef HAS_SUBSURFACESCATTERING\\n scatter = getMaterialScattering();\\n profile = uSubsurfaceScatteringProfile;\\n#endif\\n\\n gl_FragColor = encodeDepthAlphaProfileScatter(depth, alpha, profile, scatter);\\n}\\n',\r\n 'pbr.vert':\r\n '#define HAS_VIEW_NORMAL\\n#define HAS_VIEW_VERTEX\\n#pragma include \"base.vert\"\\n',\r\n 'pbr.frag':\r\n 'uniform float uRGBMRange;\\nuniform int uOutputLinear;\\n\\n// stuffs (ssr, opacity, scattering)\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\n// shadow signature...\\n#ifdef HAS_SUBSURFACETRANSLUCENCY\\n #define _OUT_DISTANCE\\n #define OPT_DISTANCE shadowDistance,\\n#else\\n #define OPT_DISTANCE\\n#endif\\n\\n//////////\\n// VARYING\\n//////////\\nvarying vec4 vViewVertex;\\nvarying vec3 vViewNormal;\\n\\n#ifdef HAS_SHADOW\\n varying vec3 vModelNormal;\\n varying vec3 vModelVertex;\\n#endif\\n\\n#ifdef HAS_VIEW_TANGENT\\n varying vec4 vViewTangent;\\n#endif\\n\\n#pragma include \"utils/common.glsl\"\\n\\n#pragma include \"utils/functions.glsl\"\\n\\n#pragma include \"utils/material.glsl\"\\n\\n// TODO ifdef around pragma include can result in error (files being included multiple times can be ignored)\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\n#pragma include \"utils/rand.glsl\"\\n\\n#if defined(HAS_NORMALMAP) || defined(HAS_BUMPMAP) || defined(HAS_CLEARCOATNORMALMAP) || defined(SAMPLER_ANISOTROPY)\\n#pragma include \"utils/normalBump.glsl\"\\n#endif\\n\\n#ifdef HAS_SHADOW\\n#pragma include \"shadowing/shadowReceive.glsl\"\\n#endif\\n\\n// /!\\\\ (lightsPBR is also included in clearcoat file, and ifdef around pragma include is not reliable)\\n#if defined(HAS_LIGHT) || defined(HAS_CLEARCOAT) || defined(HAS_SHEEN)\\n#pragma include \"utils/lightsPBR.glsl\"\\n#endif\\n\\n#ifdef HAS_ENVIRONMENT\\n#pragma include \"utils/environment.glsl\"\\n#endif\\n\\n#ifdef HAS_SUBSURFACETRANSLUCENCY\\n#pragma include \"utils/lightsSSS.glsl\"\\n#endif\\n\\n#ifdef HAS_SUBSURFACESCATTERING\\n#pragma include \"utils/checkerboard.glsl\"\\n#endif\\n\\n#ifdef HAS_CLEARCOAT\\n#pragma include \"utils/clearCoat.glsl\"\\n#endif\\n\\n// #ifdef HAS_OPACITY_DITHER\\n// #pragma include \"utils/rand.glsl\"\\n// #endif\\n\\n#ifdef HAS_OPACITY_REFRACTION\\n#pragma include \"utils/refraction.glsl\"\\n#endif\\n\\n#ifdef HAS_SSR\\n#pragma include \"utils/ssr.glsl\"\\n#endif\\n\\nfloat specularOcclusion(const in int occlude, const in float ao, const in vec3 normal, const in vec3 eyeVector) {\\n if (occlude == 0) return 1.0;\\n // Yoshiharu Gotanda\\'s specular occlusion approximation:\\n // cf http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx pg59\\n float d = dot(normal, eyeVector) + ao;\\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\\n}\\n\\nfloat adjustRoughnessNormalMap(const in float roughness, const in vec3 normal) {\\n // Based on The Order : 1886 SIGGRAPH course notes implementation (page 21 notes)\\n float nlen2 = dot(normal, normal);\\n if (nlen2 < 1.0) {\\n float nlen = sqrt(nlen2);\\n float kappa = (3.0 * nlen - nlen2 * nlen) / (1.0 - nlen2);\\n // http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/\\n // page 91 : they use 0.5/kappa instead\\n return min(1.0, sqrt(roughness * roughness + 1.0 / kappa));\\n }\\n return roughness;\\n}\\n\\nvec3 computeAnisotropicBentNormal(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 anisotropicT, const in vec3 anisotropicB, const in float anisotropy) {\\n vec3 anisotropyDirection = anisotropy >= 0.0 ? anisotropicB : anisotropicT;\\n vec3 anisotropicTangent = cross(anisotropyDirection, eyeVector);\\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\\n float bendFactor = abs(anisotropy) * clamp(5.0 * roughness, 0.0, 1.0);\\n return normalize(mix(normal, anisotropicNormal, bendFactor));\\n}\\n\\nvoid main() {\\n //////////////////\\n // OPACITY DISCARD\\n //////////////////\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n#ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n float alpha = getMaterialOpacity();\\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n // /!\\\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\\n#ifdef HAS_OPACITY_REFRACTION\\n gRefractionRoughness = uOpacityRoughnessFactor;\\n float alphaRefraction = getMaterialOpacity();\\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n ///////////\\n // GEOMETRY\\n ///////////\\n // https://twitter.com/pyalot/status/711956736639418369\\n vec3 eyeVector = -normalize(vViewVertex.xyz);\\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\\n\\n#ifdef HAS_VIEW_TANGENT\\n vec4 tangent;\\n tangent = vViewTangent;\\n\\n tangent = gl_FrontFacing ? tangent : -tangent;\\n tangent.xyz = normalize(tangent.xyz);\\n vec3 binormal = normalize(cross(frontNormal, tangent.xyz)) * tangent.w;\\n#endif\\n\\n ///////////\\n // MATERIAL\\n ///////////\\n#if defined(HAS_LEGACY_CLASSIC)\\n vec3 materialDiffuse = getMaterialLegacyDiffuse();\\n vec3 materialSpecular = getMaterialLegacySpecular();\\n#elif defined(HAS_METALNESSPBR)\\n float f0 = 0.08 * getMaterialF0();\\n float metal = getMaterialMetalness();\\n\\n #ifdef HAS_OPACITY_REFRACTION\\n metal *= alphaRefraction;\\n #endif\\n\\n vec3 materialDiffuse = getMaterialAlbedo();\\n vec3 materialSpecular = mix(vec3(f0), materialDiffuse, metal);\\n materialDiffuse *= 1.0 - metal;\\n#else\\n vec3 materialSpecular = getMaterialSpecular();\\n vec3 materialDiffuse = getMaterialDiffuse();\\n\\n #ifdef HAS_OPACITY_REFRACTION\\n materialSpecular *= mix(0.08, 1.0, alphaRefraction);\\n #endif\\n#endif // HAS_METALNESSPBR\\n\\n#if defined(HAS_ENVIRONMENT) || defined(HAS_LIGHT)\\n float materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\\n#endif\\n\\n#if defined(HAS_LEGACY_CLASSIC)\\n float materialShininess = getMaterialLegacyShininess();\\n float materialRoughness = 0.0;\\n#elif defined(HAS_ROUGHNESSPBR)\\n float materialRoughness = getMaterialRoughness();\\n#else\\n float materialRoughness = 1.0 - getMaterialGlossiness();\\n#endif // HAS_ROUGHNESSPBR\\n\\n#ifdef HAS_AOPBR\\n float materialAO = getMaterialAO();\\n#endif\\n\\n#ifdef HAS_EMITCOLOR\\n vec3 materialEmit = getMaterialEmitColor();\\n#endif\\n\\n#ifdef HAS_CAVITYPBR\\n float materialCavity = getMaterialCavity();\\n#endif\\n\\n#ifdef HAS_SUBSURFACETRANSLUCENCY\\n float materialTranslucency = getMaterialTranslucency();\\n#endif\\n\\n vec3 materialNormal = frontNormal;\\n#ifdef HAS_NORMALMAP\\n materialNormal = getMaterialNormalMap();\\n materialRoughness = adjustRoughnessNormalMap(materialRoughness, materialNormal);\\n materialNormal = transformNormal(uNormalMapFactor, materialNormal, tangent.xyz, binormal, frontNormal);\\n#endif\\n\\n#ifdef HAS_BUMPMAP\\n materialNormal = transformBump(getMaterialBumpMap(), tangent.xyz, binormal, frontNormal);\\n#endif\\n\\n#ifdef HAS_CLEARCOAT\\n float materialClearCoat = getMaterialClearCoat();\\n float materialClearCoatRoughness = getMaterialClearCoatRoughness();\\n #ifdef HAS_CLEARCOATNORMALMAP\\n vec3 materialClearCoatNormal = transformNormal(uClearCoatNormalMapFactor, getMaterialClearCoatNormal(), tangent.xyz, binormal, frontNormal);\\n #else\\n vec3 materialClearCoatNormal = frontNormal;\\n #endif\\n#endif\\n\\n#if defined(HAS_ANISOTROPY) && (defined(HAS_LIGHT) || defined(HAS_ENVIRONMENT))\\n float anisotropy = uAnisotropyFactor;\\n\\n #ifdef SAMPLER_ANISOTROPY\\n vec2 aniso = getMaterialDirectionAnisotropy();\\n vec3 anisotropicT = transformTangent(aniso, tangent.xyz, binormal);\\n // reproject tangent/binormal on the material normal plane\\n anisotropicT = normalize(anisotropicT - materialNormal * dot(anisotropicT, materialNormal));\\n vec3 anisotropicB = normalize(cross(materialNormal, anisotropicT.xyz));\\n\\n anisotropy *= length(aniso);\\n #else\\n #if defined(HAS_NORMALMAP) || defined(HAS_BUMPMAP)\\n // reproject tangent/binormal on the material normal plane\\n tangent.xyz = normalize(tangent.xyz - materialNormal * dot(tangent.xyz, materialNormal));\\n binormal = normalize(cross(materialNormal, tangent.xyz)) * tangent.w;\\n #endif\\n\\n vec3 anisotropicT = normalize(mix(tangent.xyz, binormal, uAnisotropyDirection));\\n vec3 anisotropicB = normalize(mix(binormal, -tangent.xyz, uAnisotropyDirection));\\n #endif\\n#endif\\n\\n vec3 diffuse = vec3(0.0);\\n vec3 specular = vec3(0.0);\\n\\n#if (defined(HAS_ENVIRONMENT) || defined(HAS_LIGHT))\\n #if defined(HAS_CLEARCOAT)\\n float ccNoV = saturate(dot(materialClearCoatNormal, -refract(eyeVector, materialClearCoatNormal, 1.0 / uClearCoatIor)));\\n #endif\\n #if defined(HAS_SHEEN)\\n float sheenRoughness = getMaterialSheenRoughness();\\n #endif\\n#endif\\n //////////////\\n // ENVIRONMENT\\n //////////////\\n#ifdef HAS_ENVIRONMENT\\n\\n #ifdef HAS_ANISOTROPY\\n vec3 bentAnisotropicNormal = computeAnisotropicBentNormal(materialNormal, eyeVector, materialRoughness, anisotropicT, anisotropicB, anisotropy);\\n #else\\n vec3 bentAnisotropicNormal = materialNormal;\\n #endif\\n\\n\\n diffuse = materialDiffuse * computeDiffuseSPH(materialNormal);\\n\\n #ifdef HAS_SHEEN\\n diffuse += computeSheen(materialNormal, getSpecularDominantDir(materialNormal, reflect(-eyeVector, materialNormal), sheenRoughness), eyeVector, sheenRoughness);\\n #endif\\n\\n #ifdef HAS_LEGACY_CLASSIC\\n specular = materialSpecular * textureCubeFixed(sEnvironmentSpecular, uEnvironmentTransform * normalize((2.0 * clamp(dot(materialNormal, eyeVector), 0.0, 1.0)) * materialNormal - eyeVector), uTextureEnvironmentSpecularTextureSize.x);\\n #else\\n specular = computeIBLSpecularUE4(bentAnisotropicNormal, eyeVector, materialRoughness, materialSpecular, frontNormal, materialF90);\\n #endif\\n\\n #ifdef HAS_CLEARCOAT\\n float ccF0 = materialClearCoat * F_Schlick(uClearCoatF0, 1.0, ccNoV);\\n vec3 ccAbsorbtion = getClearCoatAbsorbtion(ccNoV, ccNoV, materialClearCoat);\\n specular = mix(specular * ccAbsorbtion, getPrefilteredEnvMapColor(materialClearCoatNormal, eyeVector, materialClearCoatRoughness, frontNormal), ccF0);\\n diffuse *= ccAbsorbtion * (1.0 - ccF0);\\n #endif\\n\\n float aoSpec = 1.0;\\n #ifdef HAS_LEGACY_CLASSIC\\n aoSpec = uReflection;\\n specular *= aoSpec;\\n #endif\\n\\n #ifdef HAS_AOPBR\\n diffuse *= uEnvironmentExposure * materialAO;\\n aoSpec = specularOcclusion(uAOPBROccludeSpecular, materialAO, materialNormal, eyeVector);\\n specular *= uEnvironmentExposure * aoSpec;\\n #else\\n diffuse *= uEnvironmentExposure;\\n specular *= uEnvironmentExposure;\\n #endif // HAS_AOPBR\\n\\n #ifdef HAS_SSR\\n #ifdef HAS_CLEARCOAT\\n vec3 normalSsr = normalize(mix(bentAnisotropicNormal, materialClearCoatNormal, materialClearCoat * 0.5));\\n float roughnessSsr = mix(materialRoughness, materialClearCoatRoughness, materialClearCoat);\\n vec3 specularSsr = aoSpec * materialSpecular * mix(vec3(1.0), ccAbsorbtion, materialClearCoat);\\n specular = ssr(specular, specularSsr, roughnessSsr, normalSsr, eyeVector);\\n #else\\n specular = ssr(specular, materialSpecular * aoSpec, materialRoughness, bentAnisotropicNormal, eyeVector);\\n #endif\\n #endif // HAS_SSR\\n#endif // HAS_ENVIRONMENT\\n\\n /////////////////////////\\n // LIGHTING AND SHADOWING\\n /////////////////////////\\n#ifdef HAS_LIGHT\\n float attenuation, dotNL;\\n vec3 eyeLightDir;\\n bool lighted;\\n vec3 lightSpecular;\\n vec3 lightDiffuse;\\n vec4 prepGGX = precomputeGGX(materialNormal, eyeVector, max(MIN_ROUGHNESS, materialRoughness));\\n\\n #ifdef HAS_CLEARCOAT\\n vec4 prepGGXClearCoat = precomputeGGX(materialClearCoatNormal, eyeVector, materialClearCoatRoughness);\\n vec3 ccSpecular;\\n vec3 ccAttenuation;\\n #endif\\n#endif\\n\\n#ifdef HAS_SHADOW\\n float shadow;\\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\\n\\n #ifdef HAS_SUBSURFACETRANSLUCENCY\\n float shadowDistance;\\n #endif\\n#endif // HAS_SHADOW\\n\\n\\n%UNROLL 4%\\n#ifdef LIGHT_TYPE_%ID%\\n\\n #if LIGHT_TYPE_%ID% == LIGHT_SPOT\\n precomputeSpot(materialNormal, vViewVertex.xyz, uEditorLight%ID%_viewDirection, uEditorLight%ID%_attenuation, uEditorLight%ID%_viewPosition.xyz, uEditorLight%ID%_spotCutOff, uEditorLight%ID%_spotBlend, attenuation, eyeLightDir, dotNL);\\n #elif LIGHT_TYPE_%ID% == LIGHT_POINT\\n precomputePoint(materialNormal, vViewVertex.xyz, uEditorLight%ID%_attenuation, uEditorLight%ID%_viewPosition.xyz, attenuation, eyeLightDir, dotNL);\\n #elif LIGHT_TYPE_%ID% == LIGHT_DIRECTION\\n precomputeSun(materialNormal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\\n #elif LIGHT_TYPE_%ID% == LIGHT_HEMI\\n precomputeSun(materialNormal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\\n #endif\\n\\n #ifdef HAS_LEGACY_CLASSIC\\n #if LIGHT_TYPE_%ID% == LIGHT_HEMI\\n hemiLight(materialNormal, eyeVector, dotNL, eyeLightDir, materialDiffuse, materialSpecular, materialShininess, uEditorLight%ID%_diffuse.rgb, uEditorLight%ID%_ground.rgb, lightDiffuse, lightSpecular, lighted);\\n #else\\n computeLightLambertCookTorrance(materialNormal, eyeVector, dotNL, attenuation, materialDiffuse, materialSpecular, materialShininess, uEditorLight%ID%_diffuse.rgb, uEditorLight%ID%_diffuse.rgb, eyeLightDir, lightDiffuse, lightSpecular, lighted);\\n #endif\\n #else\\n #ifdef HAS_ANISOTROPY\\n computeLightLambertGGXAnisotropy(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, anisotropicT, anisotropicB, anisotropy, lightDiffuse, lightSpecular, lighted);\\n #else\\n computeLightLambertGGX(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, lightDiffuse, lightSpecular, lighted);\\n #endif\\n #endif\\n\\n #ifdef HAS_CLEARCOAT\\n computeLightLambertGGXClearCoat(ccNoV, materialClearCoatNormal, eyeVector, dot(materialClearCoatNormal, eyeLightDir), prepGGXClearCoat, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialClearCoat, ccSpecular, ccAttenuation);\\n lightDiffuse *= ccAttenuation;\\n lightSpecular = ccSpecular + lightSpecular * ccAttenuation;\\n #endif\\n\\n #ifdef HAS_SHEEN\\n lightDiffuse += computeSheen(materialNormal, eyeLightDir, eyeVector, sheenRoughness);\\n #endif\\n\\n\\n\\n #ifdef HAS_SHADOW_%ID%\\n #ifdef _ATLAS_SHADOW\\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\n #else\\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\n #endif // _ATLAS_SHADOW\\n\\n lightDiffuse *= shadow;\\n lightSpecular *= shadow;\\n\\n #ifdef HAS_SUBSURFACETRANSLUCENCY\\n lightDiffuse += computeLightSSS(dotNL, attenuation, uSubsurfaceTranslucencyThicknessFactor, uSubsurfaceTranslucencyColor, materialTranslucency, shadowDistance, materialDiffuse, uEditorLight%ID%_diffuse.rgb);\\n #endif\\n #endif // HAS_SHADOW\\n\\n diffuse += lightDiffuse;\\n specular += lightSpecular;\\n#endif // LIGHT_TYPE\\n%%\\n\\n /////////////\\n // REFRACTION\\n /////////////\\n#ifdef HAS_OPACITY_REFRACTION\\n #ifdef HAS_REFRACTION_NORMAL_OFFSET\\n vec3 refractLight = refraction(gRefractionRoughness, materialNormal, frontNormal);\\n #else\\n vec3 refractLight = refraction(gRefractionRoughness, materialNormal, eyeVector);\\n #endif\\n\\n #ifdef HAS_REFRACTION_ALBEDO_TINT\\n refractLight *= materialDiffuse;\\n #endif\\n\\n diffuse = mix(refractLight, diffuse, alphaRefraction);\\n#endif // HAS_OPACITY_REFRACTION\\n\\n //////////////////////\\n // SCATTERING AND EMIT\\n //////////////////////\\n#ifdef HAS_SUBSURFACESCATTERING\\n #ifdef HAS_EMITCOLOR\\n diffuse = uEmitMultiplicative == 1 ? diffuse * materialEmit : diffuse + materialEmit;\\n if (uEmitMultiplicative == 1) specular *= materialEmit;\\n #endif\\n vec3 frag = mix(specular, diffuse, checkerboard(gl_FragCoord.xy, uHalton));\\n#else\\n vec3 frag = diffuse + specular;\\n #ifdef HAS_EMITCOLOR\\n frag = uEmitMultiplicative == 1 ? frag * materialEmit : frag + materialEmit;\\n #endif\\n#endif // HAS_SUBSURFACESCATTERING\\n\\n#ifdef HAS_CAVITYPBR\\n frag *= materialCavity;\\n#endif\\n\\n // premult\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n frag *= alpha;\\n#endif\\n\\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\\n#else\\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\\n#endif\\n}\\n',\r\n 'outline.vert': '#define NO_JITTER 1\\n#pragma include \"baseVert.glsl\"\\n',\r\n 'outline.frag':\r\n 'uniform vec3 uOutlineColor;\\n\\nvoid main() {\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n gl_FragColor = vec4(uOutlineColor, 1.0);\\n}\\n',\r\n 'matcap.vert':\r\n '#define HAS_VIEW_NORMAL\\n#define HAS_VIEW_VERTEX\\n#pragma include \"base.vert\"\\n',\r\n 'matcap.frag':\r\n 'uniform float uRGBMRange;\\nuniform int uOutputLinear;\\n\\n// stuffs (ssr, opacity, scattering)\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\nuniform vec3 uMatcapColor;\\n\\nuniform int uInspectorView; // see globalUniforms\\n\\n//////////\\n// VARYING\\n//////////\\nvarying vec4 vViewVertex;\\nvarying vec3 vViewNormal;\\n\\n#ifdef HAS_VIEW_TANGENT\\nvarying vec4 vViewTangent;\\n#endif\\n\\n#pragma include \"utils/common.glsl\"\\n\\n#pragma include \"utils/functions.glsl\"\\n\\n#pragma include \"utils/material.glsl\"\\n\\n#pragma include \"utils/curvature.glsl\"\\n\\n// TODO ifdef around pragma include can result in error (files being included multiple times can be ignored)\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\n#pragma include \"utils/rand.glsl\"\\n\\n#ifdef HAS_VIEW_TANGENT\\n#pragma include \"utils/normalBump.glsl\"\\n#endif\\n\\n#ifdef HAS_OPACITY_REFRACTION\\n#pragma include \"utils/refraction.glsl\"\\n#endif\\n\\nvoid main() {\\n //////////////////\\n // OPACITY DISCARD\\n //////////////////\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n#ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n float alpha = getMaterialOpacity();\\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n// /!\\\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\\n#ifdef HAS_OPACITY_REFRACTION\\n gRefractionRoughness = uOpacityRoughnessFactor;\\n float alphaRefraction = getMaterialOpacity();\\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n ///////////\\n // GEOMETRY\\n ///////////\\n vec3 eyeVector = -normalize(vViewVertex.xyz);\\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\\n\\n#ifdef HAS_VIEW_TANGENT\\n vec4 tangent = gl_FrontFacing ? vViewTangent : -vViewTangent;\\n tangent.xyz = normalize(tangent.xyz);\\n vec3 binormal = normalize(cross(frontNormal, tangent.xyz)) * tangent.w;\\n#endif\\n\\n ///////////\\n // MATERIAL\\n ///////////\\n vec3 materialNormal = frontNormal;\\n#ifdef HAS_NORMALMAP\\n materialNormal = getMaterialNormalMap();\\n materialNormal = transformNormal(uNormalMapFactor, materialNormal, tangent.xyz, binormal, frontNormal);\\n#endif\\n\\n#ifdef HAS_BUMPMAP\\n materialNormal = transformBump(getMaterialBumpMap(), tangent.xyz, binormal, frontNormal);\\n#endif\\n\\n vec3 materialDiffuse = uMatcapColor;\\n#ifdef HAS_VERTEX_COLOR\\n materialDiffuse *= getVertexColor();\\n#endif\\n\\n vec3 nm_x = vec3(-eyeVector.z, 0.0, eyeVector.x);\\n vec3 nm_y = cross(nm_x, eyeVector);\\n vec2 uvMatcap = vec2(dot(materialNormal.xz, -nm_x.xz), dot(materialNormal, nm_y)) * 0.5 + 0.5;\\n vec3 diffuse = materialDiffuse * sRGBToLinear(texture2D(SAMPLER_MATCAP, uvMatcap).rgb) * getCurvature(materialNormal);\\n\\n /////////////\\n // REFRACTION\\n /////////////\\n#ifdef HAS_OPACITY_REFRACTION\\n\\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\\n vec3 refractLight = refraction(uOpacityRoughnessFactor, materialNormal, frontNormal);\\n#else\\n vec3 refractLight = refraction(uOpacityRoughnessFactor, materialNormal, eyeVector);\\n#endif\\n\\n#ifdef HAS_REFRACTION_ALBEDO_TINT\\n refractLight *= materialDiffuse;\\n#endif\\n\\n diffuse = mix(refractLight, diffuse, alphaRefraction);\\n#endif // HAS_OPACITY_REFRACTION\\n\\n vec3 frag = diffuse;\\n\\n if (uInspectorView == 2) {\\n frag = vec3(0.9, 0.75, 0.5) * max(0.25, dot(materialNormal.xyz, vec3(0.15, 0.3, 0.9)));\\n }\\n\\n// premult\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n frag *= alpha;\\n#endif\\n\\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\\n#else\\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\\n#endif\\n}\\n',\r\n 'shadeless.vert': '#pragma include \"pbr.vert\"\\n',\r\n 'shadeless.frag':\r\n 'uniform float uRGBMRange;\\nuniform int uOutputLinear;\\n\\n// stuffs (ssr, opacity, scattering)\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\n//////////\\n// VARYING\\n//////////\\n\\n#ifdef HAS_OPACITY_REFRACTION\\n varying vec3 vViewNormal;\\n varying vec4 vViewVertex;\\n#endif\\n\\n#pragma include \"utils/common.glsl\"\\n#pragma include \"utils/functions.glsl\"\\n#pragma include \"utils/material.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\n#ifdef HAS_OPACITY_REFRACTION\\n #pragma include \"utils/refraction.glsl\"\\n#endif\\n\\nvoid main() {\\n //////////////////\\n // OPACITY DISCARD\\n //////////////////\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n\\n#ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n float alpha = getMaterialOpacity();\\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n // /!\\\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\\n#ifdef HAS_OPACITY_REFRACTION\\n gRefractionRoughness = uOpacityRoughnessFactor;\\n float alphaRefraction = getMaterialOpacity();\\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n ///////////\\n // GEOMETRY\\n ///////////\\n#ifdef HAS_OPACITY_REFRACTION\\n vec3 eyeVector = -normalize(vViewVertex.xyz);\\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\\n#endif\\n\\n ///////////\\n // MATERIAL\\n ///////////\\n#if defined(HAS_LEGACY_CLASSIC)\\n vec3 materialDiffuse = getMaterialLegacyDiffuse();\\n#elif defined(HAS_ALBEDOPBR)\\n vec3 materialDiffuse = getMaterialAlbedo();\\n#else\\n vec3 materialDiffuse = getMaterialDiffuse();\\n#endif\\n\\n#ifdef HAS_AOPBR\\n float materialAO = getMaterialAO();\\n#endif\\n\\n#ifdef HAS_EMITCOLOR\\n vec3 materialEmit = getMaterialEmitColor();\\n#endif\\n\\n#ifdef HAS_CAVITYPBR\\n float materialCavity = getMaterialCavity();\\n#endif\\n\\n vec3 diffuse = materialDiffuse;\\n\\n#ifdef HAS_AOPBR\\n diffuse *= materialAO;\\n#endif\\n\\n /////////////\\n // REFRACTION\\n /////////////\\n#ifdef HAS_OPACITY_REFRACTION\\n #ifdef HAS_REFRACTION_NORMAL_OFFSET\\n vec3 refractLight = refraction(uOpacityRoughnessFactor, frontNormal, frontNormal);\\n #else\\n vec3 refractLight = refraction(uOpacityRoughnessFactor, frontNormal, eyeVector);\\n #endif\\n\\n #ifdef HAS_REFRACTION_ALBEDO_TINT\\n refractLight *= materialDiffuse;\\n #endif\\n\\n diffuse = mix(refractLight, diffuse, alphaRefraction);\\n#endif // HAS_OPACITY_REFRACTION\\n\\n vec3 frag = diffuse;\\n\\n#ifdef HAS_EMITCOLOR\\n frag = uEmitMultiplicative == 1 ? frag * materialEmit : frag + materialEmit;\\n#endif\\n\\n#ifdef HAS_CAVITYPBR\\n frag *= materialCavity;\\n#endif\\n\\n // premult\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n frag *= alpha;\\n#endif\\n\\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\\n#else\\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\\n#endif\\n}\\n',\r\n 'wireframe.vert': '#define WIREFRAME\\n#pragma include \"base.vert\"\\n',\r\n 'wireframe.frag':\r\n 'uniform vec4 uColor;\\n\\nvoid main() {\\n gl_FragColor = vec4(uColor.rgb * uColor.a, uColor.a);\\n}\\n',\r\n 'inspector/inspector.vert': '#pragma include \"base.vert\"\\n',\r\n 'inspector/inspector.frag':\r\n 'uniform float uRGBMRange;\\nuniform int uOutputLinear;\\n\\n// stuffs (ssr, opacity, scattering)\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\nuniform float uDisplay2D;\\nuniform int uInspectorView; // see globalUniforms\\n\\nuniform float uInspectorFactor;\\nuniform int uInspectorInvert;\\nuniform float uInspectorMaskThreshold;\\nuniform vec3 uInspectorColor;\\n\\nuniform vec2 uHoverUV;\\nuniform int uInspectorSelected;\\nuniform int uInspectorWireframe;\\n\\n#ifdef FEEDBACK_UV\\n vec3 colorHoverUV(const in vec3 frag) {\\n if (uInspectorSelected == 0) return frag;\\n return mix(vec3(1.0, 0.0, 0.0), frag, smoothstep(0.01, 0.02, distance(FEEDBACK_UV, uHoverUV)));\\n }\\n#endif\\n\\n#pragma include \"utils/functions.glsl\"\\n#pragma include \"utils/material.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\nvoid main() {\\n //////////////////\\n // OPACITY DISCARD\\n //////////////////\\n#ifdef HAS_POINT_CIRCLE\\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\\n#endif\\n\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n#ifdef HAS_OPACITY_DITHER\\n if (uDisplay2D == 0.0) ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n float alpha = 1.0;\\n float alphaFinal = 1.0;\\n\\n if (uDisplay2D == 0.0) {\\n alpha = getMaterialOpacity();\\n alphaFinal = alpha * float(1 - uOpacityAdditive);\\n }\\n\\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\\n#endif\\n\\n ///////////\\n // MATERIAL\\n ///////////\\n vec3 frag = vec3(0.0);\\n#ifdef HAS_INSPECTOR\\n frag = uInspectorFactor * COLOR_CONVERT_INSPECTOR(texture2D(SAMPLER_INSPECTOR, UV_INSPECTOR).PACK_INSPECTOR);\\n if (uInspectorInvert == 1) frag = 1.0 - frag;\\n\\n if (uInspectorMaskThreshold > 0.0 && uDisplay2D == 0.0) frag = frag.x < uInspectorMaskThreshold ? vec3(0.0) : vec3(1.0);\\n\\n #ifdef HAS_VERTEX_COLOR\\n #ifdef HAS_VERTEX_ALPHA\\n frag *= getVertexColor();\\n #else\\n frag *= uInspectorView == 1 ? sRGBToLinear(vColor.aaa) : getVertexColor();\\n #endif\\n #endif\\n\\n // we want to display the linear textures as srgb textures, see comment in channelFactoryViewModel\\n #ifdef CONVERT_INSPECTOR_TO_LINEAR\\n frag = sRGBToLinear(frag);\\n #endif\\n\\n #ifdef HAS_INSPECTOR_TEXTURE\\n frag *= uInspectorColor;\\n #endif\\n\\n frag = colorHoverUV(frag);\\n#endif\\n\\n // premult\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n frag *= alpha;\\n#endif\\n\\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\\n\\n if (uDisplay2D == 1.0) {\\n gl_FragColor = vec4(frag, 1.0);\\n return;\\n }\\n\\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\\n#else\\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\\n#endif\\n}\\n',\r\n 'shadowing/shadowCast.vert':\r\n 'uniform vec2 uShadowMapSize;\\n#define SHADOW_CAST\\n#define HAS_VIEW_VERTEX\\n#pragma include \"baseVert.glsl\"\\n',\r\n 'shadowing/shadowCast.frag':\r\n '// opacity\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\nuniform vec4 uShadowDepthRange;\\n\\nvarying vec4 vViewVertex;\\n\\n#pragma include \"utils/material.glsl\"\\n\\n#ifdef HAS_OPACITY\\n#pragma include \"utils/material.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n#endif\\n\\nvec4 encodeFloatRGBA( float v ) {\\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\\n enc = fract(enc);\\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\\n return enc;\\n}\\n\\nvoid main() {\\n#ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n#endif\\n#ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n#endif\\n\\n#if defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)\\n if (getMaterialOpacity() < EPSILON_ALPHA) discard;\\n#endif\\n\\n gl_FragColor = encodeFloatRGBA((-vViewVertex.z - uShadowDepthRange.x) / (uShadowDepthRange.y - uShadowDepthRange.x));\\n}\\n',\r\n 'ARKit/shadowAr.vert': '#pragma include \"base.vert\"\\n',\r\n 'ARKit/shadowAr.frag':\r\n '\\n#pragma include \"shadowing/shadowReceive.glsl\"\\n\\nvarying vec3 vModelNormal;\\nvarying vec3 vModelVertex;\\n\\nvoid main() {\\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\\n #ifdef _ATLAS_SHADOW\\n float shadow = shadowReceive(true, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture0_projection, uShadow_Texture0_viewRight, uShadow_Texture0_viewUp, uShadow_Texture0_viewLook, uShadow_Texture0_depthRange, uShadowReceive0_bias, uShadow_Texture0_mapSize, uStaticFrameNumShadow0);\\n #else\\n float shadow = shadowReceive(true, modelNormal, vModelVertex, Texture12, uShadow_Texture0_renderSize, uShadow_Texture0_projection, uShadow_Texture0_viewRight, uShadow_Texture0_viewUp, uShadow_Texture0_viewLook, uShadow_Texture0_depthRange, uShadowReceive0_bias, uStaticFrameNumShadow0);\\n #endif\\n\\n // not much blending, so no need to convert to srgb\\n // gl_FragColor = vec4(0.0, 0.0, 0.0, linearTosRGB(0.5 - shadow));\\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.5 - shadow);\\n}\\n',\r\n 'webVR/controller.vert':\r\n '#define HAS_VERTEX_COLOR\\n#define HAS_VIEW_VERTEX\\n#define HAS_VIEW_NORMAL\\n#pragma include \"base.vert\"\\n',\r\n 'webVR/controller.frag':\r\n '#define MIN_ROUGHNESS 0.045\\n\\nuniform float uRGBMRange;\\nuniform int uOutputLinear;\\n\\nvarying vec4 vViewVertex;\\nvarying vec3 vViewNormal;\\nvarying vec4 vColor;\\n\\nuniform float uNormalSign;\\nuniform vec3 uAlbedo;\\nuniform float uRoughness;\\nuniform float uMetalness;\\n\\nvec3 lightDir = normalize(vec3(0.0, 0.3, 0.9));\\nvec3 lightColor = vec3(0.7, 0.7, 0.9);\\n\\n#pragma include \"utils/functions.glsl\"\\n\\n#pragma include \"utils/lightsPBR.glsl\"\\n\\nvoid main() {\\n vec3 eyeVector = -normalize(vViewVertex.xyz);\\n vec3 materialNormal = uNormalSign * normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\\n\\n // material\\n float f0 = 0.04;\\n vec3 materialDiffuse = uAlbedo * vColor.r;\\n vec3 materialSpecular = mix(vec3(f0), materialDiffuse, uMetalness);\\n materialDiffuse *= 1.0 - uMetalness;\\n float materialRoughness = max(MIN_ROUGHNESS, uRoughness);\\n float materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\\n\\n // precompute light\\n float attenuation, dotNL;\\n vec3 eyeLightDir;\\n bool lighted;\\n vec3 lightSpecular;\\n vec3 lightDiffuse;\\n vec4 prepGGX = precomputeGGX(materialNormal, eyeVector, materialRoughness);\\n\\n // shading\\n attenuation = 1.0;\\n dotNL = dot(lightDir, materialNormal);\\n computeLightLambertGGX(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, lightColor, lightDir, materialF90, lightDiffuse, lightSpecular, lighted);\\n\\n vec3 frag = lightDiffuse + lightSpecular;\\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\\n}\\n',\r\n 'debug/boneBox.vert':\r\n '#define HAS_VIEW_NORMAL\\n#pragma include \"base.vert\"\\n',\r\n 'debug/boneBox.frag':\r\n 'uniform float uRGBMRange;\\n\\nvarying vec3 vViewNormal;\\n\\n#pragma include \"utils/functions.glsl\"\\n\\nvoid main(void) {\\n gl_FragColor = encodeRGBM(0.5 * vec3(abs(dot(vViewNormal.xyz, vec3(0.3, 0.6, 0.9)))), uRGBMRange);\\n}\\n',\r\n 'debug/normal.vert':\r\n 'attribute float Offset;\\nuniform float uScale;\\n\\n#define HAS_MODEL_VERTEX\\n#define HAS_MODEL_NORMAL\\n\\n#define INJECT_VERT gl_Position = uProjectionMatrix * uViewMatrix * vec4(Offset == 1.0 ? vModelVertex + normalize(vModelNormal) * uScale : vModelVertex, 1.0);\\n\\n#pragma include \"base.vert\"\\n',\r\n 'debug/normal.frag':\r\n 'uniform vec3 uColorDebug;\\n\\nvoid main(void) {\\n gl_FragColor = vec4(uColorDebug, 1.0);\\n}\\n',\r\n 'debug/tangent.vert':\r\n 'attribute float Offset;\\nuniform float uScale;\\n\\n#define HAS_MODEL_VERTEX\\n#define HAS_MODEL_TANGENT\\n\\n#define INJECT_VERT gl_Position = uProjectionMatrix * uViewMatrix * vec4(Offset == 1.0 ? vModelVertex + normalize(vModelTangent) * uScale : vModelVertex, 1.0);\\n\\n#pragma include \"base.vert\"\\n',\r\n 'debug/tangent.frag':\r\n 'uniform vec3 uColorDebug;\\n\\nvoid main(void) {\\n gl_FragColor = vec4(uColorDebug, 1.0);\\n}\\n',\r\n 'debug/skinning.vert':\r\n 'attribute vec3 BonesColor;\\nvarying vec3 vBonesColor;\\n\\n#define NO_JITTER\\n#define INJECT_VERT vBonesColor = BonesColor;\\n\\n#pragma include \"base.vert\"\\n',\r\n 'debug/skinning.frag':\r\n 'varying vec3 vBonesColor;\\n\\nvoid main(void) {\\n gl_FragColor = vec4(vBonesColor, 1.0);\\n}\\n',\r\n 'debug/geometry.vert': '#define NO_JITTER\\n#pragma include \"base.vert\"\\n',\r\n 'debug/geometry.frag':\r\n 'uniform vec3 uColorDebug;\\n\\nvoid main(void) {\\n gl_FragColor = vec4(uColorDebug, 1.0);\\n}\\n',\r\n 'ground/ground.vert': '#pragma include \"base.vert\"\\n',\r\n 'ground/ground.frag':\r\n '#pragma include \"utils/encodeDepth.glsl\"\\nuniform vec2 uNearFar;\\nvarying vec4 vViewVertex;\\n\\nuniform float uGroundFade;\\nuniform float uGroundOpacity;\\nuniform float uChanging;\\n\\nvarying vec2 vTexCoord0;\\n\\n#ifdef PASS_THROUGH\\n float getShadow(){\\n return 1.0;\\n }\\n#endif\\n\\n#ifdef SHADOW_CATCHER\\n\\n varying vec3 vModelNormal;\\n varying vec3 vModelVertex;\\n\\n #define OPT_DISTANCE\\n #pragma include \"shadowing/shadowReceive.glsl\"\\n\\n #pragma include \"utils/getLuminance.glsl\"\\n\\n %UNROLL 4%\\n #ifdef LIGHT_TYPE_%ID%\\n uniform vec4 uEditorLight%ID%_diffuse;\\n #endif\\n %%\\n\\n\\n float getShadow(){\\n float shadow = 0.0;\\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\\n bool lighted = true;\\n\\n float weight;\\n float sumWeights = 0.0;\\n\\n %UNROLL 4%\\n #ifdef LIGHT_TYPE_%ID%\\n #ifdef HAS_SHADOW_%ID%\\n weight = getLuminance(uEditorLight%ID%_diffuse.rgb);\\n #ifdef _ATLAS_SHADOW\\n shadow += weight * shadowReceive(lighted, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\n #else\\n shadow += weight * shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\n #endif // _ATLAS_SHADOW\\n sumWeights += weight;\\n #endif // HAS_SHADOW\\n #endif // LIGHT_TYPE\\n %%\\n\\n #ifdef HAS_SHADOW\\n shadow /= sumWeights;\\n #else\\n shadow = 1.0;\\n #endif\\n\\n return shadow;\\n }\\n#endif\\n\\n#ifdef BAKED_AO\\n #pragma include \"utils/encodeDecode.glsl\"\\n uniform sampler2D uTexture;\\n\\n float getShadow(){\\n return decode24(texture2D(uTexture, vTexCoord0).rgb);\\n }\\n#endif\\n\\n#ifdef DISPLAY_PLANE\\n const float gridSize = 10.0;\\n const vec4 overlayColor = vec4(0.109,0.664,0.848,1.0);\\n#endif\\n\\nuniform float uWidgetFade;\\n\\nvoid main() {\\n float shadow = getShadow();\\n #ifndef DISPLAY_PLANE\\n\\t if (shadow >= 0.99) discard;\\n #endif\\n vec2 centerUV = vTexCoord0 * 2.0 - 1.0;\\n float fade = clamp(1.0 - dot(centerUV, centerUV) * (pow(10.0, uGroundFade) - 1.0) , 0.0, 1.0);\\n\\n float alpha = (1.0 - shadow) * uGroundOpacity * fade;\\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0) * uGroundOpacity * fade * alpha;\\n\\n\\n #ifdef DISPLAY_PLANE\\n float gridValue = clamp(step(0.03,fract(vTexCoord0.x * gridSize))\\n * step(0.03,fract(vTexCoord0.y * gridSize)),0.0,1.0)\\n * step(vTexCoord0.x,0.997)\\n * step(vTexCoord0.y,0.997);\\n\\n gl_FragColor = mix(overlayColor * fade, gl_FragColor, uWidgetFade) * vec4(gridValue,gridValue,gridValue,1.0);\\n #endif\\n\\n}\\n',\r\n 'ground/bakeShadowMap.vert': '#pragma include \"base.vert\"\\n',\r\n 'ground/bakeShadowMap.frag':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n\\n// opacity\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uFrameMod;\\nuniform int uDrawOpaque;\\n\\n#ifdef HAS_OPACITY\\n#pragma include \"utils/material.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n#endif\\n\\nvoid main(void) {\\n\\n #ifdef HAS_ALPHAMASK\\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\\n #endif\\n #ifdef HAS_OPACITY_DITHER\\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\\n #endif\\n\\n #if defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)\\n if (getMaterialOpacity() < EPSILON_ALPHA) discard;\\n #endif\\n\\n // Depth in clip space\\n float depth = gl_FragCoord.z / gl_FragCoord.w;\\n gl_FragColor.rgb = encode24(depth);\\n gl_FragColor.a = 1.0;\\n\\n}\\n',\r\n};\r\n","export default {\r\n 'passThrough.glsl':\r\n '#ifdef VR_DISTORTION\\nuniform vec2 uDistortion;\\nuniform vec4 uProjectionLeft;\\nuniform vec4 uUnprojectionLeft;\\n\\n#pragma include \"distortion.glsl\"\\n#endif\\n\\n#ifdef ASCII_FOOL\\n#pragma include \"ascii.glsl\"\\n#endif\\n\\nuniform sampler2D TextureInput;\\n\\nvec4 passThrough() {\\n#ifdef VR_DISTORTION\\n gTexCoord = distortion(gTexCoord);\\n#endif\\n\\n#ifdef ASCII_FOOL\\n return ascii(gTexCoord.xy);\\n#else\\n return TEXTURE_2D_TextureInput(gTexCoord);\\n#endif\\n}\\n',\r\n 'setDepthAlpha.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureInput;\\nuniform sampler2D TextureDepth;\\n\\nuniform sampler2D TextureRefraction;\\nuniform vec2 uTextureRefractionSize;\\nuniform vec2 uTextureRefractionRatio;\\n\\n// no background scenario\\nvec4 setDepthAlpha(const in vec4 color) {\\n#ifdef REFRACTION_FORCE_ALPHA_ONE\\n // detect if we are on a refraction pixel\\n vec2 uvRef = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\\n if (texture2D(TextureRefraction, uvRef * uTextureRefractionRatio).a > 0.0) return vec4(color.rgb, 1.0);\\n#endif\\n\\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\n return vec4(color.rgb, alpha);\\n}',\r\n 'combineOpacity.glsl':\r\n 'uniform sampler2D TextureTransparent; \\nfloat gTransparentAlpha;\\n\\nvec4 combineOpacity(const in vec4 color) {\\n\\t// should be replaced with TEXTURE_2D_TextureTransparent as is can make sense\\n vec4 transparent = TEXTURE_2D_TextureTransparent(gTexCoord); \\n gTransparentAlpha = transparent.a; \\n return vec4(color.rgb * (1.0 - transparent.a) + transparent.rgb, 1.0);\\n}',\r\n 'combineRefraction.glsl':\r\n 'uniform sampler2D TextureInput;\\nuniform sampler2D TextureRefraction;\\n\\nuniform vec2 uTextureRefractionSize;\\nuniform vec2 uTextureRefractionRatio;\\nuniform float uRGBMRange;\\n\\nvec4 combineRefraction() {\\n // manual fetch to check m value of rgba : we use m 0 (invalid of rgbm) as masking\\n vec2 uv = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\\n vec4 rgbmRefraction = texture2D(TextureRefraction, uv * uTextureRefractionRatio);\\n\\n vec4 background = TEXTURE_2D_TextureInput(gTexCoord);\\n if (rgbmRefraction.a == 0.0) return background;\\n return vec4(decodeRGBM(rgbmRefraction, uRGBMRange), 1.0);\\n}',\r\n 'packMipmapRefraction.glsl':\r\n 'uniform sampler2D TextureRefractionBlur0;\\nuniform sampler2D TextureRefractionBlur1;\\nuniform sampler2D TextureRefractionBlur2;\\nuniform sampler2D TextureRefractionBlur3;\\nuniform sampler2D TextureRefractionBlur4;\\nuniform sampler2D TextureRefractionBlur5;\\nuniform sampler2D TextureRefractionBlur6;\\nuniform sampler2D TextureRefractionBlur7;\\nuniform vec2 uTextureOutputRatio;\\n\\nvec4 packMipmapRefraction() {\\n vec4 result = vec4(0.0, 0.0, 0.0, 1.0);\\n\\n // see _hookComposerResize in NodePostProcess.js (mipmap)\\n gTexCoord.y /= uTextureOutputRatio.y;\\n\\n float levelLog = -log2(1.0 - gTexCoord.y) + 1.0;\\n float level = floor(levelLog) - 1.0;\\n\\n float pLevel = pow(2.0, level + 1.0); // 2, 4, 8, 16...\\n gTexCoord.x = pLevel * gTexCoord.x * 0.5;\\n gTexCoord.y = pLevel * (1.0 - gTexCoord.y) - 1.0;\\n\\n // unused part of the texture\\n if (gTexCoord.x > 1.0 || gTexCoord.y > 1.0) return result;\\n\\n if (level < 0.1) result.rgb = TEXTURE_2D_TextureRefractionBlur0(gTexCoord).rgb;\\n else if (level < 1.1) result.rgb = TEXTURE_2D_TextureRefractionBlur1(gTexCoord).rgb;\\n else if (level < 2.1) result.rgb = TEXTURE_2D_TextureRefractionBlur2(gTexCoord).rgb;\\n else if (level < 3.1) result.rgb = TEXTURE_2D_TextureRefractionBlur3(gTexCoord).rgb;\\n else if (level < 4.1) result.rgb = TEXTURE_2D_TextureRefractionBlur4(gTexCoord).rgb;\\n else if (level < 5.1) result.rgb = TEXTURE_2D_TextureRefractionBlur5(gTexCoord).rgb;\\n else if (level < 6.1) result.rgb = TEXTURE_2D_TextureRefractionBlur6(gTexCoord).rgb;\\n else if (level < 7.1) result.rgb = TEXTURE_2D_TextureRefractionBlur7(gTexCoord).rgb;\\n\\n return result;\\n}\\n',\r\n 'sssCommon.glsl':\r\n '#pragma include \"utils/checkerboard.glsl\"\\n\\n// blur jimenez\\n// https://github.com/iryoku/separable-sss/blob/master/SeparableSSS.h#L454\\n\\n// blur UE4 (based on jimenez)\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/SeparableSSS.usf\\n\\n// UE 4 pre/post passes (down/upsample/checkerboard)\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/PostProcessSubsurface.usf\\n\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Common.usf#L501\\n// also solution 2 of http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color\\nfloat luminanceLinear(const in vec3 color) {\\n return dot(color, vec3(0.3, 0.59, 0.11));\\n}\\n\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/PostProcessSubsurface.usf#L247\\nvoid uncheckerboard(out vec3 diffuse, out vec3 specular) {\\n\\n vec2 coordCenter = floor(gTexCoord * uTextureSSSColorSize) + 0.5;\\n vec2 uvCenter = coordCenter / uTextureSSSColorSize;\\n // not precomputing offset as 1.0/uTextureSSSColorSize.xy\\n // to make sure we don\\'t loose precision and end up with ABCD being same texel\\n // on low precision gpu\\n vec3 offset = vec3(1.0, 1.0, 0.0);\\n\\n vec3 A = TEXTURE_2D_TextureSSSColor((coordCenter + offset.xz)/ uTextureSSSColorSize.xy).rgb;\\n vec3 B = TEXTURE_2D_TextureSSSColor((coordCenter - offset.xz)/ uTextureSSSColorSize.xy).rgb;\\n vec3 C = TEXTURE_2D_TextureSSSColor((coordCenter + offset.zy)/ uTextureSSSColorSize.xy).rgb;\\n vec3 D = TEXTURE_2D_TextureSSSColor((coordCenter - offset.zy)/ uTextureSSSColorSize.xy).rgb;\\n\\n // Luminance could be green channel only\\n float a = luminanceLinear(A);\\n float b = luminanceLinear(B);\\n float c = luminanceLinear(C);\\n float d = luminanceLinear(D);\\n\\n float ab = abs(a - b);\\n float cd = abs(c - d);\\n\\n // take the average in the direction that avoids dither pattern\\n vec3 quant1 = 0.5 * mix(A + B, C + D, ab > cd ? 1.0 : 0.0);\\n vec3 quant0 = TEXTURE_2D_TextureSSSColor(uvCenter).rgb;\\n\\n float checker = checkerboard(coordCenter, uHalton);\\n diffuse = mix(quant1, quant0, checker);\\n specular = mix(quant0, quant1, checker);\\n}\\n\\n',\r\n 'sssExtract.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureSSSColor;\\nuniform sampler2D TextureDepth;\\nuniform vec2 uTextureSSSColorSize;\\n\\nuniform vec4 uHalton;\\n\\n#pragma include \"sssCommon.glsl\"\\n\\n// hacky line to force the composerPostprocess to\\n// hook texture funciton in sssCommon because pragma defines\\n// aren\\'t handled directly\\n\\n// TEXTURE_2D_TextureSSSColor(whatever)\\nvec4 sssExtract() {\\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\\n vec3 specular;\\n vec3 diffuse;\\n uncheckerboard(diffuse, specular);\\n\\n // force depth \"0.0\" to tell sss blur to skip the pixel when blurring\\n // make sure to return float not bool cast to float implicitely\\n // not all glsl compiler support that\\n float bgOrNotSSS = (decodeProfile(pack) == 0 || pack.x == 1.0) ? 0.0 : 1.0;\\n return vec4(diffuse, bgOrNotSSS * decodeDepth(pack));\\n}\\n',\r\n 'sssBlur.glsl':\r\n '#pragma include \"utils/functions.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\nuniform sampler2D TextureSSSBlur;\\nuniform sampler2D TextureDepth;\\nuniform sampler2D TextureSSSKernel;\\n\\nuniform vec2 uNearFar;\\n\\nuniform vec2 uBlurDir;\\nuniform float uProjFactor;\\nuniform float uScatteringFactorPacker;\\nuniform float uFrameModTaaSS;\\n\\n#ifndef SSS_JITTER\\n#define SSS_JITTER 1.0\\n#endif\\n\\n#ifndef SSS_HALF_KERNEL_SIZE\\n#define SSS_HALF_KERNEL_SIZE 11\\n#endif\\n\\n#ifndef SSS_PROFILE_COUNT\\n#define SSS_PROFILE_COUNT 1\\n#endif\\n\\n#define SSS_FOLLOW_SURFACE\\n\\n// if we want to do it branchless\\nvec3 sssFetchColorBranchless(const in vec2 uv, const in vec4 colorM, const in float depthNormBias){\\n vec4 fetch = TEXTURE_2D_TextureSSSBlur(uv);\\n\\n#ifdef SSS_FOLLOW_SURFACE\\n float mixer = smoothstep(0.0, 0.05, abs(colorM.a - fetch.a) * depthNormBias);\\n mixer = mix(mixer, 1.0, step(fetch.a, 0.0)); // force to 1 if fetch.a is 0 (background)\\n fetch.rgb = mix(fetch.rgb, colorM.rgb, mixer);\\n#endif\\n\\n // uv inside box\\n // https://stackoverflow.com/questions/12751080/glsl-point-inside-box-test\\n vec2 s = step(vec2(0.0), uv) - step(vec2(1.0), uv);\\n return mix(colorM.rgb, fetch.rgb, s.x * s.y);\\n}\\n\\nvec3 sssFetchColor(const in vec2 uv, const in vec4 colorM, const in float depthNormBias){\\n if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) {\\n return colorM.rgb;\\n }\\n\\n // ignore sss with big depth difference, original jimenez is clamp(dDiff, 0.0, 1.0)\\n // we use a much more aggressive function\\n vec4 fetch = TEXTURE_2D_TextureSSSBlur(uv);\\n\\n#ifdef SSS_FOLLOW_SURFACE\\n if (fetch.a == 0.0) return colorM.rgb;\\n return mix(fetch.rgb, colorM.rgb, smoothstep(0.0, 0.05, abs(colorM.a - fetch.a) * depthNormBias));\\n#else\\n return fetch.rgb;\\n#endif\\n}\\n\\nvec4 sssBlur() {\\n vec4 colorM = TEXTURE_2D_TextureSSSBlur(gTexCoord);\\n\\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\\n\\n // background or not sss stuffs\\n if (pack.x == 1.0) {\\n return colorM;\\n }\\n\\n int profile = decodeProfile(pack);\\n float scatter = decodeScatter(pack);\\n if (scatter == 0.0) {\\n return colorM;\\n }\\n\\n float scatterWorld = scatter / uScatteringFactorPacker;\\n float depthRange = (uNearFar.y - uNearFar.x);\\n\\n // for follow surface\\n // factor to get a normalized depth difference depending of scatter but not of camera position\\n float depthNormBias = depthRange * 0.05 / scatterWorld;\\n\\n float worldPos = uNearFar.x + depthRange * colorM.a;\\n // uScatteringFactorPacker is just a unpacking factor because subsurface factor \\n // is a world space value but written in 8 bit texture\\n vec2 finalStep = uBlurDir * uProjFactor * scatterWorld / worldPos;\\n finalStep *= 1.0 / 3.0;\\n\\n float yProfile = 1.0 - (float(profile) - 0.5) / float(SSS_PROFILE_COUNT);\\n float xKernelSize = 1.0 / float(SSS_HALF_KERNEL_SIZE);\\n\\n vec3 kernel0 = texture2D(TextureSSSKernel, vec2(xKernelSize * 0.5, yProfile)).rgb;\\n vec3 colorBlurred = colorM.rgb * kernel0;\\n\\n // force nearest sample for sss texture kernel color\\n vec2 offKernelNearest = vec2(0.5 * xKernelSize, 0.0);\\n\\n // randomize the sss texture alpha weight a bit\\n float rnd = interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS);\\n rnd = mix(0.5, rnd, SSS_JITTER);\\n vec2 offKernelJitter = vec2(rnd * xKernelSize, 0.0);\\n\\n for (int i = 1; i < SSS_HALF_KERNEL_SIZE; i++) {\\n vec2 uvKernel = vec2(float(i) * xKernelSize, yProfile);\\n\\n vec3 kernel = texture2D(TextureSSSKernel, uvKernel + offKernelNearest).rgb;\\n float kernelDither = texture2D(TextureSSSKernel, uvKernel + offKernelJitter).a;\\n\\n vec2 offset = kernelDither * finalStep;\\n\\n vec3 fetch = sssFetchColor(gTexCoord + offset, colorM, depthNormBias);\\n fetch += sssFetchColor(gTexCoord - offset, colorM, depthNormBias);\\n\\n colorBlurred += kernel.rgb * fetch;\\n }\\n\\n return vec4(colorBlurred, colorM.a);\\n}\\n',\r\n 'sssCombine.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureSSSColor;\\nuniform vec2 uTextureSSSColorSize;\\n\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\nuniform float uProjFactor;\\nuniform float uScatteringFactorPacker;\\n\\n#pragma include \"sssCommon.glsl\"\\n\\nuniform sampler2D TextureSSSBlur;\\nuniform sampler2D TextureDepth;\\n\\nvec4 sssCombine() {\\n\\n // full res - not SSS\\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\\n int profile = decodeProfile(pack);\\n // black pixels for background or non sss surfaces\\n if (pack.x == 1.0 || profile == 0) {\\n return TEXTURE_2D_TextureSSSColor(gTexCoord);\\n }\\n\\n vec3 specular;\\n vec3 diffuse;\\n uncheckerboard(diffuse, specular);\\n\\n // try to retain high res detail as much as possible (same ad dof)\\n // make sure to use a factor that is independent from bounding box\\n float scatterWorld = decodeScatter(pack) / uScatteringFactorPacker;\\n float worldPos = uNearFar.x + (uNearFar.y - uNearFar.x) * decodeDepth(pack);\\n float factor = uProjFactor * scatterWorld / worldPos;\\n\\n // magic factor 10 (can be tweaked, e.g: if sss effects disappears too fast when we are far away)\\n factor = smoothstep(0.05, 0.3, factor * 10.0);\\n // return vec4(vec3(factor), 1.0);\\n\\n diffuse = mix(diffuse, TEXTURE_2D_TextureSSSBlur(gTexCoord).rgb, factor);\\n\\n return vec4(diffuse + specular, 1.0);\\n}\\n',\r\n 'packMipmapDepth.glsl':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureDepth0;\\nuniform sampler2D TextureDepth1;\\nuniform sampler2D TextureDepth2;\\nuniform sampler2D TextureDepth3;\\nuniform sampler2D TextureDepth4;\\nuniform sampler2D TextureDepth5;\\nuniform vec2 uTextureOutputRatio;\\n\\nvec4 packMipmapDepth() {\\n vec4 result = vec4(0.0, 0.0, 0.0, 0.0);\\n\\n // see _hookComposerResize in NodePostProcess.js (mipmap)\\n gTexCoord.y /= uTextureOutputRatio.y;\\n\\n float levelLog = -log2(1.0 - gTexCoord.y) + 1.0;\\n float level = floor(levelLog) - 1.0;\\n\\n float pLevel = pow(2.0, level + 1.0); // 2, 4, 8, 16...\\n gTexCoord.x = pLevel * gTexCoord.x * 0.5;\\n gTexCoord.y = pLevel * (1.0 - gTexCoord.y) - 1.0;\\n\\n // unused part of the texture\\n if (gTexCoord.x > 1.0 || gTexCoord.y > 1.0) return result;\\n\\n if (level < 0.1) result.rgba = vec4(encode24(decodeDepth(TEXTURE_2D_TextureDepth0(gTexCoord))), 1.0);\\n else if (level < 1.1) result.rgba = TEXTURE_2D_TextureDepth1(gTexCoord);\\n else if (level < 2.1) result.rgba = TEXTURE_2D_TextureDepth2(gTexCoord);\\n else if (level < 3.1) result.rgba = TEXTURE_2D_TextureDepth3(gTexCoord);\\n else if (level < 4.1) result.rgba = TEXTURE_2D_TextureDepth4(gTexCoord);\\n else if (level < 5.1) result.rgba = TEXTURE_2D_TextureDepth5(gTexCoord);\\n\\n return result;\\n}\\n',\r\n 'depthMipmap.glsl':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureDepth;\\nuniform int uFirstDepth;\\n\\nuniform vec2 uTextureDepthSize;\\nuniform vec2 uTextureOutputSize;\\n\\n// For some reasons it requires unpacking *and* repacking to avoid transition between mipmap\\nvec4 depthMipmap() {\\n vec2 invSize = 1.0 / uTextureDepthSize;\\n vec4 depths;\\n vec2 offDepth = vec2(0.25, -0.25);\\n if (uFirstDepth == 1) {\\n depths.x = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yy * invSize));\\n depths.y = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xy * invSize));\\n depths.z = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yx * invSize));\\n depths.w = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xx * invSize));\\n } else {\\n depths.x = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yy * invSize).xyz);\\n depths.y = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xy * invSize).xyz);\\n depths.z = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yx * invSize).xyz);\\n depths.w = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xx * invSize).xyz);\\n }\\n\\n return vec4(encode24(min(min(depths.x, depths.y), min(depths.z, depths.w))), 1.0);\\n}\\n',\r\n 'ssaoExtract.glsl':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\nuniform sampler2D TextureMipmapDepth;\\nuniform vec2 uTextureMipmapDepthSize;\\nuniform vec2 uTextureMipmapDepthRatio;\\n\\nuniform float uQuality; // mipmap usage\\n\\nuniform vec2 uTextureOutputSize;\\n\\nuniform float uSsaoRadius;\\nuniform float uSsaoIntensity;\\nuniform float uSsaoBias;\\nuniform vec4 uSsaoProjectionInfo;\\nuniform float uSsaoProjectionScale;\\n\\nuniform vec2 uNearFar;\\n\\nuniform float uFrameModTaaSS;\\n\\n// Constant used to scale the depth view value that is given to the blur pass\\n#define MIN_RADIUS 1.0\\n#define NB_SPIRAL_TURNS 3.0\\n\\nvec4 fetchDepthPackLevel(const in vec2 uv, const in float level){\\n float maxLod = 5.0;\\n float powLevel = pow(2.0, min(maxLod, floor(level)) + 1.0);\\n vec2 pixelSize = 2.0 * powLevel / uTextureMipmapDepthSize;\\n\\n vec2 uvFetch = max(pixelSize, min(1.0 - pixelSize, uv));\\n uvFetch = vec2(2.0 * uvFetch.x, powLevel - 1.0 - uvFetch.y) * uTextureMipmapDepthRatio.xy / powLevel;\\n\\n return texture2D(TextureMipmapDepth, uvFetch);\\n}\\n\\nfloat fetchDepthLevel(const in vec2 uv, const in float level){\\n return decode24(fetchDepthPackLevel(uv, level).xyz);\\n}\\n\\nfloat zValueFromScreenSpacePosition(const in float depth) {\\n return uNearFar.x + (uNearFar.y - uNearFar.x) * depth;\\n}\\n\\nvec3 reconstructCSPosition(const in vec2 ssP, const in float z) {\\n return vec3((ssP.xy * uSsaoProjectionInfo.xy + uSsaoProjectionInfo.zw) * z, z);\\n}\\n\\nvec3 getPosition(const in vec2 uv) {\\n return reconstructCSPosition(uv * uTextureOutputSize, zValueFromScreenSpacePosition(fetchDepthLevel(uv, 0.0)));\\n}\\n\\n#define MAX_MIP_LEVEL 5\\n// Determines at which point we should switch mip level\\n// if number is too small (~3) will lead to flashing (bad variance as many taps give same pixel)\\n// if number is too high, mip level are not used well and the cache is not used efficiently\\n#define LOG_MAX_OFFSET 3\\n\\nvec3 getOffsetedPixelPos(\\n const in vec2 uv,\\n const in vec2 unitOffset,\\n const in float screenSpaceRadius) {\\n\\n float mipLevel = clamp(floor(log2(screenSpaceRadius)) - float(LOG_MAX_OFFSET), 0.0, float(MAX_MIP_LEVEL));\\n vec2 uvOff = uv + floor(screenSpaceRadius * unitOffset) / uTextureOutputSize;\\n\\n float d = zValueFromScreenSpacePosition(fetchDepthLevel(uvOff, mipLevel));\\n return reconstructCSPosition(uvOff * uTextureOutputSize, d);\\n}\\n\\n#define PIOVER8 0.39269908169\\nvec3 unpackNormal1(const in float pack1) {\\n float pack8 = floor(pack1 * 255.0);\\n float th = PIOVER8 * float(pack8 / 16.0);\\n float len = sqrt(mod(float(pack8), 16.0) / 15.001);\\n vec2 nv = vec2(cos(th), sin(th)) * len;\\n return -vec3(nv.x, nv.y, sqrt(max(0.0, 1.0 - nv.x * nv.x - nv.y * nv.y)));\\n}\\n\\nvec3 unpackNormal2(const in vec2 pack2) {\\n vec3 nv = pack2.rgg * 2.0 - 1.0;\\n return -vec3(nv.x, nv.y, sqrt(max(0.0, 1.0 - nv.x * nv.x - nv.y * nv.y)));\\n}\\n\\n#define SSAO_TAP_EXTRACT(id) screenSpaceRadius = (float(id) + 0.5) * (1.0 / nbSamples); \\\\\\n angle = screenSpaceRadius * (NB_SPIRAL_TURNS * 6.28) + randomAngle; \\\\\\n screenSpaceRadius = max(0.75, screenSpaceRadius * ssRadius); \\\\\\n offsetUnitVec = vec2(cos(angle), sin(angle)); \\\\\\n occludingPoint = getOffsetedPixelPos(uv, offsetUnitVec, screenSpaceRadius); \\\\\\n occludingPoint -= cameraSpacePosition; \\\\\\n vv = dot(occludingPoint, occludingPoint); \\\\\\n vn = dot(occludingPoint, normal); \\\\\\n contrib += max(1.0 - vv * invRadius2, 0.0) * max((vn - uSsaoBias) * inversesqrt(vv), 0.0); \\\\\\n\\n#define SSAO_DO_TAPS(void) SSAO_TAP_EXTRACT(offset + 0); \\\\\\n SSAO_TAP_EXTRACT(offset + 1); \\\\\\n SSAO_TAP_EXTRACT(offset + 2); \\\\\\n SSAO_TAP_EXTRACT(offset + 3); \\\\\\n SSAO_TAP_EXTRACT(offset + 4); \\\\\\n SSAO_TAP_EXTRACT(offset + 5); \\\\\\n SSAO_TAP_EXTRACT(offset + 6); \\\\\\n SSAO_TAP_EXTRACT(offset + 7); \\\\\\n SSAO_TAP_EXTRACT(offset + 8); \\\\\\n SSAO_TAP_EXTRACT(offset + 9); \\\\\\n SSAO_TAP_EXTRACT(offset + 10); \\\\\\n offset += 11; \\\\\\n\\n\\nvec4 ssaoExtract() {\\n vec2 uv = gTexCoord;\\n\\n vec3 depthPacked = fetchDepthPackLevel(uv, 0.0).xyz;\\n\\n vec3 cameraSpacePosition = getPosition(uv);\\n float ssRadius = -uSsaoProjectionScale * uSsaoRadius / cameraSpacePosition.z;\\n\\n#ifdef SSAO_NORMAL\\n vec3 normal = unpackNormal2(TEXTURE_2D_TextureDepth(uv).ba); // g buffer normal 2 component on ba\\n#elif defined(GL_OES_standard_derivatives) && !defined(MOBILE)\\n vec3 normal = cross(dFdy(cameraSpacePosition), dFdx(cameraSpacePosition));\\n#else\\n vec2 offDepth = vec2(1.0, 0.0);\\n vec3 depthLeft = getPosition(uv - offDepth.xy / uTextureMipmapDepthSize);\\n vec3 depthRight = getPosition(uv + offDepth.xy / uTextureMipmapDepthSize);\\n vec3 depthBottom = getPosition(uv - offDepth.yx / uTextureMipmapDepthSize);\\n vec3 depthTop = getPosition(uv + offDepth.yx / uTextureMipmapDepthSize);\\n vec3 normal = cross(depthLeft - depthRight, depthTop - depthBottom);\\n#endif\\n\\n // early returns should be done derivatives usage to avoid bad edges\\n\\n // early return background\\n if (depthPacked.x == 1.0) {\\n return vec4(depthPacked, 1.0);\\n }\\n\\n // early return radius too small (note: needs to be in separate conditional because of nvidia/osx bug)\\n if (ssRadius < MIN_RADIUS) {\\n return vec4(depthPacked, 1.0);\\n }\\n\\n normal = normalize(normal);\\n float nFalloff = mix(1.0, max(0.0, 1.5 * normal.z), 0.35);\\n\\n // needs to be > 2PI\\n float randomAngle = 6.28 * interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS);\\n float invRadius2 = 1.0 / (uSsaoRadius * uSsaoRadius);\\n float contrib = 0.0;\\n\\n float vv;\\n float vn;\\n float screenSpaceRadius;\\n float angle;\\n vec3 occludingPoint;\\n vec2 offsetUnitVec;\\n int offset = 0;\\n\\n float nbSamples = 11.0;\\n\\n if (uQuality > 0.33) nbSamples += 11.0;\\n#ifndef MOBILE\\n if (uQuality > 0.66) nbSamples += 11.0;\\n#endif\\n\\n SSAO_DO_TAPS();\\n if (uQuality > 0.33) { SSAO_DO_TAPS(); }\\n#ifndef MOBILE\\n if (uQuality > 0.66) { SSAO_DO_TAPS(); }\\n#endif\\n\\n float aoValue = max(0.0, 1.0 - sqrt(contrib * nFalloff / nbSamples));\\n aoValue = pow(aoValue, 10.0 * uSsaoIntensity);\\n\\n vec4 aoDepth;\\n aoDepth.rgb = depthPacked;\\n aoDepth.a = mix(1.0, aoValue, clamp(ssRadius - MIN_RADIUS, 0.0, 1.0));\\n\\n return aoDepth;\\n}\\n',\r\n 'ssaoBlur.glsl':\r\n '#pragma include \"utils/encodeDecode.glsl\"\\n\\nuniform sampler2D TextureBlurInput;\\nuniform vec2 uTextureBlurInputSize;\\n\\n#define SSAO_FILTER_RADIUS 3\\n\\n#define SSAO_TAP_BLUR(id, absid) sampleTex = TEXTURE_2D_TextureBlurInput(uv + axis * float(id) * 2.0); \\\\\\n z = decode24(sampleTex.xyz); \\\\\\n weight = max(0.0, 1.0 - sharpnessFactor * abs(z - initialZ)) * (0.3 + gaussian[absid]); \\\\\\n sum += weight * sampleTex.a; \\\\\\n totalWeight += weight;\\n\\nvec4 ssaoBlur(const in vec2 axis) {\\n vec2 uv = gTexCoord;\\n\\n vec4 aoDepth = TEXTURE_2D_TextureBlurInput(uv);\\n\\n // background\\n if(aoDepth.x == 1.0){\\n return aoDepth;\\n }\\n\\n float initialZ = decode24(aoDepth.xyz);\\n\\n float gaussian[SSAO_FILTER_RADIUS + 2]; // dummy because of intel off-by-one bug\\n gaussian[0] = 0.153170;\\n gaussian[1] = 0.144893;\\n gaussian[2] = 0.122649;\\n gaussian[3] = 0.092902;\\n gaussian[4] = 0.0;\\n\\n float totalWeight = gaussian[0];\\n float sum = aoDepth.a * totalWeight;\\n float sharpnessFactor = 400.0;\\n\\n // ---- UNROLL ----\\n vec2 ofs;\\n float z;\\n float weight;\\n vec4 sampleTex;\\n\\n SSAO_TAP_BLUR(-3, 3);\\n SSAO_TAP_BLUR(-2, 2);\\n SSAO_TAP_BLUR(-1, 1);\\n SSAO_TAP_BLUR(1, 1);\\n SSAO_TAP_BLUR(2, 2);\\n SSAO_TAP_BLUR(3, 3);\\n // ---- UNROLL ----\\n\\n aoDepth.a = sum / totalWeight;\\n return aoDepth;\\n}\\n\\n#ifdef SSAO_BLUR_H\\nvec4 ssaoBlurH() {\\n return ssaoBlur(vec2(1.0, 0.0) / uTextureBlurInputSize);\\n}\\n#else\\nvec4 ssaoBlurV() {\\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\\n return vec4(color * ssaoBlur(vec2(0.0, 1.0) / uTextureBlurInputSize).aaa, 1.0);\\n}\\n#endif',\r\n 'dofCommon.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n\\nconst float MAX_BLUR = 16.0;\\nconst float EPS_EARLY_OUT = 0.01; // early out (typically when we move the camera fast and the dof might be not effective)\\n\\nfloat texDepthToCoC(const in vec4 fetch) {\\n // background should be always max blurred so that the near blur can expand onto the background (because of special dilate background codepath below)\\n if(fetch.x == 1.0) return max(uDofBlurNearFarFocal.x, uDofBlurNearFarFocal.y);\\n\\n float coc = decodeDepth(fetch);\\n coc = clamp((coc - uDofBlurNearFarFocal.z) / coc, -1.0, 1.0);\\n return (coc < 0.0 ? coc * uDofBlurNearFarFocal.x : coc * uDofBlurNearFarFocal.y);\\n}',\r\n 'dofCoC.glsl':\r\n 'uniform vec3 uDofBlurNearFarFocal;\\n\\n#pragma include \"dofCommon.glsl\"\\n\\nuniform sampler2D TextureDepth;\\n\\nvec4 dofCoC() {\\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\\n return vec4(0.0);\\n }\\n\\n return vec4(vec3(0.0), texDepthToCoC(TEXTURE_2D_TextureDepth(gTexCoord)) * 0.5 + 0.5);\\n}',\r\n 'dofNearDilate.glsl':\r\n 'uniform vec3 uDofBlurNearFarFocal;\\n\\n#pragma include \"dofCommon.glsl\"\\n\\nuniform sampler2D TextureDofCoC;\\nuniform vec2 uTextureDofCoCSize;\\nuniform sampler2D TextureDepth;\\n\\nuniform float uDofScale;\\n\\nvec4 dilateNear(const in vec2 offset) {\\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\\n return vec4(0.0);\\n }\\n\\n // TODO DOF both the weights and the formula can be tweaked, also we could add a bit of jitter or something\\n vec2 uv = gTexCoord;\\n bool isBG = TEXTURE_2D_TextureDepth(uv).x == 1.0;\\n\\n float coc = 0.0;\\n vec2 ofs = MAX_BLUR * offset / 5.0;\\n\\n float coc0 = TEXTURE_2D_TextureDofCoC(uv).a * 2.0 - 1.0;\\n float coc1 = TEXTURE_2D_TextureDofCoC(uv - 5.0 * ofs).a * 2.0 - 1.0;\\n float coc2 = TEXTURE_2D_TextureDofCoC(uv - 4.0 * ofs).a * 2.0 - 1.0;\\n float coc3 = TEXTURE_2D_TextureDofCoC(uv - 3.0 * ofs).a * 2.0 - 1.0;\\n float coc4 = TEXTURE_2D_TextureDofCoC(uv - 2.0 * ofs).a * 2.0 - 1.0;\\n float coc5 = TEXTURE_2D_TextureDofCoC(uv - 1.0 * ofs).a * 2.0 - 1.0;\\n float coc6 = TEXTURE_2D_TextureDofCoC(uv + 1.0 * ofs).a * 2.0 - 1.0;\\n float coc7 = TEXTURE_2D_TextureDofCoC(uv + 2.0 * ofs).a * 2.0 - 1.0;\\n float coc8 = TEXTURE_2D_TextureDofCoC(uv + 3.0 * ofs).a * 2.0 - 1.0;\\n float coc9 = TEXTURE_2D_TextureDofCoC(uv + 4.0 * ofs).a * 2.0 - 1.0;\\n float coc10 = TEXTURE_2D_TextureDofCoC(uv + 5.0 * ofs).a * 2.0 - 1.0;\\n\\n if(isBG == true){\\n // avoid \"shrink\" effect on the out of focus far part on the model edges\\n // gaussian weights (sigma 10), (doesn\\'t have to be gaussian though), but the sum must be 1.0\\n // http://dev.theomader.com/gaussian-kernel-calculator/\\n coc = abs(coc0) * 0.095474 +\\n (abs(coc1) + abs(coc10)) * 0.084264 +\\n (abs(coc2) + abs(coc9)) * 0.088139 +\\n (abs(coc3) + abs(coc8)) * 0.091276 +\\n (abs(coc4) + abs(coc7)) * 0.093585 +\\n (abs(coc5) + abs(coc6)) * 0.094998;\\n } else {\\n // blur only near field (expand)\\n coc = min(coc0, 0.0);\\n coc = min(coc1 * 0.3, coc);\\n coc = min(coc2 * 0.5, coc);\\n coc = min(coc3 * 0.75, coc);\\n coc = min(coc4 * 0.8, coc);\\n coc = min(coc5 * 0.95, coc);\\n coc = min(coc6 * 0.95, coc);\\n coc = min(coc7 * 0.8, coc);\\n coc = min(coc8 * 0.75, coc);\\n coc = min(coc9 * 0.5, coc);\\n coc = min(coc10 * 0.3, coc);\\n if(abs(coc0) > abs(coc)) coc = coc0;\\n }\\n\\n return vec4(0.0, 0.0, 0.0, coc * 0.5 + 0.5);\\n}\\n\\nvec4 dofNearDilateH() {\\n vec2 offset = vec2(uDofScale / uTextureDofCoCSize.x, 0.0);\\n return dilateNear(offset);\\n}\\n\\nvec4 dofNearDilateV() {\\n vec2 offset = vec2(0.0, uDofScale / uTextureDofCoCSize.y);\\n return dilateNear(offset);\\n}',\r\n 'dofDownsampleColor.glsl':\r\n 'uniform sampler2D TextureInput;\\n\\n#ifdef COLOR_WITH_COC\\nuniform sampler2D TextureDofCoC;\\n#endif\\n\\nvec4 dofDownsampleColor() {\\n vec2 uv = gTexCoord;\\n\\n vec4 color = TEXTURE_2D_NEAREST_TextureInput(uv);\\n\\n// premult with coc buffer\\n#ifdef COLOR_WITH_COC\\n color.a = abs(TEXTURE_2D_TextureDofCoC(uv).a * 2.0 - 1.0);\\n color.a *= color.a * color.a;\\n color.rgb *= color.a;\\n#endif\\n\\n return color;\\n}',\r\n 'dofBlurCircular.glsl':\r\n '#pragma include \"utils/rand.glsl\"\\n\\nuniform vec3 uDofBlurNearFarFocal;\\n#pragma include \"dofCommon.glsl\"\\n\\nuniform sampler2D TextureDofColor;\\nuniform vec2 uTextureDofColorSize;\\n\\n#ifndef COLOR_WITH_COC\\nuniform sampler2D TextureDofCoC;\\nuniform vec2 uTextureDofCoCSize;\\n#endif\\n\\nuniform float uDofScale;\\nuniform float uQuality;\\n\\nuniform float uFrameModTaaSS;\\n\\n#ifdef COLOR_WITH_COC\\n#define DOF_TAP(id) ofs = fTaps_Poisson[id]; \\\\\\n ofs = gTexCoord + blurDist * vec2(dot(ofs, basis.xy), dot(ofs, basis.zw) ); \\\\\\n sumcol += TEXTURE_2D_TextureDofColor(ofs);\\n#else\\n#define DOF_TAP(id) ofs = fTaps_Poisson[id]; \\\\\\n ofs = gTexCoord + blurDist * vec2(dot(ofs, basis.xy), dot(ofs, basis.zw) ); \\\\\\n cocWeight = abs(TEXTURE_2D_TextureDofCoC(ofs).a * 2.0 - 1.0); \\\\\\n cocWeight *= cocWeight * cocWeight; \\\\\\n sumcol.rgb += TEXTURE_2D_TextureDofColor(ofs).rgb * cocWeight; \\\\\\n sumcol.a += cocWeight;\\n#endif\\n\\nvec4 dofBlur16(const in vec2 blurDist, const in float ntime) {\\n float rnd = 6.28 * ditheringNoise(gl_FragCoord.xy, uFrameModTaaSS + ntime);\\n\\n float cosa = cos(rnd);\\n float sina = sin(rnd);\\n vec4 basis = vec4(cosa, -sina, sina, cosa);\\n\\n vec4 sumcol = vec4(0.0);\\n\\n float total = 0.0;\\n\\n vec2 fTaps_Poisson[17];\\n // https://github.com/bartwronski/PoissonSamplingGenerator\\n fTaps_Poisson[0] = vec2(0.343280198355, 0.921191856785);\\n fTaps_Poisson[1] = vec2(-0.116859107262, 0.873056831344);\\n fTaps_Poisson[2] = vec2(-0.646421287853, 0.760425284853);\\n fTaps_Poisson[3] = vec2(-0.0437332058416, 0.47196719804);\\n fTaps_Poisson[4] = vec2(0.48240473891, 0.464894594736);\\n fTaps_Poisson[5] = vec2(-0.718897237297, 0.352191304304);\\n fTaps_Poisson[6] = vec2(-0.939061387886, -0.0387376698953);\\n fTaps_Poisson[7] = vec2(0.546569494557, -0.0169516524446);\\n fTaps_Poisson[8] = vec2(-0.182644095652, -0.0702667761349);\\n fTaps_Poisson[9] = vec2(-0.576191305396, -0.252368997099);\\n fTaps_Poisson[10] = vec2(0.921914032366, -0.366530187909);\\n fTaps_Poisson[11] = vec2(-0.0582053944545, -0.510617206206);\\n fTaps_Poisson[12] = vec2(-0.783101528934, -0.601411360136);\\n fTaps_Poisson[13] = vec2(0.430604354377, -0.729559481383);\\n fTaps_Poisson[14] = vec2(-0.350716524868, -0.809522919973);\\n fTaps_Poisson[15] = vec2(0.0600898835968, -0.952568587297);\\n fTaps_Poisson[16] = vec2(0.0, 0.0); // dummy because of intel off-by-one bug\\n\\n vec2 ofs;\\n vec4 sampleTex;\\n float cocWeight;\\n\\n DOF_TAP(0);\\n DOF_TAP(1);\\n DOF_TAP(2);\\n DOF_TAP(3);\\n DOF_TAP(4);\\n DOF_TAP(5);\\n DOF_TAP(6);\\n DOF_TAP(7);\\n DOF_TAP(8);\\n DOF_TAP(9);\\n DOF_TAP(10);\\n DOF_TAP(11);\\n DOF_TAP(12);\\n DOF_TAP(13);\\n DOF_TAP(14);\\n DOF_TAP(15);\\n\\n return sumcol;\\n}\\n\\nvec4 dofBlurCircular() {\\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT) {\\n return vec4(0.0);\\n }\\n\\n float factor = MAX_BLUR * uDofScale;\\n\\n#ifdef COLOR_WITH_COC\\n vec2 blurDist = factor * pow(TEXTURE_2D_TextureDofColor(gTexCoord).a, 0.333) / uTextureDofColorSize;\\n#else\\n vec2 blurDist = factor * abs(TEXTURE_2D_TextureDofCoC(gTexCoord).a * 2.0 - 1.0) / uTextureDofCoCSize;\\n#endif\\n\\n // TODO optimize dofBlur16 (unroll...)\\n vec4 sumcol = dofBlur16(blurDist, 0.0); // 16\\n if (uQuality > 0.33) sumcol += dofBlur16(blurDist, 3.0); // 32\\n if (uQuality > 0.66) sumcol += dofBlur16(blurDist, 5.0); // 48\\n\\n return vec4(sumcol.rgb / sumcol.a, 1.0);\\n}\\n',\r\n 'dofCombine.glsl':\r\n 'uniform vec3 uDofBlurNearFarFocal;\\n\\n#pragma include \"dofCommon.glsl\"\\n\\nuniform sampler2D TextureInput;\\nuniform sampler2D TextureDofBlurCircular;\\nuniform sampler2D TextureDofNearDilateV;\\nuniform sampler2D TextureDepth;\\n\\nuniform vec2 uTextureDofNearDilateVSize;\\nuniform vec2 uTextureDofBlurCircularSize;\\n\\nuniform float uDofScale;\\n\\nvec4 dofCombine() {\\n vec2 uv = gTexCoord;\\n vec3 color = TEXTURE_2D_TextureInput(uv).rgb;\\n\\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\\n return vec4(color, 1.0);\\n }\\n\\n vec4 depthPacked = TEXTURE_2D_TextureDepth(uv);\\n\\n // half res color\\n vec3 blur;\\n // no bilinear for background pixels because it can displays artefacts on low frequency due to rgbm bilinear fetching\\n if (depthPacked.x == 1.0) {\\n blur = TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv).rgb;\\n vec2 off = vec2(1.0, -1.0) * uDofScale;\\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.xx / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.yy / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.xy / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.yx / uTextureDofBlurCircularSize).rgb;\\n blur /= 5.0;\\n } else {\\n blur = TEXTURE_2D_TextureDofBlurCircular(uv).rgb;\\n vec2 off = vec2(1.0, -1.0) * uDofScale;\\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.xx / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.yy / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.xy / uTextureDofBlurCircularSize).rgb;\\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.yx / uTextureDofBlurCircularSize).rgb;\\n blur /= 5.0;\\n }\\n\\n // merge full res and half res coc\\n vec2 uvNearest = (floor(uv * uTextureDofNearDilateVSize) + 0.5) / uTextureDofNearDilateVSize;\\n float coc = abs(min(TEXTURE_2D_TextureDofNearDilateV(uvNearest).a * 2.0 - 1.0, texDepthToCoC(depthPacked)));\\n\\n // merge half res blurred color and full res pixels\\n float cocLower = 0.05;\\n float cocHigher = 0.3;\\n\\n return vec4(mix(color, blur, smoothstep(cocLower, cocHigher, coc)), 1.0);\\n}\\n\\n',\r\n 'bloomExtract.glsl':\r\n '#pragma include \"utils/getLuminance.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureInput;\\n\\n#ifdef HAS_BACKGROUND\\nuniform sampler2D TextureDepth;\\n#endif\\n\\nuniform float uBloomThreshold;\\n\\nvec3 extractBright(const in vec3 color) {\\n // TODO manage hdr pixel with high frequency? (use derivative??), for now we clamp the extracted pixel :(\\n return clamp(color * clamp(getLuminance(color) - uBloomThreshold, 0.0, 1.0), 0.0, 1.0);\\n}\\n\\nvec4 bloomExtract() {\\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\\n\\n#ifdef HAS_BACKGROUND\\n\\tfloat alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\n\\tif(alpha == 0.0) {\\n\\t\\treturn vec4(vec3(0.0), 1.0);\\n }\\n#else\\n\\tfloat alpha = 1.0;\\n#endif\\n\\n\\treturn vec4(extractBright(color * alpha), 1.0);\\n}',\r\n 'bloomCombine.glsl':\r\n 'uniform sampler2D TextureInput;\\nuniform sampler2D TextureBloomBlur1;\\nuniform sampler2D TextureBloomBlur2;\\nuniform sampler2D TextureBloomBlur3;\\nuniform sampler2D TextureBloomBlur4;\\nuniform sampler2D TextureBloomBlur5;\\n\\nuniform float uBloomRadius;\\nuniform float uBloomFactor;\\n\\nfloat getRadiusFactored(const float value, const float middle) {\\n return mix(value, middle * 2.0 - value, uBloomRadius);\\n}\\n\\nvec4 bloomCombine() {\\n vec3 bloom = vec3(0.0);\\n\\n const float midVal = 0.6;\\n\\n const float factor1 = 1.1;\\n const float factor2 = 0.9;\\n const float factor3 = 0.6;\\n const float factor4 = 0.3;\\n const float factor5 = 0.1;\\n\\n bloom += TEXTURE_2D_TextureBloomBlur1(gTexCoord).rgb * getRadiusFactored(factor1, midVal);\\n bloom += TEXTURE_2D_TextureBloomBlur2(gTexCoord).rgb * getRadiusFactored(factor2, midVal);\\n bloom += TEXTURE_2D_TextureBloomBlur3(gTexCoord).rgb * getRadiusFactored(factor3, midVal);\\n bloom += TEXTURE_2D_TextureBloomBlur4(gTexCoord).rgb * getRadiusFactored(factor4, midVal);\\n bloom += TEXTURE_2D_TextureBloomBlur5(gTexCoord).rgb * getRadiusFactored(factor5, midVal);\\n\\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\\n return vec4(color + (bloom * uBloomFactor), 1.0);\\n}',\r\n 'chromaticAberration.glsl':\r\n 'uniform sampler2D TextureInput;\\n\\nuniform float uChromaFactor;\\n\\nvec4 chromaticAberration() {\\n vec2 uv = gTexCoord;\\n\\n vec2 dist = uv - 0.5;\\n vec2 offset = uChromaFactor * dist * length(dist);\\n vec3 col;\\n col.r = TEXTURE_2D_TextureInput(uv - offset).r;\\n col.g = TEXTURE_2D_TextureInput(uv).g;\\n col.b = TEXTURE_2D_TextureInput(uv + offset).b;\\n\\n return vec4(col, 1.0);\\n}',\r\n 'vignette.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\nuniform vec2 uLensRadius;\\nuniform float uFrameMod;\\n\\nfloat vignetteDithered() {\\n vec2 lens = uLensRadius;\\n // smoothesp is not realiable with edge0 == edge1\\n lens.y = min(lens.y, lens.x - 1e-4);\\n\\n float jitter = interleavedGradientNoise(gl_FragCoord.xy, uFrameMod);\\n\\n // jitter a bit the uv to remove the banding in some cases\\n // (lens.x - lens.y) reduce flickering when the vignette is harder (hardness)\\n // (lens.x + lens.y) reduce the flickering when the vignette has a strong radius\\n jitter = (lens.x - lens.y) * (lens.x + lens.y) * 0.07 * (jitter - 0.5);\\n return smoothstep(lens.x, lens.y, jitter + distance(gTexCoord, vec2(0.5)));\\n}\\n\\nvec4 vignette(const in vec4 color) {\\n float factor = vignetteDithered();\\n return vec4(linearTosRGB(sRGBToLinear(color.rgb) * factor), clamp(color.a + (1.0 - factor), 0.0, 1.0));\\n}',\r\n 'toneMapping.glsl':\r\n '#pragma include \"utils/getLuminance.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform float uToneExposure;\\nuniform float uToneBrightness;\\nuniform float uToneContrast;\\nuniform float uToneSaturation;\\nuniform int uToneMethod;\\n\\n#ifdef HAS_FIXED_BACKGROUND\\nuniform sampler2D TextureDepth;\\n#endif\\n\\nvec3 toneMapping(const in vec3 color) {\\n if (gTransparentAlpha > 0.999) return color; \\n vec3 col = color * uToneExposure;\\n float luminance = dot(col * (1.0 + uToneBrightness), vec3(0.2126, 0.7152, 0.0722));\\n col = mix(vec3(luminance), col * (1.0 + uToneBrightness), vec3(uToneSaturation));\\n\\n // contrast is annoying and require special treatment in case of fixed background\\n // because it doesn\\'t output black when the input is black\\n float toneContrast = uToneContrast;\\n#ifdef HAS_FIXED_BACKGROUND\\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\n if(alpha == 0.0) toneContrast *= luminance;\\n#endif\\n col = max(vec3(0.0), col * (1.0 + toneContrast) - 0.5 * toneContrast);\\n\\n // simple reinhard and filmic\\n // http://filmicgames.com/archives/190\\n if(uToneMethod == 1) { // reinhard (on luminance)\\n col /= 1.0 + getLuminance(col);\\n } else if( uToneMethod == 2) { // filmic\\n vec3 x = max(vec3(0.0), col - 0.004);\\n col = (x * (6.2 * x + 0.5) ) / ( x * (6.2 * x + 1.7) + 0.06);\\n col = pow(col, vec3(2.2)); // filmic curve already encode srgb to linear\\n }\\n\\n return col;\\n}\\n\\nvec4 toneMapping(const in vec4 color) {\\n return vec4(toneMapping(color.rgb), 1.0);\\n}\\n',\r\n 'colorBalance.glsl':\r\n \"uniform vec3 uColorBalanceLow;\\nuniform vec3 uColorBalanceMid;\\nuniform vec3 uColorBalanceHigh;\\n\\nfloat RGBToL(const in vec3 color) {\\n float fmin = min(min(color.r, color.g), color.b);\\n float fmax = max(max(color.r, color.g), color.b);\\n return (fmax + fmin) / 2.0;\\n}\\n\\nvec3 colorBalance(const in vec3 color) {\\n vec3 lrgb = uColorBalanceLow;\\n vec3 mrgb = uColorBalanceMid;\\n vec3 hrgb = uColorBalanceHigh;\\n\\n float cLen = length(color);\\n if(cLen < 1e-5)\\n return color;\\n\\n // TODO : I have no idea what I am doing, we should use a curve widge\\n float lightness = RGBToL(color);\\n // ' lightness=(lightness*0.9-1.0)/(lightness*2.0+1.0) +1.0;\\n lightness = (1.5 * lightness) / (lightness + 0.5);\\n // https://github.com/liovch/GPUImage/blob/master/framework/Source/GPUImageColorBalanceFilter\\n float a = 0.25;\\n float b = 0.333;\\n float scale = 0.7;\\n vec3 low = lrgb * clamp((lightness - b) / -a + 0.5, 0.0, 1.0);\\n vec3 mid = mrgb * clamp((lightness - b) / a + 0.5, 0.0, 1.0) * clamp((lightness + b - 1.0) / -a + 0.5, 0.0, 1.0);\\n vec3 high = hrgb * clamp((lightness + b - 1.0) / a + 0.5, 0.0, 1.0);\\n vec3 newColor = max(color + (low + mid + high) * scale, vec3(0.0));\\n // newColor can be negative\\n float len = length(newColor);\\n return len < 1e-5 ? newColor * cLen : newColor * cLen / len;\\n}\\n\\nvec4 colorBalance(const in vec4 color) {\\n return vec4(colorBalance(color.rgb), 1.0);\\n}\",\r\n 'supersample.glsl':\r\n 'uniform vec4 uHalton;\\n\\nuniform float uSSAARestart;\\nuniform sampler2D TexturePrevious;\\nuniform vec2 uTexturePreviousSize;\\n\\n// static in place amortized supersampling\\nvec4 supersample() {\\n vec4 currFragColor = TEXTURE_2D_TextureInput(gTexCoord).rgba;\\n\\n float haltz = abs(uHalton.z);\\n if (haltz == 1.0) {\\n // just return the color.\\n return currFragColor;\\n }\\n\\n // same pixel for same projected interpolated vertex on prev frame\\n vec4 accumColorN = TEXTURE_2D_NEAREST_TexturePrevious(gTexCoord).rgba;\\n\\n // mix frames\\n float lerpFac = 1.0 / uHalton.w;\\n\\n // if uTaaSSSRestart is 0.0, then we used the previous TAAed image to start supersampling\\n // we do that to avoid a sudden re-aliasing of the image (which is perceptible)\\n if (uHalton.w == 1.0) lerpFac = uSSAARestart;\\n\\n if (haltz == 3.0) {\\n // No supersample, crude motion blur by accumulation\\n return mix(currFragColor, accumColorN, lerpFac);\\n }\\n\\n // Supsersample, accumulation + jittering\\n // http://en.wikipedia.org/wiki/Moving_average#Cumulative_moving_average\\n // cumulative moving average over frameNum (which starts at 2)\\n // n is previous frame\\n // accumColorN = Accum(n)\\n // return value is accumColor( n +1 )\\n // Accum(n+1) = Accum(n) + ((x(n+1) - Accum(n)) / (n + 1)))\\n // formula above is equal to glsl mix\\n return mix(accumColorN, currFragColor, lerpFac);\\n}\\n',\r\n 'supersampleTaa.glsl':\r\n '#pragma include \"utils/getLuminance.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n#pragma include \"supersample.glsl\"\\n\\nuniform sampler2D TextureInput;\\nuniform vec2 uTextureInputSize;\\nuniform sampler2D TexturePrevious;\\nuniform vec2 uTexturePreviousSize;\\nuniform sampler2D TextureDepth;\\n\\nuniform vec4 uHalton;\\nuniform vec2 uNearFar;\\n\\nuniform float uTaaEnabled;\\nuniform mat4 uTaaInvViewMatrixLeft;\\nuniform mat4 uTaaCurrentFramePVLeft;\\nuniform mat4 uTaaLastFramePVLeft;\\nuniform vec4 uTaaCornersCSLeft[2];\\n\\n#ifdef VR_ENABLED\\nuniform mat4 uTaaInvViewMatrixRight;\\nuniform mat4 uTaaCurrentFramePVRight;\\nuniform mat4 uTaaLastFramePVRight;\\nuniform vec4 uTaaCornersCSRight[2];\\n#endif\\n\\nvec3 reconstructWSPosition(const in vec2 uv, const in vec4 corners0, const in vec4 corners1, const in mat4 invView, const in float depth) {\\n vec2 finalUv = uv;\\n#ifdef VR_ENABLED\\n float xViewportOffset = uv.x >= 0.5 ? -0.5 : 0.0;\\n finalUv.x = ( uv.x + xViewportOffset ) * 2.0;\\n#endif\\n\\n // the corners are in view space, it means if we interpolate between them we can retrieve the view space direction of the fragment\\n vec4 AB = mix(corners0, corners1, vec4(finalUv.x));\\n\\n // multiply this view space direction by the depth gives us the view space position\\n vec3 vsPos = vec3(mix(AB.xy, AB.zw, vec2(finalUv.y)), 1.0) * depth;\\n\\n // multiply by the inverse of the view matrix gives us the world space position\\n return (invView * vec4(vsPos, 1.0)).xyz;\\n}\\n\\n#define NEIGHBOUR_SET_IF_DMIN_Z_GREATER(d, x, y) if(d < dmin.z) dmin = vec3(x, y, d);\\n#define NEIGHBOUR_CREATE_FROM_OFFSET(d, x, y) d = decodeDepth(TEXTURE_2D_TextureDepth(uv + vec2(x,y)));\\n#define FIND_NEIGHBOUR_MIN(d, x, y) NEIGHBOUR_CREATE_FROM_OFFSET(d, x, y); NEIGHBOUR_SET_IF_DMIN_Z_GREATER(d, x, y)\\n\\n\\n// Neighborhood clamping from Tiago Sousa\\n// 4tap(decent) comment t, ml, mr, b\\n// https://github.com/playdeadgames/temporal/blob/9e6a7704e69bb73f29fe393390e545b21ddfd42d/Assets/Shaders/IncDepth.cginc#L111\\n// 9Tap(good) slower but nicer\\n// https://github.com/playdeadgames/temporal/blob/9e6a7704e69bb73f29fe393390e545b21ddfd42d/Assets/Shaders/IncDepth.cginc#L37\\n//#define CLOSEST_9TAP\\nvec3 closestFragment(const in vec2 uv, const in vec2 texelSize) {\\n\\n float d;\\n vec2 size = 2.0 * texelSize;\\n vec3 dmin = vec3(0.0, 0.0, 0.0);\\n\\n // 5Tap\\n NEIGHBOUR_CREATE_FROM_OFFSET(dmin.z, 0.0, 0.0);\\n FIND_NEIGHBOUR_MIN(d, -size.x, size.y);\\n FIND_NEIGHBOUR_MIN(d, size.x, size.y);\\n FIND_NEIGHBOUR_MIN(d, -size.x, -size.y);\\n FIND_NEIGHBOUR_MIN(d, size.x, -size.y);\\n\\n#ifdef CLOSEST_9TAP\\n FIND_NEIGHBOUR_MIN(d, 0.0, size.y);\\n FIND_NEIGHBOUR_MIN(d, -size.x, 0.0);\\n FIND_NEIGHBOUR_MIN(d, size.x, 0.0);\\n FIND_NEIGHBOUR_MIN(d, 0.0, -size.y);\\n#endif\\n\\n return vec3(uv + dmin.xy, dmin.z);\\n}\\n\\n// note: only clips towards aabb center (but fast!)\\n// same as https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc#L199\\n// which is adapted from https://github.com/playdeadgames/temporal\\n// using the mathematical similar version of https://twitter.com/Stubbesaurus/status/890154773726580736\\n// exhibits numerical issue (in a consistent way on intel/nvidia at least)\\nvec4 clip_aabb_opti(const in vec4 minimum, const in vec4 maximum, const in vec4 color) {\\n const float eps = 0.00000001;\\n\\n vec4 center = 0.5 * (maximum + minimum);\\n vec4 extents = 0.5 * (maximum - minimum) + eps;\\n vec4 offset = color - center;\\n\\n vec4 ts = abs(offset / extents);\\n float t = max(max(ts.r, ts.g), max(ts.b, ts.a));\\n return center + offset / max(1.0, t);\\n // return t > 1.0 : center + offset / t : color;\\n}\\n\\nvec4 taa(const in vec2 ssVel, const in vec2 texelSize) {\\n vec2 uv = gTexCoord;\\n\\n vec4 tl = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, texelSize.y));\\n vec4 t = TEXTURE_2D_TextureInput(uv + vec2(0.0, texelSize.y));\\n vec4 tr = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, texelSize.y));\\n\\n vec4 ml = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, 0.0));\\n vec4 m = TEXTURE_2D_TextureInput(uv);\\n vec4 mr = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, 0.0));\\n\\n vec4 bl = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, -texelSize.y));\\n vec4 b = TEXTURE_2D_TextureInput(uv + vec2(0.0, -texelSize.y));\\n vec4 br = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, -texelSize.y));\\n\\n // sharpen\\n // https://github.com/Unity-Technologies/PostProcessing/blob/v1/PostProcessing/Resources/Shaders/TAA.cginc#L143\\n // reduces blurring, but increases flickering with dense geometry\\n vec4 corners = 2.0 * (tr + bl + br + tl) - 2.0 * m;\\n m += (m - (corners * 0.166667)) * 2.718282 * 0.3;\\n m = max(vec4(0.0), m);\\n\\n // Brian Karis neighbourhood rounding: http://advances.realtimerendering.com/s2014/epic/TemporalAA.pptx\\n // average of rounded pattern with cross pattern\\n vec4 cmin5 = min(mr, min(m, min(ml, min(t, b))));\\n vec4 cmin = min(cmin5, min(tl, min(tr, min(bl, br))));\\n\\n vec4 cmax5 = max(mr, max(m, max(ml, max(t, b))));\\n vec4 cmax = max(cmax5, max(tl, max(tr, max(bl, br))));\\n\\n cmin = 0.5 * (cmin + cmin5);\\n cmax = 0.5 * (cmax + cmax5);\\n\\n vec4 previousColor = TEXTURE_2D_TexturePrevious(uv - ssVel);\\n previousColor = clip_aabb_opti(cmin, cmax, previousColor);\\n\\n float lum0 = getLuminance(m.rgb);\\n float lum1 = getLuminance(previousColor.rgb);\\n float diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));\\n float unbiased_weight = 1.0 - diff;\\n float feedback = mix(FEEDBACK_MIN, FEEDBACK_MAX, unbiased_weight * unbiased_weight);\\n\\n return mix(m, previousColor, feedback);\\n}\\n\\nvec2 computeSSVelocity(const in vec3 wsPos, const in mat4 currentFrameProjView, const in mat4 lastFrameProjView, const in bool rightEye)\\n{\\n vec4 ssCurrentPos = currentFrameProjView * vec4(wsPos, 1.0);\\n vec4 ssPrevPos = lastFrameProjView * vec4(wsPos, 1.0);\\n\\n vec2 ndcCurrent = ssCurrentPos.xy / ssCurrentPos.w;\\n vec2 ndcPrev = ssPrevPos.xy / ssPrevPos.w;\\n\\n //ndcPrev = clamp(ndcPrev, vec2(-1.0), vec2(1.0));\\n if(ndcPrev.x >= 1.0 || ndcPrev.x <= -1.0 || ndcPrev.x >= 1.0 || ndcPrev.y <= -1.0)\\n return vec2(0.0);\\n\\n#ifdef VR_ENABLED\\n ndcCurrent.x /= 2.0;\\n ndcPrev.x /= 2.0;\\n\\n if (rightEye) {\\n ndcCurrent.x += 0.5;\\n ndcPrev.x += 0.5;\\n }\\n#endif\\n\\n return 0.5 * (ndcCurrent - ndcPrev);\\n}\\n\\n\\nvec4 computeTaa(const in mat4 invView, const in mat4 currentFrameProjView, const in mat4 lastFrameProjView, const in vec4 corners0, const in vec4 corners1) {\\n vec2 uv = gTexCoord;\\n float haltz = abs(uHalton.z);\\n if (haltz == 1.0) {\\n vec2 texelSize = vec2(1.0) / uTextureInputSize;\\n vec3 closest = closestFragment(uv, texelSize);\\n\\n // discard background fragments to save fillrate\\n // make sure the mesh isn\\'t transparent\\n if (closest.z >= 1.0\\n#ifdef TAA_TRANSPARENT\\n && decodeAlpha(TEXTURE_2D_TextureDepth(closest.xy)) == 0.0\\n#endif\\n ) {\\n // unjitter for fixed background with highres pattern or text\\n return TEXTURE_2D_TextureInput(uv - 0.5 * uHalton.xy * texelSize);\\n }\\n\\n float depth = -(uNearFar.x + (uNearFar.y - uNearFar.x) * closest.z);\\n vec3 ws = reconstructWSPosition(closest.xy, corners0, corners1, invView, depth);\\n\\n vec2 ssVel = computeSSVelocity(ws, currentFrameProjView, lastFrameProjView, uv.x >= 0.5);\\n return taa(ssVel, texelSize);\\n }\\n\\n return supersample();\\n}\\n\\n// temporal anti-aliasing from Playdead\\'s Inside\\n// slides: http://www.gdcvault.com/play/1022970/Temporal-Reprojection-Anti-Aliasing-in\\n// sources: https://github.com/playdeadgames/temporal\\nvec4 supersampleTaa() {\\n if (uTaaEnabled == 0.0) {\\n return supersample();\\n }\\n\\n#ifdef VR_ENABLED\\n // left and right eyes have different matrices\\n if (gTexCoord.x >= 0.5) {\\n return computeTaa(uTaaInvViewMatrixRight, uTaaCurrentFramePVRight, uTaaLastFramePVRight, uTaaCornersCSRight[0], uTaaCornersCSRight[1]);\\n }\\n#endif\\n\\n return computeTaa(uTaaInvViewMatrixLeft, uTaaCurrentFramePVLeft, uTaaLastFramePVLeft, uTaaCornersCSLeft[0], uTaaCornersCSLeft[1]);\\n}',\r\n 'composeExtra.glsl':\r\n 'uniform sampler2D TextureExtra;\\r\\n\\r\\n// LINEAR should be deduce from TEXTURE_2D_TextureExtra with user data\\r\\nvec4 composeExtra(const in vec4 color) {\\r\\n#ifdef LINEAR_EXTRA\\r\\n\\tvec4 extra = sRGBToLinear(TEXTURE_2D_TextureExtra(gTexCoord));\\r\\n#else\\r\\n\\tvec4 extra = TEXTURE_2D_TextureExtra(gTexCoord);\\r\\n#endif\\r\\n\\treturn extra + vec4(color) * (1.0 - extra.a);\\r\\n}',\r\n 'composeFixedBackground.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\r\\n\\r\\nuniform sampler2D TextureFixed;\\r\\nuniform vec2 uFixedScale;\\r\\n\\r\\nuniform sampler2D TextureDepth;\\r\\nuniform vec2 uTextureOutputSize;\\r\\n\\r\\nuniform vec4 uHalton;\\r\\nuniform float uSplitView;\\r\\n\\r\\nvec4 composeBackground(const in vec3 color, const in float alpha) {\\r\\n vec2 jitter = uHalton.xy * 0.5 / uTextureOutputSize;\\r\\n vec2 uv = (gTexCoord - 0.5 + jitter) * uFixedScale + 0.5;\\r\\n\\r\\n // we recenter and unstretch the background\\r\\n if (uSplitView == 1.0) uv.x = uv.x * 0.5 + 0.25;\\r\\n\\r\\n // composer can\\'t guess based on user data, so SRGBToLinear should be defined (or not) by TEXTURE_2D_XXXXXXX\\r\\n vec3 backgroundColor = sRGBToLinear(texture2D(TextureFixed, uv).rgb);\\r\\n return vec4(color.rgb + backgroundColor * (1.0 - alpha), 1.0);\\r\\n}\\r\\n\\r\\nuniform sampler2D TextureInput;\\r\\nuniform vec2 uTextureInputSize;\\r\\nuniform vec2 uTextureInputRatio;\\r\\n\\r\\nuniform sampler2D TextureRefraction;\\r\\nuniform vec2 uTextureRefractionSize;\\r\\nuniform vec2 uTextureRefractionRatio;\\r\\nuniform float uRGBMRange;\\r\\n\\r\\nvec4 composeFixedBackground(const in vec4 color) {\\r\\n#ifdef REFRACTION_COMPOSITING_EXCLUSION\\r\\n // detect if we are on a refraction pixel\\r\\n vec2 uvRef = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\\r\\n if (texture2D(TextureRefraction, uvRef * uTextureRefractionRatio).a > 0.0) return color;\\r\\n#endif\\r\\n\\r\\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\r\\n return composeBackground(color.rgb, alpha);\\r\\n}\\r\\n\\r\\nvec4 composeFixedBackgroundRefraction() {\\r\\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\\r\\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\r\\n return composeBackground(color.rgb, alpha);\\r\\n}',\r\n 'fxaa.glsl':\r\n '#ifdef VR_DISTORTION\\nuniform vec2 uDistortion;\\nuniform vec4 uProjectionLeft;\\nuniform vec4 uUnprojectionLeft;\\n\\n#pragma include \"distortion.glsl\"\\n#endif\\n\\n#ifdef ASCII_FOOL\\n#pragma include \"ascii.glsl\"\\n#endif\\n\\nuniform sampler2D TextureInput;\\nuniform vec2 uTextureInputSize;\\n\\n// G3D version of FXAA\\n// green (y) as luma\\n// Quality 12\\nvec4 fxaa() {\\n#ifdef VR_DISTORTION\\n gTexCoord = distortion(gTexCoord);\\n#endif\\n\\n vec2 fxaaQualityRcpFrame = 1.0 / uTextureInputSize;\\n float fxaaQualitySubpix = 0.75;\\n float fxaaQualityEdgeThreshold = 0.125;\\n float fxaaQualityEdgeThresholdMin = 0.0625;\\n\\n vec2 posM = gTexCoord;\\n vec4 rgbyM = TEXTURE_2D_TextureInput(posM);\\n float lumaM = rgbyM.y;\\n\\n // Swizzler Offseter Util\\n vec4 sw = vec4(-1.0, 1.0, 1.0, -1.0) * fxaaQualityRcpFrame.xxyy;\\n\\n float lumaS = TEXTURE_2D_TextureInput(posM + vec2(0.0, sw.z)).y;\\n float lumaE = TEXTURE_2D_TextureInput(posM + vec2(sw.y, 0.0)).y;\\n float lumaN = TEXTURE_2D_TextureInput(posM + vec2(0.0, sw.w)).y;\\n float lumaW = TEXTURE_2D_TextureInput(posM + vec2(sw.x, 0.0)).y;\\n\\n float maxSM = max(lumaS, lumaM);\\n float minSM = min(lumaS, lumaM);\\n\\n float maxESM = max(lumaE, maxSM);\\n float minESM = min(lumaE, minSM);\\n\\n float maxWN = max(lumaN, lumaW);\\n float minWN = min(lumaN, lumaW);\\n\\n float rangeMax = max(maxWN, maxESM);\\n float rangeMin = min(minWN, minESM);\\n\\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\\n float range = rangeMax - rangeMin;\\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\\n\\n bool earlyExit = range < rangeMaxClamped;\\n\\n if (earlyExit) {\\n#ifdef ASCII_FOOL\\n return ascii(posM);\\n#else\\n return rgbyM;\\n#endif\\n }\\n\\n float lumaNW = TEXTURE_2D_TextureInput(posM + sw.xw).y;\\n float lumaSE = TEXTURE_2D_TextureInput(posM + sw.yz).y;\\n float lumaNE = TEXTURE_2D_TextureInput(posM + sw.yw).y;\\n float lumaSW = TEXTURE_2D_TextureInput(posM + sw.xy).y;\\n\\n float lumaNS = lumaN + lumaS;\\n float lumaWE = lumaW + lumaE;\\n float subpixRcpRange = 1.0/range;\\n float subpixNSWE = lumaNS + lumaWE;\\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\\n\\n float lumaNESE = lumaNE + lumaSE;\\n float lumaNWNE = lumaNW + lumaNE;\\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\\n\\n float lumaNWSW = lumaNW + lumaSW;\\n float lumaSWSE = lumaSW + lumaSE;\\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\\n float edgeVert = abs(edgeVert3) + edgeVert4;\\n\\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\\n float lengthSign = fxaaQualityRcpFrame.x;\\n bool horzSpan = edgeHorz >= edgeVert;\\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\\n\\n if(!horzSpan) lumaN = lumaW;\\n if(!horzSpan) lumaS = lumaE;\\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\\n\\n float gradientN = lumaN - lumaM;\\n float gradientS = lumaS - lumaM;\\n float lumaNN = lumaN + lumaM;\\n float lumaSS = lumaS + lumaM;\\n bool pairN = abs(gradientN) >= abs(gradientS);\\n float gradient = max(abs(gradientN), abs(gradientS));\\n if(pairN) lengthSign = -lengthSign;\\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\\n\\n vec2 posB = posM.xy;\\n vec2 offNP;\\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\\n if(!horzSpan) posB.x += lengthSign * 0.5;\\n if( horzSpan) posB.y += lengthSign * 0.5;\\n\\n vec2 posN;\\n posN.x = posB.x - offNP.x;\\n posN.y = posB.y - offNP.y;\\n vec2 posP;\\n posP.x = posB.x + offNP.x;\\n posP.y = posB.y + offNP.y;\\n float subpixD = ((-2.0)*subpixC) + 3.0;\\n float lumaEndN = TEXTURE_2D_TextureInput(posN).y;\\n float subpixE = subpixC * subpixC;\\n float lumaEndP = TEXTURE_2D_TextureInput(posP).y;\\n\\n if(!pairN) lumaNN = lumaSS;\\n float gradientScaled = gradient * 1.0/4.0;\\n float lumaMM = lumaM - lumaNN * 0.5;\\n float subpixF = subpixD * subpixE;\\n bool lumaMLTZero = lumaMM < 0.0;\\n\\n lumaEndN -= lumaNN * 0.5;\\n lumaEndP -= lumaNN * 0.5;\\n bool doneN = abs(lumaEndN) >= gradientScaled;\\n bool doneP = abs(lumaEndP) >= gradientScaled;\\n if(!doneN) posN.x -= offNP.x * 1.5;\\n if(!doneN) posN.y -= offNP.y * 1.5;\\n bool doneNP = (!doneN) || (!doneP);\\n if(!doneP) posP.x += offNP.x * 1.5;\\n if(!doneP) posP.y += offNP.y * 1.5;\\n\\n if(doneNP) {\\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\\n doneN = abs(lumaEndN) >= gradientScaled;\\n doneP = abs(lumaEndP) >= gradientScaled;\\n if(!doneN) posN.x -= offNP.x * 2.0;\\n if(!doneN) posN.y -= offNP.y * 2.0;\\n doneNP = (!doneN) || (!doneP);\\n if(!doneP) posP.x += offNP.x * 2.0;\\n if(!doneP) posP.y += offNP.y * 2.0;\\n\\n if(doneNP) {\\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\\n doneN = abs(lumaEndN) >= gradientScaled;\\n doneP = abs(lumaEndP) >= gradientScaled;\\n if(!doneN) posN.x -= offNP.x * 4.0;\\n if(!doneN) posN.y -= offNP.y * 4.0;\\n doneNP = (!doneN) || (!doneP);\\n if(!doneP) posP.x += offNP.x * 4.0;\\n if(!doneP) posP.y += offNP.y * 4.0;\\n\\n if(doneNP) {\\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\\n doneN = abs(lumaEndN) >= gradientScaled;\\n doneP = abs(lumaEndP) >= gradientScaled;\\n if(!doneN) posN.x -= offNP.x * 12.0;\\n if(!doneN) posN.y -= offNP.y * 12.0;\\n doneNP = (!doneN) || (!doneP);\\n if(!doneP) posP.x += offNP.x * 12.0;\\n if(!doneP) posP.y += offNP.y * 12.0;\\n\\n }\\n\\n }\\n\\n }\\n\\n float dstN = posM.x - posN.x;\\n float dstP = posP.x - posM.x;\\n if(!horzSpan) dstN = posM.y - posN.y;\\n if(!horzSpan) dstP = posP.y - posM.y;\\n\\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\\n float spanLength = (dstP + dstN);\\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\\n float spanLengthRcp = 1.0/spanLength;\\n\\n bool directionN = dstN < dstP;\\n float dst = min(dstN, dstP);\\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\\n float subpixG = subpixF * subpixF;\\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\\n float subpixH = subpixG * fxaaQualitySubpix;\\n\\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\\n\\n \\n#ifdef ASCII_FOOL\\n return ascii(posM);\\n#else\\n return TEXTURE_2D_TextureInput(posM);\\n#endif\\n}\\n',\r\n 'grain.glsl':\r\n '#pragma include \"utils/rand.glsl\"\\n\\nuniform float uTimeGrain;\\nuniform float uGrainFactor;\\n\\nfloat nrandTriangle() {\\n float nrnd0 = pseudoRandom(gl_FragCoord.xy + 1000.0 * fract(uTimeGrain));\\n\\n // Convert uniform distribution into triangle-shaped distribution.\\n float orig = nrnd0 * 2.0 - 1.0;\\n nrnd0 = orig * inversesqrt(abs(orig));\\n nrnd0 = max(-1.0, nrnd0); // Nerf the NaN generated by 0 * rsqrt(0). Thanks @FioraAeterna!\\n nrnd0 = nrnd0 - sign(orig) + 0.5;\\n\\n // Result is range [-0.5,1.5] which is useful for actual dithering. convert to [0,1] for histogram.\\n return (nrnd0 + 0.5) * 0.5;\\n // return nrnd0;\\n}\\n\\nvec4 grain(const in vec4 color) {\\n float grainFactor = nrandTriangle();\\n return vec4(mix(color.rgb, color.rgb * (color.rgb + (1.0 - color.rgb) * 2.0 * grainFactor), uGrainFactor), color.a);\\n}',\r\n 'sharpen.glsl':\r\n '#pragma include \"utils/decodeDepth.glsl\"\\n\\nuniform sampler2D TextureInput;\\nuniform vec2 uTextureInputSize;\\n\\n#ifdef HAS_BACKGROUND\\nuniform sampler2D TextureDepth;\\n#endif\\n\\nuniform float uSharpFactor;\\n\\nuniform vec2 uPixelRatio;\\n\\nvec3 sharpColorFactor(const in vec3 color, const float sharp) {\\n vec2 off = uPixelRatio.xy / uTextureInputSize.xy;\\n\\n // use useAA, 4 texFetch already in cache. perhaps we could cache ourself.\\n vec3 rgbNW = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(-1.0, -1.0)).rgb; \\n vec3 rgbSE = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(1.0, 1.0)).rgb;\\n vec3 rgbNE = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(1.0, -1.0)).rgb;\\n vec3 rgbSW = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(-1.0, 1.0)).rgb;\\n\\n return color + sharp * (4.0 * color - rgbNW - rgbNE - rgbSW - rgbSE);\\n}\\n\\nvec4 sharpen(const in vec4 color) {\\n#ifdef HAS_BACKGROUND\\n\\tfloat alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\\n\\tif( alpha == 0.0 ) {\\n\\t\\treturn vec4(color.rgb,1.0);\\n }\\n#else\\n\\tfloat alpha = 1.0;\\n#endif\\n\\n return vec4(sharpColorFactor(color.rgb, uSharpFactor * alpha), color.a);\\n}\\n\\nvec4 sharpen() {\\n return sharpen(TEXTURE_2D_TextureInput(gTexCoord));\\n}',\r\n 'dofCross.glsl':\r\n 'uniform vec2 uTextureInputSize;\\nuniform vec3 uDofCross;\\n\\nuniform vec2 uPixelRatio;\\n\\nvec4 dofCross(const in vec4 color) {\\n float ratio = uTextureInputSize.y / uTextureInputSize.x;\\n float dist = distance(vec2(uDofCross.x, uDofCross.y * ratio), gTexCoord * vec2(1.0, ratio));\\n float widthCircle = uPixelRatio.x / uTextureInputSize.x;\\n return vec4(mix(color.rgb, vec3(1.0), abs(dist - 60.0 * widthCircle) > widthCircle ? 0.0 : uDofCross.z), color.a);\\n}',\r\n 'distortion.glsl':\r\n '// https://github.com/borismus/webvr-boilerplate/blob/master/src/distortion/barrel-distortion-fragment-v2.js\\n\\nvec2 barrel(const in vec2 v, const in vec4 projection, const in vec4 unprojection) {\\n vec2 w = (v + unprojection.zw) / unprojection.xy;\\n float val = dot(w, w);\\n // float poly = (showCenter == 1 && val < 0.00010) ? 10000.0 : 1.0 + (uDistortion.x + uDistortion.y * val) * val;\\n float poly = 1.0 + (uDistortion.x + uDistortion.y * val) * val;\\n return projection.xy * (poly * w) - projection.zw;\\n}\\n\\nvec2 distortion(const in vec2 texCoord) {\\n\\n if (abs(texCoord.x - 0.5) < .001) {\\n discard;\\n }\\n\\n vec2 a;\\n\\n if (texCoord.x < 0.5){\\n a = barrel(vec2(texCoord.x / 0.5, texCoord.y), uProjectionLeft, uUnprojectionLeft);\\n } else {\\n // right projections are shifted and vertically mirrored relative to left\\n const vec3 swi = vec3(1.0, -1.0, 0.0);\\n vec4 projectionRight = (uProjectionLeft + swi.zzxz) * swi.xxyx;\\n vec4 unprojectionRight = (uUnprojectionLeft + swi.zzxz) * swi.xxyx;\\n a = barrel(vec2((texCoord.x - 0.5) / 0.5, texCoord.y), projectionRight, unprojectionRight);\\n }\\n\\n if (a.x < 0.0 || a.x > 1.0 || a.y < 0.0 || a.y > 1.0) {\\n discard;\\n }\\n\\n return vec2(a.x * 0.5 + (texCoord.x < 0.5 ? 0.0 : 0.5), a.y);\\n}',\r\n 'ascii.glsl':\r\n '//original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h\\n// Here\\'s a little tool for new characters: thrill-project.com/archiv/coding/bitmap/\\n\\nfloat character(const in float n, vec2 p)\\n{\\n p = floor(p*vec2(4.0, -4.0) + 2.5);\\n if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y)\\n {\\n if (int(mod(n/exp2(p.x + 5.0 * p.y), 2.0)) == 1) return 1.5;\\n }\\n return 0.2;\\n}\\n\\nuniform vec2 uTextureInputSize;\\n\\nvec4 ascii( const in vec2 coord )\\n{\\n vec2 pix = coord*uTextureInputSize.xy;\\n vec3 col = TEXTURE_2D_TextureInput(floor(pix/16.0)*16.0/uTextureInputSize.xy).rgb;\\n\\n float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;\\n\\n // 458144 fish\\n // 473536 square\\n // 33408895 empty round\\n // a 469450 33095217\\n // p 469448 33095184\\n // r 32078482\\n // i 14815374\\n // l 8659215\\n\\n/*\\n float n = 4096.0; // .\\n if (gray > 0.2) n = 65600.0; // :\\n if (gray > 0.3) n = 332772.0; // *\\n if (gray > 0.4) n = 15255086.0; // o\\n if (gray > 0.5) n = 23385164.0; // &\\n if (gray > 0.6) n = 15252014.0; // 8\\n if (gray > 0.7) n = 13199452.0; // @\\n if (gray > 0.8) n = 11512810.0; // #\\n*/\\n\\n // letters are APRIL\\n // \"emojii\" are fish, square, hollow round\\n float n = 14815374.0; // I\\n if (gray > 0.2) n = 473536.0; // square\\n if (gray > 0.3) n = 15255086.0; // round o\\n if (gray > 0.4) n = 458144.0; // fish\\n if (gray > 0.5) n = 10955200.0; // A\\n if (gray > 0.6) n = 1113663.0; // P\\n if (gray > 0.7) n = 5356847.0; // R\\n if (gray > 0.8) n = 15762465.0; // L\\n\\n vec2 p = mod(pix / 8.0, 2.0) - vec2(1.0);\\n col = col * vec3(character(n, p));\\n return vec4(col, 1.0);\\n}\\n',\r\n 'fadeVr.glsl':\r\n 'uniform float uVrFadeFactor;\\r\\n\\r\\nvec4 fadeVr(const in vec4 color) {\\r\\n\\treturn vec4(mix(color.rgb, vec3(0.0), clamp(uVrFadeFactor, 0.0, 1.0)), color.a);\\r\\n}',\r\n 'veilVr.glsl':\r\n 'uniform float uVrVeilFactor;\\r\\n\\r\\nvec4 veilVr(const in vec4 color) {\\r\\n\\treturn vec4(color.rgb * uVrVeilFactor, 1.0);\\r\\n}',\r\n 'outline.glsl':\r\n 'uniform float uOutlineFactor;\\nuniform vec2 uPixelRatio;\\nuniform float uHighlightFactor;\\nuniform float uLineWidth;\\n\\nuniform sampler2D TextureOutline;\\nuniform vec2 uTextureOutlineSize;\\n\\nvec4 outline() {\\n float fac0 = 2.0;\\n float fac1 = 1.0;\\n float offsetx = uPixelRatio.x / uTextureOutlineSize[0] * uLineWidth;\\n float offsety = uPixelRatio.y / uTextureOutlineSize[1] * uLineWidth;\\n\\n vec4 texel0 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, offsety));\\n vec4 texel1 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, 0.0));\\n vec4 texel2 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, -offsety));\\n vec4 texel3 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(0.0, -offsety));\\n vec4 texel4 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, -offsety));\\n vec4 texel5 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, 0.0));\\n vec4 texel6 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, offsety));\\n vec4 texel7 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(0.0, offsety));\\n\\n vec4 rowx = -fac0 * texel5 + fac0 * texel1 + -fac1 * texel6 + fac1 * texel0 + -fac1 * texel4 + fac1 * texel2;\\n vec4 rowy = -fac0 * texel3 + fac0 * texel7 + -fac1 * texel4 + fac1 * texel6 + -fac1 * texel2 + fac1 * texel0;\\n\\n float magSqr = sqrt(dot(rowy, rowy) + dot(rowx, rowx));\\n bool infMag = magSqr < 1.0 / 65025.0;\\n\\n vec3 texelCenter = TEXTURE_2D_TextureOutline(gTexCoord).rgb;\\n if (texelCenter == vec3(0.0) || (uHighlightFactor == 0.0 && infMag)) {\\n discard;\\n }\\n\\n float finalFactor = infMag ? uHighlightFactor : min(1.0, sqrt(magSqr) * uOutlineFactor);\\n\\n return finalFactor * vec4(texelCenter, 1.0);\\n}\\n',\r\n 'finalPremultAlpha.glsl':\r\n 'vec4 finalPremultAlpha(const in vec4 color) {\\n return vec4(linearTosRGB(sRGBToLinear(color.rgb) * color.a), color.a);\\n}',\r\n};\r\n","import notify from '../osg/notify';\r\nimport BoundingSphere from '../osg/BoundingSphere';\r\nimport { mat4 } from '../osg/glMatrix';\r\n\r\n// Base class for Camera / User manipulator\r\nvar Manipulator = function(options) {\r\n if (options) {\r\n this._boundStrategy = options.boundStrategy;\r\n this.setInputManager(options.inputManager);\r\n }\r\n\r\n if (this._boundStrategy === undefined) {\r\n this._boundStrategy = Manipulator.COMPUTE_HOME_USING_SPHERE;\r\n }\r\n\r\n this._controllerList = {};\r\n this._inverseMatrix = mat4.create();\r\n this._camera = undefined;\r\n this._node = undefined;\r\n this._frustum = {};\r\n this._computeBoundNodeMaskOverride = ~0x0;\r\n\r\n // for getHomeBoundingSphere\r\n this._tmpSphere = new BoundingSphere();\r\n};\r\n\r\nManipulator.prototype = {\r\n setCamera: function(c) {\r\n this._camera = c;\r\n },\r\n getCamera: function() {\r\n return this._camera;\r\n },\r\n setNode: function(node) {\r\n this._node = node;\r\n },\r\n setComputeBoundNodeMaskOverride: function(mask) {\r\n this._computeBoundNodeMaskOverride = mask;\r\n },\r\n getComputeBoundNodeMaskOverride: function() {\r\n return this._computeBoundNodeMaskOverride;\r\n },\r\n\r\n setInputManager: function(inputManager) {\r\n this._inputManager = inputManager;\r\n },\r\n\r\n getInputManager: function() {\r\n return this._inputManager;\r\n },\r\n\r\n // overrideStrat should be a bounding volume calculation strategy\r\n getHomeBoundingSphere: function(overrideStrat) {\r\n var node = this._node;\r\n if (!node) return;\r\n\r\n var type = overrideStrat !== undefined ? overrideStrat : this._boundStrategy;\r\n\r\n if (type & Manipulator.COMPUTE_HOME_USING_BBOX) {\r\n var box;\r\n if (this._computeBoundNodeMaskOverride === ~0x0) {\r\n box = node.getBoundingBox();\r\n } else {\r\n var ComputeBoundsVisitor = require('../osg/ComputeBoundsVisitor').default;\r\n var cbv = new ComputeBoundsVisitor();\r\n cbv.setNodeMaskOverride(this._computeBoundNodeMaskOverride);\r\n cbv.reset();\r\n\r\n cbv.apply(node);\r\n box = cbv.getBoundingBox();\r\n }\r\n\r\n if (!box.valid()) return node.getBoundingSphere();\r\n\r\n // minimum between sphere and box\r\n if (type & Manipulator.COMPUTE_HOME_USING_SPHERE) {\r\n var bsphere = node.getBoundingSphere();\r\n if (bsphere.valid() && bsphere.volume() < box.volume()) {\r\n return bsphere;\r\n }\r\n }\r\n\r\n this._tmpSphere.copyBoundingBox(box);\r\n return this._tmpSphere;\r\n }\r\n\r\n return node.getBoundingSphere();\r\n },\r\n\r\n getHomeBound: function(overrideStrat) {\r\n notify.warn('Please use getHomeBoundingSphere instead');\r\n return this.getHomeBoundingSphere(overrideStrat);\r\n },\r\n\r\n getHomeDistance: function(bound) {\r\n var frustum = this._frustum;\r\n var dist = bound.radius();\r\n if (this._camera && mat4.getFrustum(frustum, this._camera.getProjectionMatrix())) {\r\n var vertical2 = Math.abs(frustum.right - frustum.left) / frustum.zNear / 2;\r\n var horizontal2 = Math.abs(frustum.top - frustum.bottom) / frustum.zNear / 2;\r\n dist /= Math.sin(Math.atan2(horizontal2 < vertical2 ? horizontal2 : vertical2, 1));\r\n } else {\r\n dist *= 1.5;\r\n }\r\n return dist;\r\n },\r\n // eg: var currentTime = nv.getFrameStamp().getSimulationTime();\r\n update: function(/*nv*/) {},\r\n\r\n getInverseMatrix: function() {\r\n return this._inverseMatrix;\r\n },\r\n\r\n getControllerList: function() {\r\n return this._controllerList;\r\n }\r\n};\r\n\r\n// flags\r\nManipulator.COMPUTE_HOME_USING_SPHERE = 1 << 0;\r\nManipulator.COMPUTE_HOME_USING_BBOX = 1 << 1;\r\n\r\nexport default Manipulator;\r\n","var Controller = function(manipulator) {\r\n this._manipulator = manipulator;\r\n this._enable = true;\r\n};\r\n\r\nController.prototype = {\r\n // All eventProxy must check isEnabled before injecting\r\n // event into Controllers\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n // called to enable/disable a Controller\r\n // it should be customized for controller that keeps states\r\n // on events\r\n setEnable: function(bool) {\r\n this._enable = bool;\r\n }\r\n};\r\n\r\nexport default Controller;\r\n","var InputGroups = {};\r\n\r\nInputGroups.SCENE = 'scene';\r\n\r\nInputGroups.MANIPULATORS = 'scene.manipulators';\r\n\r\nInputGroups.ORBIT_MANIPULATOR = 'scene.manipulators.orbit';\r\nInputGroups.ORBIT_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.orbit.mousekeyboard';\r\nInputGroups.ORBIT_MANIPULATOR_RESETTOHOME = 'scene.manipulators.orbit.mousekeyboard.home';\r\nInputGroups.ORBIT_MANIPULATOR_TOUCH = 'scene.manipulators.orbit.touch';\r\nInputGroups.ORBIT_MANIPULATOR_WEBVR = 'scene.manipulators.orbit.webvr';\r\nInputGroups.ORBIT_MANIPULATOR_DEVICEORIENTATION = 'scene.manipulators.orbit.deviceorientation';\r\nInputGroups.ORBIT_MANIPULATOR_GAMEPAD = 'scene.manipulators.orbit.gamepad';\r\n\r\nInputGroups.FPS_MANIPULATOR = 'scene.manipulators.fps';\r\nInputGroups.FPS_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.fps.mousekeyboard';\r\nInputGroups.FPS_MANIPULATOR_RESETTOHOME = 'scene.manipulators.fps.mousekeyboard.home';\r\nInputGroups.FPS_MANIPULATOR_TOUCH = 'scene.manipulators.fps.touch';\r\nInputGroups.FPS_MANIPULATOR_WEBVR = 'scene.manipulators.fps.webvr';\r\nInputGroups.FPS_MANIPULATOR_DEVICEORIENTATION = 'scene.manipulators.fps.deviceorientation';\r\nInputGroups.FPS_MANIPULATOR_GAMEPAD = 'scene.manipulators.fps.gamepad';\r\n\r\nInputGroups.CAD_MANIPULATOR = 'scene.manipulators.cad';\r\nInputGroups.CAD_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.cad.mousekeyboard';\r\nInputGroups.CAD_MANIPULATOR_RESETTOHOME = 'scene.manipulators.cad.mousekeyboard.home';\r\nInputGroups.CAD_MANIPULATOR_TOUCH = 'scene.manipulators.cad.touch';\r\n\r\nInputGroups.NODE_GIZMO = 'scene.nodegizmo';\r\n\r\nInputGroups.UI = 'ui';\r\nInputGroups.STATS = 'ui.stats';\r\n\r\nexport default InputGroups;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar degtorad = Math.PI / 180.0; // Degree-to-Radian conversion\r\n\r\nvar makeRotateFromEuler = function(q, x, y, z, order) {\r\n // http://www.mathworks.com/matlabcentral/fileexchange/\r\n // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\r\n // content/SpinCalc.m\r\n\r\n var c1 = Math.cos(x / 2);\r\n var c2 = Math.cos(y / 2);\r\n var c3 = Math.cos(z / 2);\r\n var s1 = Math.sin(x / 2);\r\n var s2 = Math.sin(y / 2);\r\n var s3 = Math.sin(z / 2);\r\n\r\n if (order === 'XYZ') {\r\n q[0] = s1 * c2 * c3 + c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 - s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 + s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 - s1 * s2 * s3;\r\n } else if (order === 'YXZ') {\r\n q[0] = s1 * c2 * c3 + c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 - s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 - s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 + s1 * s2 * s3;\r\n } else if (order === 'ZXY') {\r\n q[0] = s1 * c2 * c3 - c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 + s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 + s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 - s1 * s2 * s3;\r\n } else if (order === 'ZYX') {\r\n q[0] = s1 * c2 * c3 - c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 + s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 - s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 + s1 * s2 * s3;\r\n } else if (order === 'YZX') {\r\n q[0] = s1 * c2 * c3 + c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 + s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 - s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 - s1 * s2 * s3;\r\n } else if (order === 'XZY') {\r\n q[0] = s1 * c2 * c3 - c1 * s2 * s3;\r\n q[1] = c1 * s2 * c3 - s1 * c2 * s3;\r\n q[2] = c1 * c2 * s3 + s1 * s2 * c3;\r\n q[3] = c1 * c2 * c3 + s1 * s2 * s3;\r\n }\r\n return q;\r\n};\r\n\r\nvar FirstPersonManipulatorDeviceOrientationController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nFirstPersonManipulatorDeviceOrientationController.computeQuaternion = (function() {\r\n var screenTransform = quat.create();\r\n var worldTransform = quat.fromValues(-Math.sqrt(0.5), 0.0, 0.0, Math.sqrt(0.5)); // - PI/2 around the x-axis\r\n\r\n // but on ios alpha is relative to the first question:\r\n //\r\n // http://www.html5rocks.com/en/tutorials/device/orientation/\r\n // For most browsers, alpha returns the compass heading, so when the device is pointed\r\n // north, alpha is zero. With Mobile Safari, alpha is based on the direction the\r\n // device was pointing when device orientation was first requested. The compass\r\n // heading is available in the webkitCompassHeading parameter.\r\n\r\n return function(q, deviceOrientation, screenOrientation) {\r\n var alpha = deviceOrientation.alpha * degtorad;\r\n var beta = deviceOrientation.beta * degtorad;\r\n var gamma = deviceOrientation.gamma * degtorad;\r\n\r\n // If the user goes in landscape mode, he rotates his device with a certain angle\r\n // around the Z axis counterclockwise and the DeviceOrientation contains this\r\n // rotation To compensate this, we apply a rotation of the same angle in the\r\n // opposite way\r\n\r\n var screenAngle = screenOrientation * degtorad;\r\n\r\n // alpha is heading -> X\r\n // beta -> Z Up\r\n // Gamma -> Y view direction\r\n makeRotateFromEuler(q, beta, alpha, -gamma, 'YXZ');\r\n // equivalent to\r\n // var rotateX = mat4.fromRotation( mat4.create(), beta,[ 1,0,0 ] );\r\n // var rotateY = mat4.fromRotation( mat4.create(), alpha,[ 0,1,0 ] );\r\n // var rotateZ = mat4.fromRotation( mat4.create(), -gamma,[ 0,0,1 ] );\r\n // var result = mat4.create();\r\n // mat4.mul( result, rotateY, rotateX );\r\n // mat4.mul( result, result, rotateZ );\r\n // mat4.getRotation( q, result );\r\n\r\n var minusHalfAngle = -screenAngle / 2.0;\r\n screenTransform[1] = Math.sin(minusHalfAngle);\r\n screenTransform[3] = Math.cos(minusHalfAngle);\r\n\r\n quat.mul(q, q, screenTransform);\r\n quat.mul(q, q, worldTransform);\r\n\r\n var yTemp = q[1];\r\n q[1] = -q[2];\r\n q[2] = yTemp;\r\n\r\n return q;\r\n };\r\n})();\r\n\r\nutils.createPrototypeObject(\r\n FirstPersonManipulatorDeviceOrientationController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._quat = quat.create();\r\n this._pos = vec3.create();\r\n this._deviceOrientation = undefined;\r\n this._screenOrientation = undefined;\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.FPS_MANIPULATOR_DEVICEORIENTATION).addMappings(\r\n {\r\n setDeviceOrientation: 'deviceorientation',\r\n setScreenOrientation: 'orientationchange'\r\n },\r\n this\r\n );\r\n\r\n // default to disabled\r\n manager.setEnable(InputGroups.FPS_MANIPULATOR_DEVICEORIENTATION, false);\r\n },\r\n\r\n setDeviceOrientation: function(ev) {\r\n if (!this._deviceOrientation) {\r\n this._deviceOrientation = {};\r\n }\r\n this._deviceOrientation.alpha = ev.alpha;\r\n this._deviceOrientation.beta = ev.beta;\r\n this._deviceOrientation.gamma = ev.gamma;\r\n\r\n if (ev.screenOrientation) {\r\n this.setScreenOrientation(ev);\r\n return;\r\n }\r\n\r\n this._update();\r\n },\r\n\r\n setScreenOrientation: function(ev) {\r\n this._screenOrientation = ev.screenOrientation;\r\n this._update();\r\n },\r\n\r\n _update: function() {\r\n if (!this._deviceOrientation || !this._screenOrientation) {\r\n return;\r\n }\r\n\r\n FirstPersonManipulatorDeviceOrientationController.computeQuaternion(\r\n this._quat,\r\n this._deviceOrientation,\r\n this._screenOrientation\r\n );\r\n\r\n this._manipulator.setPoseVR(this._quat, this._pos);\r\n }\r\n })\r\n);\r\n\r\nexport default FirstPersonManipulatorDeviceOrientationController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\n\r\nimport FirstPersonDeviceOrientation from './FirstPersonManipulatorDeviceOrientationController';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar OrbitManipulatorDeviceOrientationController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n OrbitManipulatorDeviceOrientationController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._quat = quat.create();\r\n this._pos = vec3.create();\r\n\r\n this._deviceOrientation = undefined;\r\n this._screenOrientation = undefined;\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_DEVICEORIENTATION).addMappings(\r\n {\r\n setDeviceOrientation: 'deviceorientation',\r\n setScreenOrientation: 'orientationchange'\r\n },\r\n this\r\n );\r\n\r\n // default to disabled\r\n manager.setEnable(InputGroups.ORBIT_MANIPULATOR_DEVICEORIENTATION, false);\r\n },\r\n\r\n setDeviceOrientation: function(ev) {\r\n if (!this._deviceOrientation) {\r\n this._deviceOrientation = {};\r\n }\r\n this._deviceOrientation.alpha = ev.alpha;\r\n this._deviceOrientation.beta = ev.beta;\r\n this._deviceOrientation.gamma = ev.gamma;\r\n\r\n if (ev.screenOrientation) {\r\n this.setScreenOrientation(ev);\r\n return;\r\n }\r\n\r\n this._update();\r\n },\r\n\r\n setScreenOrientation: function(ev) {\r\n this._screenOrientation = ev.screenOrientation;\r\n this._update();\r\n },\r\n\r\n _update: function() {\r\n if (!this._deviceOrientation || !this._screenOrientation) {\r\n return;\r\n }\r\n\r\n FirstPersonDeviceOrientation.computeQuaternion(\r\n this._quat,\r\n this._deviceOrientation,\r\n this._screenOrientation\r\n );\r\n this._manipulator.setPoseVR(this._quat, this._pos);\r\n }\r\n })\r\n);\r\n\r\nexport default OrbitManipulatorDeviceOrientationController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport { vec2 } from '../osg/glMatrix';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar OrbitManipulatorGamePadController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n OrbitManipulatorGamePadController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._delay = 0.15;\r\n this._zoomFactor = 0.5;\r\n this._rotateFactor = 5.0;\r\n this._panFactor = 10.0;\r\n\r\n //var rotateTarget, panTarget;\r\n this._rotate = this._manipulator.getRotateInterpolator();\r\n this._zoom = this._manipulator.getZoomInterpolator();\r\n this._pan = this._manipulator.getPanInterpolator();\r\n\r\n this._rotate.setDelay(this._delay);\r\n this._zoom.setDelay(this._delay);\r\n this._pan.setDelay(this._delay);\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_GAMEPAD).addMappings(\r\n {\r\n addZoom: 'axis 3',\r\n addRotateX: 'axis 0',\r\n addRotateY: 'axis 1'\r\n },\r\n this\r\n );\r\n\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_GAMEPAD).addMappings(\r\n {\r\n panUp: 'buttonvalue 12'\r\n },\r\n this.pan.bind(this, vec2.fromValues(0, 1))\r\n );\r\n\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_GAMEPAD).addMappings(\r\n {\r\n panDown: 'buttonvalue 13'\r\n },\r\n this.pan.bind(this, vec2.fromValues(0, -1))\r\n );\r\n\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_GAMEPAD).addMappings(\r\n {\r\n panLeft: 'buttonvalue 14'\r\n },\r\n this.pan.bind(this, vec2.fromValues(1, 0))\r\n );\r\n\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_GAMEPAD).addMappings(\r\n {\r\n panRight: 'buttonvalue 15'\r\n },\r\n this.pan.bind(this, vec2.fromValues(-1, 0))\r\n );\r\n\r\n // Keeping this for whenever we add the support for custom gamepad layout\r\n // this._padFactor = 10.0;\r\n // //SpaceNavigator & 6-axis controllers\r\n // } else if (axes.length >= 5) {\r\n // if (Math.abs(axes[0]) > AXIS_THRESHOLD || Math.abs(axes[1]) > AXIS_THRESHOLD) {\r\n // this.addPan(pan, -axes[0], axes[1]);\r\n // }\r\n //\r\n // if (Math.abs(axes[2]) > AXIS_THRESHOLD) {\r\n // this.addZoom(zoom, -axes[2]);\r\n // }\r\n //\r\n // if (Math.abs(axes[3]) > AXIS_THRESHOLD || Math.abs(axes[4]) > AXIS_THRESHOLD) {\r\n // this.addRotate(rotate, axes[4], axes[3]);\r\n // }\r\n // }\r\n },\r\n\r\n pan: function(delta) {\r\n var panTarget = this._pan.getTarget();\r\n this._pan.setTarget(\r\n panTarget[0] - delta[0] * this._panFactor,\r\n panTarget[1] + delta[1] * this._panFactor\r\n );\r\n },\r\n\r\n addZoom: function(ev) {\r\n this._zoom.addTarget(-ev.value * this._zoomFactor);\r\n },\r\n\r\n addRotateX: function(ev) {\r\n this._rotate.addTarget(-ev.value * this._rotateFactor);\r\n },\r\n\r\n addRotateY: function(ev) {\r\n this._rotate.addTarget(0, ev.value * this._rotateFactor);\r\n }\r\n })\r\n);\r\nexport default OrbitManipulatorGamePadController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport osgMath from '../osg/math';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar OrbitManipulatorHammerController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n OrbitManipulatorHammerController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._panFactor = [];\r\n this._panFactor[0] = 1.0;\r\n this._panFactor[1] = -this._panFactor[0];\r\n\r\n this._rotateFactor = [];\r\n this._rotateFactor[0] = 1.2;\r\n this._rotateFactor[1] = -this._rotateFactor[0];\r\n this._zoomFactor = 5.0;\r\n\r\n this._lastScale = 0;\r\n\r\n this._zooming = false;\r\n this._dragStarted = false;\r\n\r\n this._initInputs(InputGroups.ORBIT_MANIPULATOR_TOUCH);\r\n },\r\n\r\n _initInputs: function(group) {\r\n var manager = this._manipulator.getInputManager();\r\n\r\n manager.group(group).addMappings(\r\n {\r\n pinchEnd: 'pinchend',\r\n pinchStart: 'pinchstart',\r\n pinchInOut: ['pinchin', 'pinchout'],\r\n startPan: ['panstart 2'],\r\n startRotate: ['panstart 1'],\r\n pan: ['panmove 2'],\r\n rotate: ['panmove 1'],\r\n endMotion: ['touchend 2', 'touchcancel 2', 'touchend 1', 'touchcancel 1']\r\n },\r\n this\r\n );\r\n },\r\n\r\n startPan: function(event) {\r\n this._panning = true;\r\n this.startMotion(this._manipulator.getPanInterpolator(), this._panFactor, event);\r\n },\r\n\r\n startRotate: function(event) {\r\n this._rotating = true;\r\n this.startMotion(this._manipulator.getRotateInterpolator(), this._rotateFactor, event);\r\n },\r\n\r\n pan: function(event) {\r\n if (!this._panning) {\r\n this.endMotion();\r\n this.startPan(event);\r\n }\r\n this.move(this._manipulator.getPanInterpolator(), this._panFactor, event);\r\n },\r\n\r\n rotate: function(event) {\r\n if (!this._rotating) {\r\n this.endMotion();\r\n this.startPan(event);\r\n }\r\n this.move(this._manipulator.getRotateInterpolator(), this._rotateFactor, event);\r\n },\r\n\r\n startMotion: function(interpolator, factor, event) {\r\n if (this._zooming) {\r\n return;\r\n }\r\n interpolator.reset();\r\n var x = event.canvasX * factor[0];\r\n var y = event.canvasY * factor[1];\r\n interpolator.set(x, y);\r\n },\r\n\r\n move: function(interpolator, factor, event) {\r\n var x = event.canvasX * factor[0];\r\n var y = event.canvasY * factor[1];\r\n interpolator.setTarget(x, y);\r\n },\r\n\r\n endMotion: function() {\r\n if (!this._panning && !this._rotating) return;\r\n this._panning = false;\r\n this._rotating = false;\r\n },\r\n\r\n pinchStart: function(event) {\r\n this._zooming = true;\r\n this._lastScale = event.scale;\r\n var zoomInterpolator = this._manipulator.getZoomInterpolator();\r\n zoomInterpolator.reset();\r\n zoomInterpolator.set(this._lastScale);\r\n },\r\n\r\n pinchEnd: function() {\r\n this._zooming = false;\r\n },\r\n\r\n pinchInOut: function(event) {\r\n if (!this._zooming) return;\r\n\r\n // make the dezoom faster (because the manipulator dezoom/dezoom distance speed is adaptive)\r\n var zoomFactor =\r\n event.scale > this._lastScale ? this._zoomFactor : this._zoomFactor * 3.0;\r\n // also detect pan (velocity) to reduce zoom force\r\n var minDezoom = 0.0;\r\n var maxDezoom = 0.5;\r\n var aSmooth = -Math.abs(event.velocity) + (minDezoom + maxDezoom);\r\n zoomFactor *= osgMath.smoothStep(minDezoom, maxDezoom, aSmooth);\r\n\r\n var scale = (event.scale - this._lastScale) * zoomFactor;\r\n this._lastScale = event.scale;\r\n\r\n var zoomInterpolator = this._manipulator.getZoomInterpolator();\r\n zoomInterpolator.setTarget(zoomInterpolator.getTarget()[0] - scale);\r\n },\r\n\r\n setManipulator: function(manipulator) {\r\n this._manipulator = manipulator;\r\n }\r\n })\r\n);\r\n\r\nexport default OrbitManipulatorHammerController;\r\n","export default {\r\n ROTATE: 0,\r\n PAN: 1,\r\n ZOOM: 2\r\n};\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport osgMath from '../osg/math';\r\nimport OrbitManipulatorEnums from './orbitManipulatorEnums';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar OrbitManipulatorStandardMouseKeyboardController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this._zoomFactor = 1;\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n OrbitManipulatorStandardMouseKeyboardController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._mode = undefined;\r\n this._inMotion = false;\r\n\r\n this._initInputs(\r\n InputGroups.ORBIT_MANIPULATOR_MOUSEKEYBOARD,\r\n InputGroups.ORBIT_MANIPULATOR_RESETTOHOME\r\n );\r\n },\r\n\r\n _initInputs: function(globalGroup, resetToHomeGroup) {\r\n var manager = this._manipulator.getInputManager();\r\n var setRotationMode = this.setMode.bind(\r\n this,\r\n OrbitManipulatorEnums.ROTATE,\r\n this._manipulator.getRotateInterpolator()\r\n );\r\n var setPanMode = this.setMode.bind(\r\n this,\r\n OrbitManipulatorEnums.PAN,\r\n this._manipulator.getPanInterpolator()\r\n );\r\n var setZoomMode = this.setMode.bind(\r\n this,\r\n OrbitManipulatorEnums.ZOOM,\r\n this._manipulator.getZoomInterpolator()\r\n );\r\n\r\n manager.group(globalGroup).addMappings(\r\n {\r\n move: 'mousemove',\r\n startPan: ['mousedown shift 0', 'mousedown 1', 'mousedown 2'],\r\n startZoom: ['mousedown ctrl 0', 'mousedown ctrl 2'],\r\n startRotate: 'mousedown 0 !shift !ctrl',\r\n stopMotion: ['mouseup', 'mouseout', 'keyup a', 'keyup s', 'keyup d'],\r\n zoom: 'wheel'\r\n },\r\n this\r\n );\r\n\r\n manager.group(resetToHomeGroup).addMappings(\r\n {\r\n reset: 'keydown space'\r\n },\r\n this\r\n );\r\n\r\n manager\r\n .group(globalGroup)\r\n .addMappings({ setRotationMode: 'keydown a' }, setRotationMode);\r\n manager.group(globalGroup).addMappings({ setPanMode: 'keydown d' }, setPanMode);\r\n manager.group(globalGroup).addMappings({ setZoomMode: 'keydown s' }, setZoomMode);\r\n },\r\n\r\n getMode: function() {\r\n return this._mode;\r\n },\r\n\r\n setMode: function(mode, interpolator) {\r\n if (this.getMode() === mode) {\r\n return;\r\n }\r\n this._mode = mode;\r\n interpolator.reset();\r\n this._inMotion = true;\r\n },\r\n\r\n setManipulator: function(manipulator) {\r\n this._manipulator = manipulator;\r\n },\r\n\r\n getZoomFactor: function() {\r\n return this._zoomFactor;\r\n },\r\n\r\n setZoomFactor: function(factor) {\r\n this._zoomFactor = factor;\r\n },\r\n\r\n move: function(ev) {\r\n if (this._inMotion === false) {\r\n return;\r\n }\r\n\r\n var posX = ev.canvasX;\r\n var posY = -ev.canvasY;\r\n\r\n var manipulator = this._manipulator;\r\n if (osgMath.isNaN(posX) === false && osgMath.isNaN(posY) === false) {\r\n var mode = this.getMode();\r\n if (mode === OrbitManipulatorEnums.ROTATE) {\r\n manipulator.getRotateInterpolator().setTarget(posX, posY);\r\n } else if (mode === OrbitManipulatorEnums.PAN) {\r\n manipulator.getPanInterpolator().setTarget(posX, posY);\r\n } else if (mode === OrbitManipulatorEnums.ZOOM) {\r\n var zoom = manipulator.getZoomInterpolator();\r\n if (zoom.isReset()) {\r\n zoom.setStart(posY);\r\n zoom.set(0.0);\r\n }\r\n var dy = posY - zoom.getStart();\r\n zoom.setStart(posY);\r\n var v = zoom.getTarget()[0];\r\n zoom.setTarget(v - dy / 20.0);\r\n }\r\n }\r\n },\r\n\r\n startPan: function(ev) {\r\n var pan = this._manipulator.getPanInterpolator();\r\n this.setMode(OrbitManipulatorEnums.PAN, pan);\r\n pan.reset();\r\n pan.set(ev.canvasX, -ev.canvasY);\r\n },\r\n\r\n startRotate: function(ev) {\r\n var rotate = this._manipulator.getRotateInterpolator();\r\n this.setMode(OrbitManipulatorEnums.ROTATE, rotate);\r\n rotate.reset();\r\n rotate.set(ev.canvasX, -ev.canvasY);\r\n },\r\n\r\n startZoom: function(ev) {\r\n var zoom = this._manipulator.getZoomInterpolator();\r\n this.setMode(OrbitManipulatorEnums.ZOOM, zoom);\r\n zoom.setStart(-ev.canvasY);\r\n zoom.set(0.0);\r\n },\r\n\r\n stopMotion: function() {\r\n this._inMotion = false;\r\n this._mode = undefined;\r\n },\r\n\r\n zoom: function(ev) {\r\n var intDelta = ev.deltaY / this._zoomFactor;\r\n var manipulator = this._manipulator;\r\n var zoomTarget = manipulator.getZoomInterpolator().getTarget()[0] - intDelta;\r\n manipulator.getZoomInterpolator().setTarget(zoomTarget);\r\n },\r\n\r\n reset: function() {\r\n this._manipulator.computeHomePosition();\r\n }\r\n })\r\n);\r\nexport default OrbitManipulatorStandardMouseKeyboardController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar tempQuat = quat.create();\r\nvar tempPos = vec3.create();\r\n\r\nvar OrbitManipulatorWebVRController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n OrbitManipulatorWebVRController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._pos = vec3.create();\r\n this._quat = quat.create();\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.ORBIT_MANIPULATOR_WEBVR).addMappings(\r\n {\r\n update: 'vrdisplayposechanged'\r\n },\r\n this\r\n );\r\n // default to disabled\r\n manager.setEnable(InputGroups.ORBIT_MANIPULATOR_WEBVR, false);\r\n },\r\n update: function(ev) {\r\n var q = ev.pose.orientation;\r\n if (q) {\r\n if (ev.sitToStandMatrix) {\r\n q = mat4.getRotation(tempQuat, ev.sitToStandMatrix);\r\n quat.mul(q, q, ev.pose.orientation);\r\n }\r\n\r\n this._quat[0] = q[0];\r\n this._quat[1] = -q[2];\r\n this._quat[2] = q[1];\r\n this._quat[3] = q[3];\r\n }\r\n\r\n var pos = ev.pose.position;\r\n if (pos) {\r\n if (ev.sitToStandMatrix) {\r\n pos = vec3.transformMat4(tempPos, pos, ev.sitToStandMatrix);\r\n }\r\n\r\n this._pos[0] = pos[0] * ev.worldFactor;\r\n this._pos[1] = -pos[2] * ev.worldFactor;\r\n this._pos[2] = pos[1] * ev.worldFactor;\r\n }\r\n this._manipulator.setPoseVR(this._quat, this._pos);\r\n }\r\n })\r\n);\r\n\r\nexport default OrbitManipulatorWebVRController;\r\n","var DelayInterpolator = function(size, delay, redrawCB) {\r\n this._current = new Float32Array(size);\r\n this._target = new Float32Array(size);\r\n this._delta = new Float32Array(size);\r\n this._delay = delay !== undefined ? delay : 0.15;\r\n this._reset = false;\r\n this._start = 0.0;\r\n this._redrawCB = redrawCB\r\n this.reset();\r\n};\r\n\r\nDelayInterpolator.prototype = {\r\n setDelay: function(delay) {\r\n this._delay = delay;\r\n },\r\n reset: function() {\r\n for (var i = 0, l = this._current.length; i < l; i++) {\r\n this._current[i] = this._target[i] = 0.0;\r\n }\r\n this._reset = true;\r\n },\r\n update: function(dt) {\r\n // assume 60 fps to be consistent with the old _delay values for backward compatibility\r\n // (otherwise we'd have to adjust the _delay values by multiplying to 60 )\r\n var dtDelay = Math.min(1.0, this._delay * dt * 60.0);\r\n for (var i = 0, l = this._current.length; i < l; i++) {\r\n var d = (this._target[i] - this._current[i]) * dtDelay;\r\n this._delta[i] = d;\r\n this._current[i] += d;\r\n }\r\n return this._delta;\r\n },\r\n set: function() {\r\n for (var i = 0, l = this._current.length; i < l; i++) {\r\n this._current[i] = this._target[i] = arguments[i];\r\n }\r\n this._reset = false;\r\n },\r\n isReset: function() {\r\n return this._reset;\r\n },\r\n getCurrent: function() {\r\n return this._current;\r\n },\r\n setTarget: function() {\r\n for (var i = 0, l = this._target.length; i < l; i++) {\r\n if (this._reset) {\r\n this._target[i] = this._current[i] = arguments[i];\r\n } else {\r\n this._target[i] = arguments[i];\r\n }\r\n }\r\n this._reset = false;\r\n },\r\n addTarget: function() {\r\n for (var i = 0; i < arguments.length; i++) {\r\n this._target[i] += arguments[i];\r\n }\r\n },\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n getDelta: function() {\r\n return this._delta;\r\n },\r\n getStart: function() {\r\n return this._start;\r\n },\r\n setStart: function(start) {\r\n this._start = start;\r\n }\r\n};\r\n\r\nexport default DelayInterpolator;\r\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Manipulator from './Manipulator';\r\nimport OrbitManipulatorDeviceOrientationController from './OrbitManipulatorDeviceOrientationController';\r\nimport OrbitManipulatorGamePadController from './OrbitManipulatorGamePadController';\r\nimport OrbitManipulatorHammerController from './OrbitManipulatorHammerController';\r\nimport OrbitManipulatorStandardMouseKeyboardController from './OrbitManipulatorStandardMouseKeyboardController';\r\nimport OrbitManipulatorWebVRController from './OrbitManipulatorWebVRController';\r\nimport DelayInterpolator from '../osgUtil/DelayInterpolator';\r\nimport Groups from '../osgViewer/input/InputConstants';\r\n\r\n/**\r\n * OrbitManipulator\r\n * @class\r\n */\r\nvar OrbitManipulator = function(options) {\r\n Manipulator.call(this, options);\r\n this._homePosition = vec3.create();\r\n this._frustum = {};\r\n this._redrawCB = options.redrawCB\r\n this.init();\r\n};\r\n\r\nOrbitManipulator.AvailableControllerList = [\r\n 'StandardMouseKeyboard',\r\n 'GamePad',\r\n 'Hammer',\r\n 'DeviceOrientation',\r\n 'WebVR'\r\n];\r\n\r\nOrbitManipulator.ControllerList = [\r\n 'StandardMouseKeyboard',\r\n 'GamePad',\r\n 'Hammer',\r\n 'DeviceOrientation',\r\n 'WebVR'\r\n];\r\n\r\nvar TWO_PI = 2 * Math.PI;\r\nvar lowerOrEqual = function(val, limit) {\r\n return val < limit + 0.00001;\r\n};\r\n\r\nvar MIN_ZOOM = 1e-4;\r\nvar MAX_ZOOM = Infinity;\r\n\r\n/** @lends OrbitManipulator.prototype */\r\nutils.createPrototypeObject(\r\n OrbitManipulator,\r\n utils.objectInherit(Manipulator.prototype, {\r\n init: function() {\r\n this._distance = 25.0;\r\n this._target = vec3.create();\r\n this._upz = vec3.fromValues(0.0, 0.0, 1.0);\r\n vec3.init(this._target);\r\n\r\n var rot1 = mat4.fromRotation(mat4.create(), -Math.PI, this._upz);\r\n var rot2 = mat4.fromRotation(\r\n mat4.create(),\r\n Math.PI / 10.0,\r\n vec3.fromValues(1.0, 0.0, 0.0)\r\n );\r\n this._rotation = mat4.create();\r\n mat4.mul(this._rotation, rot1, rot2);\r\n this._time = 0.0;\r\n\r\n this._vrMatrix = mat4.create();\r\n\r\n this._rotate = new DelayInterpolator(2, undefined, this._redrawCB);\r\n this._pan = new DelayInterpolator(2, undefined, this._redrawCB);\r\n this._zoom = new DelayInterpolator(1, undefined, this._redrawCB);\r\n\r\n this._minSpeed = 1e-4; // set a limit to pan/zoom speed\r\n this._scaleMouseMotion = 1.0;\r\n\r\n this._inverseMatrix = mat4.create();\r\n\r\n // distance at which we start pushing the target (so that we can still zoom)\r\n // with a very low _limitZoomIn, it's like a fps manipulator as long as you don't unzoom\r\n this._autoPushTarget = true;\r\n\r\n // pitch range [-PI/2, PI/2]\r\n this._limitPitchUp = Math.PI * 0.5 * 0.9;\r\n this._limitPitchDown = -this._limitPitchUp;\r\n\r\n // yaw range [-PI, PI]\r\n this._limitYawLeft = -Math.PI;\r\n this._limitYawRight = -this._limitYawLeft;\r\n\r\n this._limitZoomIn = MIN_ZOOM;\r\n this._limitZoomOut = MAX_ZOOM;\r\n\r\n this._constrainYaw = false;\r\n this._constrainPitch = false;\r\n this._constrainYaw = false;\r\n this._constrainZoom = false;\r\n\r\n this._panFactor = .002,\r\n this._rotationFactor = .1,\r\n this._zoomFactor = .1;\r\n\r\n // instance of controller\r\n var self = this;\r\n\r\n OrbitManipulator.ControllerList.forEach(function(value) {\r\n if (OrbitManipulator[value] !== undefined) {\r\n if (self._controllerList[value]) {\r\n self._controllerList[value].init();\r\n } else {\r\n self._controllerList[value] = new OrbitManipulator[value](self);\r\n }\r\n }\r\n });\r\n },\r\n\r\n setZoomFactor(e) {\r\n this._zoomFactor = .1 * e\r\n },\r\n \r\n setRotationFactor(e) {\r\n this._rotationFactor = .1 * e\r\n },\r\n\r\n setPanFactor(e) {\r\n this._panFactor = .002 * e\r\n }, \r\n \r\n setLimitPitchUp(up) {\r\n this._limitPitchUp = up;\r\n },\r\n \r\n setLimitPitchDown: function(down) {\r\n this._limitPitchDown = down;\r\n },\r\n setLimitYawLeft: function(left) {\r\n this._limitYawLeft = left;\r\n this._constrainYaw = true;\r\n },\r\n setLimitYawRight: function(right) {\r\n this._limitYawRight = right;\r\n this._constrainYaw = true;\r\n },\r\n setLimitZoomOut: function(zoomOut) {\r\n this._limitZoomOut = zoomOut;\r\n this._constrainZoom = true;\r\n },\r\n setLimitZoomIn: function(zoomIn) {\r\n this._limitZoomIn = zoomIn;\r\n this._constrainZoom = true;\r\n },\r\n\r\n setConstrainPitch: function(limit) {\r\n this._constrainPitch = limit;\r\n this._previousPitch = undefined;\r\n },\r\n\r\n isConstrainPitch: function() {\r\n return this._constrainPitch;\r\n },\r\n\r\n setConstrainYaw: function(constrain) {\r\n this._constrainYaw = constrain;\r\n this._previousYaw = undefined;\r\n },\r\n\r\n isConstrainYaw: function() {\r\n return this._constrainYaw;\r\n },\r\n\r\n setConstrainZoom: function(limit) {\r\n this._constrainZoom = limit;\r\n },\r\n\r\n isConstrainZoom: function() {\r\n return this._constrainZoom;\r\n },\r\n\r\n setDelay: function(dt) {\r\n this._rotate.setDelay(dt);\r\n this._pan.setDelay(dt);\r\n this._zoom.setDelay(dt);\r\n },\r\n reset: function() {\r\n this.init();\r\n },\r\n setTarget: function(target) {\r\n vec3.copy(this._target, target);\r\n var eyePos = vec3.create();\r\n this.getEyePosition(eyePos);\r\n this._distance = vec3.distance(target, eyePos);\r\n },\r\n setEyePosition: (function() {\r\n var f = vec3.create();\r\n var s = vec3.create();\r\n var u = vec3.create();\r\n return function(eye) {\r\n var result = this._rotation;\r\n var center = this._target;\r\n\r\n vec3.sub(f, eye, center);\r\n vec3.normalize(f, f);\r\n\r\n vec3.cross(s, f, this._upz);\r\n vec3.normalize(s, s);\r\n\r\n vec3.cross(u, s, f);\r\n vec3.normalize(u, u);\r\n\r\n // s[0], f[0], u[0], 0.0,\r\n // s[1], f[1], u[1], 0.0,\r\n // s[2], f[2], u[2], 0.0,\r\n // 0, 0, 0, 1.0\r\n result[0] = s[0];\r\n result[1] = f[0];\r\n result[2] = u[0];\r\n result[3] = 0.0;\r\n result[4] = s[1];\r\n result[5] = f[1];\r\n result[6] = u[1];\r\n result[7] = 0.0;\r\n result[8] = s[2];\r\n result[9] = f[2];\r\n result[10] = u[2];\r\n result[11] = 0.0;\r\n result[12] = 0;\r\n result[13] = 0;\r\n result[14] = 0;\r\n result[15] = 1.0;\r\n\r\n this._distance = vec3.distance(center, eye);\r\n };\r\n })(),\r\n\r\n setEnable: function(enabled) {\r\n this.getInputManager().setEnable(Groups.ORBIT_MANIPULATOR, enabled);\r\n },\r\n\r\n computeHomePosition: function(boundStrategy) {\r\n var bs = this.getHomeBoundingSphere(boundStrategy);\r\n if (!bs || !bs.valid()) return;\r\n\r\n this.setDistance(this.getHomeDistance(bs));\r\n this.setTarget(bs.center());\r\n },\r\n\r\n getHomePosition: function() {\r\n if (this._node !== undefined) {\r\n var target = this._target;\r\n var distance = this.getDistance();\r\n\r\n this.computeEyePosition(target, distance, this._homePosition);\r\n }\r\n return this._homePosition;\r\n },\r\n\r\n setMinSpeed: function(s) {\r\n this._minSpeed = s;\r\n },\r\n getMinSpeed: function() {\r\n return this._minSpeed;\r\n },\r\n\r\n setDistance: function(d) {\r\n this._distance = d;\r\n },\r\n getDistance: function() {\r\n return this._distance;\r\n },\r\n\r\n getSpeedFactor: function() {\r\n return Math.max(this._distance, this._minSpeed);\r\n },\r\n computePan: (function() {\r\n var inv = mat4.create();\r\n var x = vec3.create();\r\n var y = vec3.create();\r\n return function(dx, dy) {\r\n var proj = this._camera.getProjectionMatrix();\r\n // modulate panning speed with verticalFov value\r\n // if it's an orthographic we don't change the panning speed\r\n // TODO : manipulators in osgjs don't support well true orthographic camera anyway because they\r\n // manage the view matrix (and you need to edit the projection matrix to 'zoom' for true ortho camera)\r\n var vFov = proj[15] === 1 ? 1.0 : 2.0 / proj[5];\r\n var speed = this.getSpeedFactor() * vFov;\r\n dy *= speed;\r\n dx *= speed;\r\n\r\n mat4.invert(inv, this._rotation);\r\n x[0] = inv[0];\r\n x[1] = inv[1];\r\n x[2] = inv[2];\r\n vec3.normalize(x, x);\r\n\r\n y[0] = inv[8];\r\n y[1] = inv[9];\r\n y[2] = inv[10];\r\n vec3.normalize(y, y);\r\n\r\n vec3.scale(x, x, -dx);\r\n vec3.scale(y, y, dy);\r\n vec3.add(this._target, this._target, x);\r\n vec3.add(this._target, this._target, y);\r\n };\r\n })(),\r\n computeRotation: (function() {\r\n var rightDir = vec3.fromValues(1.0, 0.0, 0.0);\r\n\r\n return function(dx, dy) {\r\n var prevPitch = Math.atan(-this._rotation[6] / this._rotation[5]);\r\n if (isNaN(prevPitch)) {\r\n prevPitch = 0.0;\r\n }\r\n var pitch = this._computePitch(prevPitch, dy);\r\n\r\n var deltaYaw = dx / 10.0;\r\n var previousYaw = Math.atan2(this._rotation[4], this._rotation[0]);\r\n var yaw = this._computeYaw(previousYaw, deltaYaw);\r\n mat4.fromRotation(this._rotation, -pitch, rightDir);\r\n mat4.rotate(this._rotation, this._rotation, -yaw, this._upz);\r\n };\r\n })(),\r\n\r\n _computePitch: function(prevPitch, dy) {\r\n var pitch = prevPitch + dy / 10.0;\r\n return Math.min(Math.max(pitch, this._limitPitchDown), this._limitPitchUp);\r\n },\r\n\r\n _computeYaw: function(previousYaw, deltaYaw) {\r\n var yaw = previousYaw + deltaYaw;\r\n var left = this._limitYawLeft;\r\n var right = this._limitYawRight;\r\n\r\n if (this._constrainYaw) {\r\n if (right < left) {\r\n if (yaw > Math.PI) {\r\n previousYaw -= TWO_PI;\r\n yaw -= TWO_PI;\r\n }\r\n if (yaw < -Math.PI) {\r\n previousYaw += TWO_PI;\r\n yaw += TWO_PI;\r\n }\r\n }\r\n\r\n if (deltaYaw === 0) {\r\n var isOutsideLimit = false;\r\n if (left > right) isOutsideLimit = yaw < left && yaw > right;\r\n else isOutsideLimit = yaw < left || yaw > right;\r\n if (isOutsideLimit)\r\n yaw = Math.abs(yaw - left) > Math.abs(yaw - right) ? right : left;\r\n }\r\n\r\n if (deltaYaw > 0.0 && lowerOrEqual(previousYaw, right) && yaw > right) {\r\n yaw = right;\r\n } else if (deltaYaw < 0.0 && lowerOrEqual(left, previousYaw) && yaw < left) {\r\n yaw = left;\r\n }\r\n }\r\n return yaw;\r\n },\r\n\r\n computeZoom: function(dz) {\r\n this.zoom(dz);\r\n },\r\n\r\n setAutoPushTarget: function(bool) {\r\n this._autoPushTarget = bool;\r\n },\r\n\r\n zoom: (function() {\r\n var dir = vec3.create();\r\n return function(ratio) {\r\n var newValue = this._distance + this.getSpeedFactor() * (ratio - 1.0);\r\n\r\n if (this._autoPushTarget && newValue < this._limitZoomIn) {\r\n // push the target instead of zooming on it\r\n vec3.sub(dir, this._target, this.getEyePosition(dir));\r\n vec3.normalize(dir, dir);\r\n vec3.scale(dir, dir, this._limitZoomIn - newValue);\r\n vec3.add(this._target, this._target, dir);\r\n }\r\n\r\n var min = this._constrainZoom ? this._limitZoomIn : MIN_ZOOM;\r\n var max = this._constrainZoom ? this._limitZoomOut : MAX_ZOOM;\r\n this._distance = Math.max(min, Math.min(max, newValue));\r\n };\r\n })(),\r\n\r\n getRotateInterpolator: function() {\r\n return this._rotate;\r\n },\r\n getPanInterpolator: function() {\r\n return this._pan;\r\n },\r\n getZoomInterpolator: function() {\r\n return this._zoom;\r\n },\r\n getTarget: function(target) {\r\n return vec3.copy(target, this._target);\r\n },\r\n getEyePosition: function(eye) {\r\n this.computeEyePosition(this._target, this._distance, eye);\r\n return eye;\r\n },\r\n\r\n computeEyePosition: (function() {\r\n var tmpDist = vec3.create();\r\n var tmpInverse = mat4.create();\r\n return function(target, distance, eye) {\r\n mat4.invert(tmpInverse, this._rotation);\r\n tmpDist[1] = distance;\r\n vec3.transformMat4(eye, tmpDist, tmpInverse);\r\n vec3.add(eye, target, eye);\r\n };\r\n })(),\r\n\r\n update: (function() {\r\n var eye = vec3.create();\r\n return function(nv) {\r\n var dt = nv.getFrameStamp().getDeltaTime();\r\n\r\n var delta;\r\n\r\n delta = this._rotate.update(dt);\r\n this.computeRotation(\r\n -delta[0] * this._rotationFactor * this._scaleMouseMotion,\r\n -delta[1] * this._rotationFactor * this._scaleMouseMotion\r\n );\r\n\r\n var panFactor = 0.002;\r\n delta = this._pan.update(dt);\r\n this.computePan(-delta[0] * panFactor, -delta[1] * panFactor);\r\n\r\n delta = this._zoom.update(dt);\r\n this.computeZoom(1.0 + delta[0] / 10.0);\r\n\r\n var target = this._target;\r\n var distance = this._distance;\r\n\r\n /* 1. Works but bypass other manipulators */\r\n // mat4.copy( this._inverseMatrix , this._vrMatrix );\r\n\r\n /* 2. Works but gets broken by other manipulators */\r\n mat4.invert(this._inverseMatrix, this._rotation);\r\n mat4.mul(this._inverseMatrix, this._vrMatrix, this._inverseMatrix);\r\n\r\n /* 3. Doesnt' work */\r\n // mat4.mul( this._vrMatrix, this._vrMatrix, this._rotation );\r\n // mat4.invert( this._inverseMatrix, this._vrMatrix );\r\n\r\n vec3.set(eye, 0.0, distance, 0.0);\r\n vec3.transformMat4(eye, eye, this._inverseMatrix);\r\n\r\n mat4.lookAt(this._inverseMatrix, vec3.add(eye, target, eye), target, this._upz);\r\n };\r\n })(),\r\n\r\n setPoseVR: function(q /*, pos*/) {\r\n mat4.fromQuat(this._vrMatrix, q);\r\n // this._vrMatrix[ 12 ] = pos[ 0 ];\r\n // this._vrMatrix[ 13 ] = pos[ 1 ];\r\n // this._vrMatrix[ 14 ] = pos[ 2 ];\r\n }\r\n }),\r\n 'osgGA',\r\n 'OrbitManipulator'\r\n);\r\n\r\nOrbitManipulator.DeviceOrientation = OrbitManipulatorDeviceOrientationController;\r\nOrbitManipulator.GamePad = OrbitManipulatorGamePadController;\r\nOrbitManipulator.Hammer = OrbitManipulatorHammerController;\r\nOrbitManipulator.WebVR = OrbitManipulatorWebVRController;\r\nOrbitManipulator.StandardMouseKeyboard = OrbitManipulatorStandardMouseKeyboardController;\r\n\r\nexport default OrbitManipulator;\r\n","// jshint ignore: start\r\n\r\n/*\r\n ** Copyright (c) 2012 The Khronos Group Inc.\r\n **\r\n ** Permission is hereby granted, free of charge, to any person obtaining a\r\n ** copy of this software and/or associated documentation files (the\r\n ** \"Materials\"), to deal in the Materials without restriction, including\r\n ** without limitation the rights to use, copy, modify, merge, publish,\r\n ** distribute, sublicense, and/or sell copies of the Materials, and to\r\n ** permit persons to whom the Materials are furnished to do so, subject to\r\n ** the following conditions:\r\n **\r\n ** The above copyright notice and this permission notice shall be included\r\n ** in all copies or substantial portions of the Materials.\r\n **\r\n ** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\n ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\n ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\n ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\r\n */\r\n\r\n// Various functions for helping debug WebGL apps.\r\n\r\nvar WebGLDebugUtils = (function() {\r\n /**\r\n * Wrapped logging function.\r\n * @param {string} msg Message to log.\r\n */\r\n var log = function(msg) {\r\n if (window.console && window.console.log) {\r\n window.console.log(msg);\r\n }\r\n };\r\n\r\n /**\r\n * Wrapped error logging function.\r\n * @param {string} msg Message to log.\r\n */\r\n var error = function(msg) {\r\n if (window.console && window.console.error) {\r\n window.console.error(msg);\r\n } else {\r\n log(msg);\r\n }\r\n };\r\n\r\n /**\r\n * Which arguments are enums based on the number of arguments to the function.\r\n * So\r\n * 'texImage2D': {\r\n * 9: { 0:true, 2:true, 6:true, 7:true },\r\n * 6: { 0:true, 2:true, 3:true, 4:true },\r\n * },\r\n *\r\n * means if there are 9 arguments then 6 and 7 are enums, if there are 6\r\n * arguments 3 and 4 are enums\r\n *\r\n * @type {!Object.<number, !Object.<number, string>}\r\n */\r\n var glValidEnumContexts = {\r\n // Generic setters and getters\r\n\r\n enable: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n disable: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n getParameter: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n\r\n // Rendering\r\n\r\n drawArrays: {\r\n 3: {\r\n 0: true\r\n }\r\n },\r\n drawElements: {\r\n 4: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n\r\n // Shaders\r\n\r\n createShader: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n getShaderParameter: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n getProgramParameter: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n getShaderPrecisionFormat: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n\r\n // Vertex attributes\r\n\r\n getVertexAttrib: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n vertexAttribPointer: {\r\n 6: {\r\n 2: true\r\n }\r\n },\r\n\r\n // Textures\r\n\r\n bindTexture: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n activeTexture: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n getTexParameter: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n texParameterf: {\r\n 3: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n texParameteri: {\r\n 3: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n // texImage2D and texSubImage2D are defined below with WebGL 2 entrypoints\r\n copyTexImage2D: {\r\n 8: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n copyTexSubImage2D: {\r\n 8: {\r\n 0: true\r\n }\r\n },\r\n generateMipmap: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n // compressedTexImage2D and compressedTexSubImage2D are defined below with WebGL 2 entrypoints\r\n\r\n // Buffer objects\r\n\r\n bindBuffer: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n // bufferData and bufferSubData are defined below with WebGL 2 entrypoints\r\n getBufferParameter: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n\r\n // Renderbuffers and framebuffers\r\n\r\n pixelStorei: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n // readPixels is defined below with WebGL 2 entrypoints\r\n bindRenderbuffer: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n bindFramebuffer: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n checkFramebufferStatus: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n framebufferRenderbuffer: {\r\n 4: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n framebufferTexture2D: {\r\n 5: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n getFramebufferAttachmentParameter: {\r\n 3: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n getRenderbufferParameter: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n renderbufferStorage: {\r\n 4: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n\r\n // Frame buffer operations (clear, blend, depth test, stencil)\r\n\r\n clear: {\r\n 1: {\r\n 0: {\r\n enumBitwiseOr: ['COLOR_BUFFER_BIT', 'DEPTH_BUFFER_BIT', 'STENCIL_BUFFER_BIT']\r\n }\r\n }\r\n },\r\n depthFunc: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n blendFunc: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n blendFuncSeparate: {\r\n 4: {\r\n 0: true,\r\n 1: true,\r\n 2: true,\r\n 3: true\r\n }\r\n },\r\n blendEquation: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n blendEquationSeparate: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n stencilFunc: {\r\n 3: {\r\n 0: true\r\n }\r\n },\r\n stencilFuncSeparate: {\r\n 4: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n stencilMaskSeparate: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n stencilOp: {\r\n 3: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n stencilOpSeparate: {\r\n 4: {\r\n 0: true,\r\n 1: true,\r\n 2: true,\r\n 3: true\r\n }\r\n },\r\n\r\n // Culling\r\n\r\n cullFace: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n frontFace: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n\r\n // ANGLE_instanced_arrays extension\r\n\r\n drawArraysInstancedANGLE: {\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n drawElementsInstancedANGLE: {\r\n 5: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n\r\n // EXT_blend_minmax extension\r\n\r\n blendEquationEXT: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n\r\n // WebGL 2 Buffer objects\r\n\r\n bufferData: {\r\n 3: {\r\n 0: true,\r\n 2: true\r\n }, // WebGL 1\r\n 4: {\r\n 0: true,\r\n 2: true\r\n }, // WebGL 2\r\n 5: {\r\n 0: true,\r\n 2: true\r\n } // WebGL 2\r\n },\r\n bufferSubData: {\r\n 3: {\r\n 0: true\r\n }, // WebGL 1\r\n 4: {\r\n 0: true\r\n }, // WebGL 2\r\n 5: {\r\n 0: true\r\n } // WebGL 2\r\n },\r\n copyBufferSubData: {\r\n 5: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n getBufferSubData: {\r\n 3: {\r\n 0: true\r\n },\r\n 4: {\r\n 0: true\r\n },\r\n 5: {\r\n 0: true\r\n }\r\n },\r\n\r\n // WebGL 2 Framebuffer objects\r\n\r\n blitFramebuffer: {\r\n 10: {\r\n 8: {\r\n enumBitwiseOr: ['COLOR_BUFFER_BIT', 'DEPTH_BUFFER_BIT', 'STENCIL_BUFFER_BIT']\r\n },\r\n 9: true\r\n }\r\n },\r\n framebufferTextureLayer: {\r\n 5: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n invalidateFramebuffer: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n invalidateSubFramebuffer: {\r\n 6: {\r\n 0: true\r\n }\r\n },\r\n readBuffer: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n\r\n // WebGL 2 Renderbuffer objects\r\n\r\n getInternalformatParameter: {\r\n 3: {\r\n 0: true,\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n renderbufferStorageMultisample: {\r\n 5: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n\r\n // WebGL 2 Texture objects\r\n\r\n texStorage2D: {\r\n 5: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n texStorage3D: {\r\n 6: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n texImage2D: {\r\n 9: {\r\n 0: true,\r\n 2: true,\r\n 6: true,\r\n 7: true\r\n }, // WebGL 1 & 2\r\n 6: {\r\n 0: true,\r\n 2: true,\r\n 3: true,\r\n 4: true\r\n }, // WebGL 1\r\n 10: {\r\n 0: true,\r\n 2: true,\r\n 6: true,\r\n 7: true\r\n } // WebGL 2\r\n },\r\n texImage3D: {\r\n 10: {\r\n 0: true,\r\n 2: true,\r\n 7: true,\r\n 8: true\r\n },\r\n 11: {\r\n 0: true,\r\n 2: true,\r\n 7: true,\r\n 8: true\r\n }\r\n },\r\n texSubImage2D: {\r\n 9: {\r\n 0: true,\r\n 6: true,\r\n 7: true\r\n }, // WebGL 1 & 2\r\n 7: {\r\n 0: true,\r\n 4: true,\r\n 5: true\r\n }, // WebGL 1\r\n 10: {\r\n 0: true,\r\n 6: true,\r\n 7: true\r\n } // WebGL 2\r\n },\r\n texSubImage3D: {\r\n 11: {\r\n 0: true,\r\n 8: true,\r\n 9: true\r\n },\r\n 12: {\r\n 0: true,\r\n 8: true,\r\n 9: true\r\n }\r\n },\r\n copyTexSubImage3D: {\r\n 9: {\r\n 0: true\r\n }\r\n },\r\n compressedTexImage2D: {\r\n 7: {\r\n 0: true,\r\n 2: true\r\n }, // WebGL 1 & 2\r\n 8: {\r\n 0: true,\r\n 2: true\r\n }, // WebGL 2\r\n 9: {\r\n 0: true,\r\n 2: true\r\n } // WebGL 2\r\n },\r\n compressedTexImage3D: {\r\n 8: {\r\n 0: true,\r\n 2: true\r\n },\r\n 9: {\r\n 0: true,\r\n 2: true\r\n },\r\n 10: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n compressedTexSubImage2D: {\r\n 8: {\r\n 0: true,\r\n 6: true\r\n }, // WebGL 1 & 2\r\n 9: {\r\n 0: true,\r\n 6: true\r\n }, // WebGL 2\r\n 10: {\r\n 0: true,\r\n 6: true\r\n } // WebGL 2\r\n },\r\n compressedTexSubImage3D: {\r\n 10: {\r\n 0: true,\r\n 8: true\r\n },\r\n 11: {\r\n 0: true,\r\n 8: true\r\n },\r\n 12: {\r\n 0: true,\r\n 8: true\r\n }\r\n },\r\n\r\n // WebGL 2 Vertex attribs\r\n\r\n vertexAttribIPointer: {\r\n 5: {\r\n 2: true\r\n }\r\n },\r\n\r\n // WebGL 2 Writing to the drawing buffer\r\n\r\n drawArraysInstanced: {\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n drawElementsInstanced: {\r\n 5: {\r\n 0: true,\r\n 2: true\r\n }\r\n },\r\n drawRangeElements: {\r\n 6: {\r\n 0: true,\r\n 4: true\r\n }\r\n },\r\n\r\n // WebGL 2 Reading back pixels\r\n\r\n readPixels: {\r\n 7: {\r\n 4: true,\r\n 5: true\r\n }, // WebGL 1 & 2\r\n 8: {\r\n 4: true,\r\n 5: true\r\n } // WebGL 2\r\n },\r\n\r\n // WebGL 2 Multiple Render Targets\r\n\r\n clearBufferfv: {\r\n 3: {\r\n 0: true\r\n },\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n clearBufferiv: {\r\n 3: {\r\n 0: true\r\n },\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n clearBufferuiv: {\r\n 3: {\r\n 0: true\r\n },\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n clearBufferfi: {\r\n 4: {\r\n 0: true\r\n }\r\n },\r\n\r\n // WebGL 2 Query objects\r\n\r\n beginQuery: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n endQuery: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n getQuery: {\r\n 2: {\r\n 0: true,\r\n 1: true\r\n }\r\n },\r\n getQueryParameter: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n\r\n // WebGL 2 Sampler objects\r\n\r\n samplerParameteri: {\r\n 3: {\r\n 1: true,\r\n 2: true\r\n }\r\n },\r\n samplerParameterf: {\r\n 3: {\r\n 1: true\r\n }\r\n },\r\n getSamplerParameter: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n\r\n // WebGL 2 Sync objects\r\n\r\n fenceSync: {\r\n 2: {\r\n 0: true,\r\n 1: {\r\n enumBitwiseOr: []\r\n }\r\n }\r\n },\r\n clientWaitSync: {\r\n 3: {\r\n 1: {\r\n enumBitwiseOr: ['SYNC_FLUSH_COMMANDS_BIT']\r\n }\r\n }\r\n },\r\n waitSync: {\r\n 3: {\r\n 1: {\r\n enumBitwiseOr: []\r\n }\r\n }\r\n },\r\n getSyncParameter: {\r\n 2: {\r\n 1: true\r\n }\r\n },\r\n\r\n // WebGL 2 Transform Feedback\r\n\r\n bindTransformFeedback: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n beginTransformFeedback: {\r\n 1: {\r\n 0: true\r\n }\r\n },\r\n transformFeedbackVaryings: {\r\n 3: {\r\n 2: true\r\n }\r\n },\r\n\r\n // WebGL2 Uniform Buffer Objects and Transform Feedback Buffers\r\n\r\n bindBufferBase: {\r\n 3: {\r\n 0: true\r\n }\r\n },\r\n bindBufferRange: {\r\n 5: {\r\n 0: true\r\n }\r\n },\r\n getIndexedParameter: {\r\n 2: {\r\n 0: true\r\n }\r\n },\r\n getActiveUniforms: {\r\n 3: {\r\n 2: true\r\n }\r\n },\r\n getActiveUniformBlockParameter: {\r\n 3: {\r\n 2: true\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Map of numbers to names.\r\n * @type {Object}\r\n */\r\n var glEnums = null;\r\n\r\n /**\r\n * Map of names to numbers.\r\n * @type {Object}\r\n */\r\n var enumStringToValue = null;\r\n\r\n /**\r\n * Initializes this module. Safe to call more than once.\r\n * @param {!WebGLRenderingContext} ctx A WebGL context. If\r\n * you have more than one context it doesn't matter which one\r\n * you pass in, it is only used to pull out constants.\r\n */\r\n function init(ctx) {\r\n if (glEnums == null) {\r\n glEnums = {};\r\n enumStringToValue = {};\r\n for (var propertyName in ctx) {\r\n if (typeof ctx[propertyName] === 'number') {\r\n glEnums[ctx[propertyName]] = propertyName;\r\n enumStringToValue[propertyName] = ctx[propertyName];\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Checks the utils have been initialized.\r\n */\r\n function checkInit() {\r\n if (glEnums == null) {\r\n throw 'WebGLDebugUtils.init(ctx) not called';\r\n }\r\n }\r\n\r\n /**\r\n * Returns true or false if value matches any WebGL enum\r\n * @param {*} value Value to check if it might be an enum.\r\n * @return {boolean} True if value matches one of the WebGL defined enums\r\n */\r\n function mightBeEnum(value) {\r\n checkInit();\r\n return glEnums[value] !== undefined;\r\n }\r\n\r\n /**\r\n * Gets an string version of an WebGL enum.\r\n *\r\n * Example:\r\n * var str = WebGLDebugUtil.glEnumToString(ctx.getError());\r\n *\r\n * @param {number} value Value to return an enum for\r\n * @return {string} The string version of the enum.\r\n */\r\n function glEnumToString(value) {\r\n checkInit();\r\n var name = glEnums[value];\r\n return name !== undefined\r\n ? 'gl.' + name\r\n : '/*UNKNOWN WebGL ENUM*/ 0x' + value.toString(16) + '';\r\n }\r\n\r\n /**\r\n * Returns the string version of a WebGL argument.\r\n * Attempts to convert enum arguments to strings.\r\n * @param {string} functionName the name of the WebGL function.\r\n * @param {number} numArgs the number of arguments passed to the function.\r\n * @param {number} argumentIndx the index of the argument.\r\n * @param {*} value The value of the argument.\r\n * @return {string} The value as a string.\r\n */\r\n function glFunctionArgToString(functionName, numArgs, argumentIndex, value) {\r\n var funcInfo = glValidEnumContexts[functionName];\r\n if (funcInfo !== undefined) {\r\n var funcInfo = funcInfo[numArgs];\r\n if (funcInfo !== undefined) {\r\n if (funcInfo[argumentIndex]) {\r\n if (\r\n typeof funcInfo[argumentIndex] === 'object' &&\r\n funcInfo[argumentIndex]['enumBitwiseOr'] !== undefined\r\n ) {\r\n var enums = funcInfo[argumentIndex]['enumBitwiseOr'];\r\n var orResult = 0;\r\n var orEnums = [];\r\n for (var i = 0; i < enums.length; ++i) {\r\n var enumValue = enumStringToValue[enums[i]];\r\n if ((value & enumValue) !== 0) {\r\n orResult |= enumValue;\r\n orEnums.push(glEnumToString(enumValue));\r\n }\r\n }\r\n if (orResult === value) {\r\n return orEnums.join(' | ');\r\n } else {\r\n return glEnumToString(value);\r\n }\r\n } else {\r\n return glEnumToString(value);\r\n }\r\n }\r\n }\r\n }\r\n if (value === null) {\r\n return 'null';\r\n } else if (value === undefined) {\r\n return 'undefined';\r\n } else {\r\n return value.toString();\r\n }\r\n }\r\n\r\n /**\r\n * Converts the arguments of a WebGL function to a string.\r\n * Attempts to convert enum arguments to strings.\r\n *\r\n * @param {string} functionName the name of the WebGL function.\r\n * @param {number} args The arguments.\r\n * @return {string} The arguments as a string.\r\n */\r\n function glFunctionArgsToString(functionName, args) {\r\n // apparently we can't do args.join(\",\");\r\n var argStr = '';\r\n var numArgs = args.length;\r\n for (var ii = 0; ii < numArgs; ++ii) {\r\n argStr +=\r\n (ii == 0 ? '' : ', ') + glFunctionArgToString(functionName, numArgs, ii, args[ii]);\r\n }\r\n return argStr;\r\n }\r\n\r\n function makePropertyWrapper(wrapper, original, propertyName) {\r\n //log(\"wrap prop: \" + propertyName);\r\n wrapper.__defineGetter__(propertyName, function() {\r\n return original[propertyName];\r\n });\r\n // TODO(gmane): this needs to handle properties that take more than\r\n // one value?\r\n wrapper.__defineSetter__(propertyName, function(value) {\r\n //log(\"set: \" + propertyName);\r\n original[propertyName] = value;\r\n });\r\n }\r\n\r\n // Makes a function that calls a function on another object.\r\n function makeFunctionWrapper(original, functionName) {\r\n //log(\"wrap fn: \" + functionName);\r\n var f = original[functionName];\r\n return function() {\r\n //log(\"call: \" + functionName);\r\n var result = f.apply(original, arguments);\r\n return result;\r\n };\r\n }\r\n\r\n /**\r\n * Given a WebGL context returns a wrapped context that calls\r\n * gl.getError after every command and calls a function if the\r\n * result is not gl.NO_ERROR.\r\n *\r\n * @param {!WebGLRenderingContext} ctx The webgl context to\r\n * wrap.\r\n * @param {!function(err, funcName, args): void} opt_onErrorFunc\r\n * The function to call when gl.getError returns an\r\n * error. If not specified the default function calls\r\n * console.log with a message.\r\n * @param {!function(funcName, args): void} opt_onFunc The\r\n * function to call when each webgl function is called.\r\n * You can use this to log all calls for example.\r\n * @param {!WebGLRenderingContext} opt_err_ctx The webgl context\r\n * to call getError on if different than ctx.\r\n */\r\n function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc, opt_err_ctx) {\r\n opt_err_ctx = opt_err_ctx || ctx;\r\n init(ctx);\r\n opt_onErrorFunc =\r\n opt_onErrorFunc ||\r\n function(err, functionName, args) {\r\n // apparently we can't do args.join(\",\");\r\n var argStr = '';\r\n var numArgs = args.length;\r\n for (var ii = 0; ii < numArgs; ++ii) {\r\n argStr +=\r\n (ii == 0 ? '' : ', ') +\r\n glFunctionArgToString(functionName, numArgs, ii, args[ii]);\r\n }\r\n error(\r\n 'WebGL error ' +\r\n glEnumToString(err) +\r\n ' in ' +\r\n functionName +\r\n '(' +\r\n argStr +\r\n ')'\r\n );\r\n };\r\n\r\n // Holds booleans for each GL error so after we get the error ourselves\r\n // we can still return it to the client app.\r\n var glErrorShadow = {};\r\n\r\n // Makes a function that calls a WebGL function and then calls getError.\r\n function makeErrorWrapper(ctx, functionName) {\r\n return function() {\r\n if (opt_onFunc) {\r\n opt_onFunc(functionName, arguments);\r\n }\r\n var result = ctx[functionName].apply(ctx, arguments);\r\n var err = opt_err_ctx.getError();\r\n if (err != 0) {\r\n glErrorShadow[err] = true;\r\n opt_onErrorFunc(err, functionName, arguments);\r\n }\r\n return result;\r\n };\r\n }\r\n\r\n // Make a an object that has a copy of every property of the WebGL context\r\n // but wraps all functions.\r\n var wrapper = {};\r\n for (var propertyName in ctx) {\r\n if (typeof ctx[propertyName] === 'function') {\r\n if (propertyName != 'getExtension') {\r\n wrapper[propertyName] = makeErrorWrapper(ctx, propertyName);\r\n } else {\r\n var wrapped = makeErrorWrapper(ctx, propertyName);\r\n wrapper[propertyName] = function() {\r\n var result = wrapped.apply(ctx, arguments);\r\n if (!result) {\r\n return null;\r\n }\r\n return makeDebugContext(result, opt_onErrorFunc, opt_onFunc, opt_err_ctx);\r\n };\r\n }\r\n } else {\r\n makePropertyWrapper(wrapper, ctx, propertyName);\r\n }\r\n }\r\n\r\n // Override the getError function with one that returns our saved results.\r\n wrapper.getError = function() {\r\n for (var err in glErrorShadow) {\r\n if (glErrorShadow.hasOwnProperty(err)) {\r\n if (glErrorShadow[err]) {\r\n glErrorShadow[err] = false;\r\n return err;\r\n }\r\n }\r\n }\r\n return ctx.NO_ERROR;\r\n };\r\n\r\n return wrapper;\r\n }\r\n\r\n function resetToInitialState(ctx) {\r\n var isWebGL2RenderingContext = !!ctx.createTransformFeedback;\r\n\r\n if (isWebGL2RenderingContext) {\r\n ctx.bindVertexArray(null);\r\n }\r\n\r\n var numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS);\r\n var tmp = ctx.createBuffer();\r\n ctx.bindBuffer(ctx.ARRAY_BUFFER, tmp);\r\n for (var ii = 0; ii < numAttribs; ++ii) {\r\n ctx.disableVertexAttribArray(ii);\r\n ctx.vertexAttribPointer(ii, 4, ctx.FLOAT, false, 0, 0);\r\n ctx.vertexAttrib1f(ii, 0);\r\n if (isWebGL2RenderingContext) {\r\n ctx.vertexAttribDivisor(ii, 0);\r\n }\r\n }\r\n ctx.deleteBuffer(tmp);\r\n\r\n var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);\r\n for (var ii = 0; ii < numTextureUnits; ++ii) {\r\n ctx.activeTexture(ctx.TEXTURE0 + ii);\r\n ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);\r\n ctx.bindTexture(ctx.TEXTURE_2D, null);\r\n if (isWebGL2RenderingContext) {\r\n ctx.bindTexture(ctx.TEXTURE_2D_ARRAY, null);\r\n ctx.bindTexture(ctx.TEXTURE_3D, null);\r\n ctx.bindSampler(ii, null);\r\n }\r\n }\r\n\r\n ctx.activeTexture(ctx.TEXTURE0);\r\n ctx.useProgram(null);\r\n ctx.bindBuffer(ctx.ARRAY_BUFFER, null);\r\n ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);\r\n ctx.bindFramebuffer(ctx.FRAMEBUFFER, null);\r\n ctx.bindRenderbuffer(ctx.RENDERBUFFER, null);\r\n ctx.disable(ctx.BLEND);\r\n ctx.disable(ctx.CULL_FACE);\r\n ctx.disable(ctx.DEPTH_TEST);\r\n ctx.disable(ctx.DITHER);\r\n ctx.disable(ctx.SCISSOR_TEST);\r\n ctx.blendColor(0, 0, 0, 0);\r\n ctx.blendEquation(ctx.FUNC_ADD);\r\n ctx.blendFunc(ctx.ONE, ctx.ZERO);\r\n ctx.clearColor(0, 0, 0, 0);\r\n ctx.clearDepth(1);\r\n ctx.clearStencil(-1);\r\n ctx.colorMask(true, true, true, true);\r\n ctx.cullFace(ctx.BACK);\r\n ctx.depthFunc(ctx.LESS);\r\n ctx.depthMask(true);\r\n ctx.depthRange(0, 1);\r\n ctx.frontFace(ctx.CCW);\r\n ctx.hint(ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE);\r\n ctx.lineWidth(1);\r\n ctx.pixelStorei(ctx.PACK_ALIGNMENT, 4);\r\n ctx.pixelStorei(ctx.UNPACK_ALIGNMENT, 4);\r\n ctx.pixelStorei(ctx.UNPACK_FLIP_Y_WEBGL, false);\r\n ctx.pixelStorei(ctx.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);\r\n // TODO: Delete this IF.\r\n if (ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL) {\r\n ctx.pixelStorei(ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL, ctx.BROWSER_DEFAULT_WEBGL);\r\n }\r\n ctx.polygonOffset(0, 0);\r\n ctx.sampleCoverage(1, false);\r\n ctx.scissor(0, 0, ctx.canvas.width, ctx.canvas.height);\r\n ctx.stencilFunc(ctx.ALWAYS, 0, 0xffffffff);\r\n ctx.stencilMask(0xffffffff);\r\n ctx.stencilOp(ctx.KEEP, ctx.KEEP, ctx.KEEP);\r\n ctx.viewport(0, 0, ctx.canvas.width, ctx.canvas.height);\r\n ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT | ctx.STENCIL_BUFFER_BIT);\r\n\r\n if (isWebGL2RenderingContext) {\r\n ctx.drawBuffers([ctx.BACK]);\r\n ctx.readBuffer(ctx.BACK);\r\n ctx.bindBuffer(ctx.COPY_READ_BUFFER, null);\r\n ctx.bindBuffer(ctx.COPY_WRITE_BUFFER, null);\r\n ctx.bindBuffer(ctx.PIXEL_PACK_BUFFER, null);\r\n ctx.bindBuffer(ctx.PIXEL_UNPACK_BUFFER, null);\r\n var numTransformFeedbacks = ctx.getParameter(\r\n ctx.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\r\n );\r\n for (var ii = 0; ii < numTransformFeedbacks; ++ii) {\r\n ctx.bindBufferBase(ctx.TRANSFORM_FEEDBACK_BUFFER, ii, null);\r\n }\r\n var numUBOs = ctx.getParameter(ctx.MAX_UNIFORM_BUFFER_BINDINGS);\r\n for (var ii = 0; ii < numUBOs; ++ii) {\r\n ctx.bindBufferBase(ctx.UNIFORM_BUFFER, ii, null);\r\n }\r\n ctx.disable(ctx.RASTERIZER_DISCARD);\r\n ctx.pixelStorei(ctx.UNPACK_IMAGE_HEIGHT, 0);\r\n ctx.pixelStorei(ctx.UNPACK_SKIP_IMAGES, 0);\r\n ctx.pixelStorei(ctx.UNPACK_ROW_LENGTH, 0);\r\n ctx.pixelStorei(ctx.UNPACK_SKIP_ROWS, 0);\r\n ctx.pixelStorei(ctx.UNPACK_SKIP_PIXELS, 0);\r\n ctx.pixelStorei(ctx.PACK_ROW_LENGTH, 0);\r\n ctx.pixelStorei(ctx.PACK_SKIP_ROWS, 0);\r\n ctx.pixelStorei(ctx.PACK_SKIP_PIXELS, 0);\r\n ctx.hint(ctx.FRAGMENT_SHADER_DERIVATIVE_HINT, ctx.DONT_CARE);\r\n }\r\n\r\n // TODO: This should NOT be needed but Firefox fails with 'hint'\r\n while (ctx.getError());\r\n }\r\n\r\n function makeLostContextSimulatingCanvas(canvas) {\r\n var unwrappedContext_;\r\n var wrappedContext_;\r\n var onLost_ = [];\r\n var onRestored_ = [];\r\n var wrappedContext_ = {};\r\n var contextId_ = 1;\r\n var contextLost_ = false;\r\n var resourceId_ = 0;\r\n var resourceDb_ = [];\r\n var numCallsToLoseContext_ = 0;\r\n var numCalls_ = 0;\r\n var canRestore_ = false;\r\n var restoreTimeout_ = 0;\r\n var isWebGL2RenderingContext;\r\n\r\n // Holds booleans for each GL error so can simulate errors.\r\n var glErrorShadow_ = {};\r\n\r\n canvas.getContext = (function(f) {\r\n return function() {\r\n var ctx = f.apply(canvas, arguments);\r\n // Did we get a context and is it a WebGL context?\r\n if (\r\n ctx instanceof WebGLRenderingContext ||\r\n (window.WebGL2RenderingContext && ctx instanceof WebGL2RenderingContext)\r\n ) {\r\n if (ctx != unwrappedContext_) {\r\n if (unwrappedContext_) {\r\n throw 'got different context';\r\n }\r\n isWebGL2RenderingContext =\r\n window.WebGL2RenderingContext && ctx instanceof WebGL2RenderingContext;\r\n unwrappedContext_ = ctx;\r\n wrappedContext_ = makeLostContextSimulatingContext(unwrappedContext_);\r\n }\r\n return wrappedContext_;\r\n }\r\n return ctx;\r\n };\r\n })(canvas.getContext);\r\n\r\n function wrapEvent(listener) {\r\n if (typeof listener === 'function') {\r\n return listener;\r\n } else {\r\n return function(info) {\r\n listener.handleEvent(info);\r\n };\r\n }\r\n }\r\n\r\n var addOnContextLostListener = function(listener) {\r\n onLost_.push(wrapEvent(listener));\r\n };\r\n\r\n var addOnContextRestoredListener = function(listener) {\r\n onRestored_.push(wrapEvent(listener));\r\n };\r\n\r\n function wrapAddEventListener(canvas) {\r\n var f = canvas.addEventListener;\r\n canvas.addEventListener = function(type, listener, bubble) {\r\n switch (type) {\r\n case 'webglcontextlost':\r\n addOnContextLostListener(listener);\r\n break;\r\n case 'webglcontextrestored':\r\n addOnContextRestoredListener(listener);\r\n break;\r\n default:\r\n f.apply(canvas, arguments);\r\n }\r\n };\r\n }\r\n\r\n wrapAddEventListener(canvas);\r\n\r\n canvas.loseContext = function() {\r\n if (!contextLost_) {\r\n contextLost_ = true;\r\n numCallsToLoseContext_ = 0;\r\n ++contextId_;\r\n while (unwrappedContext_.getError());\r\n clearErrors();\r\n glErrorShadow_[unwrappedContext_.CONTEXT_LOST_WEBGL] = true;\r\n var event = makeWebGLContextEvent('context lost');\r\n var callbacks = onLost_.slice();\r\n setTimeout(function() {\r\n //log(\"numCallbacks:\" + callbacks.length);\r\n for (var ii = 0; ii < callbacks.length; ++ii) {\r\n //log(\"calling callback:\" + ii);\r\n callbacks[ii](event);\r\n }\r\n if (restoreTimeout_ >= 0) {\r\n setTimeout(function() {\r\n canvas.restoreContext();\r\n }, restoreTimeout_);\r\n }\r\n }, 0);\r\n }\r\n };\r\n\r\n canvas.restoreContext = function() {\r\n if (contextLost_) {\r\n if (onRestored_.length) {\r\n setTimeout(function() {\r\n if (!canRestore_) {\r\n throw 'can not restore. webglcontestlost listener did not call event.preventDefault';\r\n }\r\n freeResources();\r\n resetToInitialState(unwrappedContext_);\r\n contextLost_ = false;\r\n numCalls_ = 0;\r\n canRestore_ = false;\r\n var callbacks = onRestored_.slice();\r\n var event = makeWebGLContextEvent('context restored');\r\n for (var ii = 0; ii < callbacks.length; ++ii) {\r\n callbacks[ii](event);\r\n }\r\n }, 0);\r\n }\r\n }\r\n };\r\n\r\n canvas.loseContextInNCalls = function(numCalls) {\r\n if (contextLost_) {\r\n throw 'You can not ask a lost contet to be lost';\r\n }\r\n numCallsToLoseContext_ = numCalls_ + numCalls;\r\n };\r\n\r\n canvas.getNumCalls = function() {\r\n return numCalls_;\r\n };\r\n\r\n canvas.setRestoreTimeout = function(timeout) {\r\n restoreTimeout_ = timeout;\r\n };\r\n\r\n function isWebGLObject(obj) {\r\n //return false;\r\n return (\r\n obj instanceof WebGLBuffer ||\r\n obj instanceof WebGLFramebuffer ||\r\n obj instanceof WebGLProgram ||\r\n obj instanceof WebGLRenderbuffer ||\r\n obj instanceof WebGLShader ||\r\n obj instanceof WebGLTexture\r\n );\r\n }\r\n\r\n function checkResources(args) {\r\n for (var ii = 0; ii < args.length; ++ii) {\r\n var arg = args[ii];\r\n if (isWebGLObject(arg)) {\r\n return arg.__webglDebugContextLostId__ == contextId_;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n function clearErrors() {\r\n var k = Object.keys(glErrorShadow_);\r\n for (var ii = 0; ii < k.length; ++ii) {\r\n delete glErrorShadow_[k[ii]];\r\n }\r\n }\r\n\r\n function loseContextIfTime() {\r\n ++numCalls_;\r\n if (!contextLost_) {\r\n if (numCallsToLoseContext_ == numCalls_) {\r\n canvas.loseContext();\r\n }\r\n }\r\n }\r\n\r\n // Makes a function that simulates WebGL when out of context.\r\n function makeLostContextFunctionWrapper(ctx, functionName) {\r\n var f = ctx[functionName];\r\n return function() {\r\n // log(\"calling:\" + functionName);\r\n // Only call the functions if the context is not lost.\r\n loseContextIfTime();\r\n if (!contextLost_) {\r\n //if (!checkResources(arguments)) {\r\n // glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;\r\n // return;\r\n //}\r\n var result = f.apply(ctx, arguments);\r\n return result;\r\n }\r\n };\r\n }\r\n\r\n function freeResources() {\r\n for (var ii = 0; ii < resourceDb_.length; ++ii) {\r\n var resource = resourceDb_[ii];\r\n if (resource instanceof WebGLBuffer) {\r\n unwrappedContext_.deleteBuffer(resource);\r\n } else if (resource instanceof WebGLFramebuffer) {\r\n unwrappedContext_.deleteFramebuffer(resource);\r\n } else if (resource instanceof WebGLProgram) {\r\n unwrappedContext_.deleteProgram(resource);\r\n } else if (resource instanceof WebGLRenderbuffer) {\r\n unwrappedContext_.deleteRenderbuffer(resource);\r\n } else if (resource instanceof WebGLShader) {\r\n unwrappedContext_.deleteShader(resource);\r\n } else if (resource instanceof WebGLTexture) {\r\n unwrappedContext_.deleteTexture(resource);\r\n } else if (isWebGL2RenderingContext) {\r\n if (resource instanceof WebGLQuery) {\r\n unwrappedContext_.deleteQuery(resource);\r\n } else if (resource instanceof WebGLSampler) {\r\n unwrappedContext_.deleteSampler(resource);\r\n } else if (resource instanceof WebGLSync) {\r\n unwrappedContext_.deleteSync(resource);\r\n } else if (resource instanceof WebGLTransformFeedback) {\r\n unwrappedContext_.deleteTransformFeedback(resource);\r\n } else if (resource instanceof WebGLVertexArrayObject) {\r\n unwrappedContext_.deleteVertexArray(resource);\r\n }\r\n }\r\n }\r\n }\r\n\r\n function makeWebGLContextEvent(statusMessage) {\r\n return {\r\n statusMessage: statusMessage,\r\n preventDefault: function() {\r\n canRestore_ = true;\r\n }\r\n };\r\n }\r\n\r\n return canvas;\r\n\r\n function makeLostContextSimulatingContext(ctx) {\r\n // copy all functions and properties to wrapper\r\n for (var propertyName in ctx) {\r\n if (typeof ctx[propertyName] === 'function') {\r\n wrappedContext_[propertyName] = makeLostContextFunctionWrapper(\r\n ctx,\r\n propertyName\r\n );\r\n } else {\r\n makePropertyWrapper(wrappedContext_, ctx, propertyName);\r\n }\r\n }\r\n\r\n // Wrap a few functions specially.\r\n wrappedContext_.getError = function() {\r\n loseContextIfTime();\r\n if (!contextLost_) {\r\n var err;\r\n while ((err = unwrappedContext_.getError())) {\r\n glErrorShadow_[err] = true;\r\n }\r\n }\r\n for (var err in glErrorShadow_) {\r\n if (glErrorShadow_[err]) {\r\n delete glErrorShadow_[err];\r\n return err;\r\n }\r\n }\r\n return wrappedContext_.NO_ERROR;\r\n };\r\n\r\n var creationFunctions = [\r\n 'createBuffer',\r\n 'createFramebuffer',\r\n 'createProgram',\r\n 'createRenderbuffer',\r\n 'createShader',\r\n 'createTexture'\r\n ];\r\n if (isWebGL2RenderingContext) {\r\n creationFunctions.push(\r\n 'createQuery',\r\n 'createSampler',\r\n 'fenceSync',\r\n 'createTransformFeedback',\r\n 'createVertexArray'\r\n );\r\n }\r\n for (var ii = 0; ii < creationFunctions.length; ++ii) {\r\n var functionName = creationFunctions[ii];\r\n wrappedContext_[functionName] = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return null;\r\n }\r\n var obj = f.apply(ctx, arguments);\r\n obj.__webglDebugContextLostId__ = contextId_;\r\n resourceDb_.push(obj);\r\n return obj;\r\n };\r\n })(ctx[functionName]);\r\n }\r\n\r\n var functionsThatShouldReturnNull = [\r\n 'getActiveAttrib',\r\n 'getActiveUniform',\r\n 'getBufferParameter',\r\n 'getContextAttributes',\r\n 'getAttachedShaders',\r\n 'getFramebufferAttachmentParameter',\r\n 'getParameter',\r\n 'getProgramParameter',\r\n 'getProgramInfoLog',\r\n 'getRenderbufferParameter',\r\n 'getShaderParameter',\r\n 'getShaderInfoLog',\r\n 'getShaderSource',\r\n 'getTexParameter',\r\n 'getUniform',\r\n 'getUniformLocation',\r\n 'getVertexAttrib'\r\n ];\r\n if (isWebGL2RenderingContext) {\r\n functionsThatShouldReturnNull.push(\r\n 'getInternalformatParameter',\r\n 'getQuery',\r\n 'getQueryParameter',\r\n 'getSamplerParameter',\r\n 'getSyncParameter',\r\n 'getTransformFeedbackVarying',\r\n 'getIndexedParameter',\r\n 'getUniformIndices',\r\n 'getActiveUniforms',\r\n 'getActiveUniformBlockParameter',\r\n 'getActiveUniformBlockName'\r\n );\r\n }\r\n for (var ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {\r\n var functionName = functionsThatShouldReturnNull[ii];\r\n wrappedContext_[functionName] = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return null;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_[functionName]);\r\n }\r\n\r\n var isFunctions = [\r\n 'isBuffer',\r\n 'isEnabled',\r\n 'isFramebuffer',\r\n 'isProgram',\r\n 'isRenderbuffer',\r\n 'isShader',\r\n 'isTexture'\r\n ];\r\n if (isWebGL2RenderingContext) {\r\n isFunctions.push(\r\n 'isQuery',\r\n 'isSampler',\r\n 'isSync',\r\n 'isTransformFeedback',\r\n 'isVertexArray'\r\n );\r\n }\r\n for (var ii = 0; ii < isFunctions.length; ++ii) {\r\n var functionName = isFunctions[ii];\r\n wrappedContext_[functionName] = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return false;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_[functionName]);\r\n }\r\n\r\n wrappedContext_.checkFramebufferStatus = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return wrappedContext_.FRAMEBUFFER_UNSUPPORTED;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.checkFramebufferStatus);\r\n\r\n wrappedContext_.getAttribLocation = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return -1;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.getAttribLocation);\r\n\r\n wrappedContext_.getVertexAttribOffset = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return 0;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.getVertexAttribOffset);\r\n\r\n wrappedContext_.isContextLost = function() {\r\n return contextLost_;\r\n };\r\n\r\n if (isWebGL2RenderingContext) {\r\n wrappedContext_.getFragDataLocation = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return -1;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.getFragDataLocation);\r\n\r\n wrappedContext_.clientWaitSync = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return wrappedContext_.WAIT_FAILED;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.clientWaitSync);\r\n\r\n wrappedContext_.getUniformBlockIndex = (function(f) {\r\n return function() {\r\n loseContextIfTime();\r\n if (contextLost_) {\r\n return wrappedContext_.INVALID_INDEX;\r\n }\r\n return f.apply(ctx, arguments);\r\n };\r\n })(wrappedContext_.getUniformBlockIndex);\r\n }\r\n\r\n return wrappedContext_;\r\n }\r\n }\r\n\r\n return {\r\n /**\r\n * Initializes this module. Safe to call more than once.\r\n * @param {!WebGLRenderingContext} ctx A WebGL context. If\r\n * you have more than one context it doesn't matter which one\r\n * you pass in, it is only used to pull out constants.\r\n */\r\n init: init,\r\n\r\n /**\r\n * Returns true or false if value matches any WebGL enum\r\n * @param {*} value Value to check if it might be an enum.\r\n * @return {boolean} True if value matches one of the WebGL defined enums\r\n */\r\n mightBeEnum: mightBeEnum,\r\n\r\n /**\r\n * Gets an string version of an WebGL enum.\r\n *\r\n * Example:\r\n * WebGLDebugUtil.init(ctx);\r\n * var str = WebGLDebugUtil.glEnumToString(ctx.getError());\r\n *\r\n * @param {number} value Value to return an enum for\r\n * @return {string} The string version of the enum.\r\n */\r\n glEnumToString: glEnumToString,\r\n\r\n /**\r\n * Converts the argument of a WebGL function to a string.\r\n * Attempts to convert enum arguments to strings.\r\n *\r\n * Example:\r\n * WebGLDebugUtil.init(ctx);\r\n * var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 2, 0, gl.TEXTURE_2D);\r\n *\r\n * would return 'TEXTURE_2D'\r\n *\r\n * @param {string} functionName the name of the WebGL function.\r\n * @param {number} numArgs The number of arguments\r\n * @param {number} argumentIndx the index of the argument.\r\n * @param {*} value The value of the argument.\r\n * @return {string} The value as a string.\r\n */\r\n glFunctionArgToString: glFunctionArgToString,\r\n\r\n /**\r\n * Converts the arguments of a WebGL function to a string.\r\n * Attempts to convert enum arguments to strings.\r\n *\r\n * @param {string} functionName the name of the WebGL function.\r\n * @param {number} args The arguments.\r\n * @return {string} The arguments as a string.\r\n */\r\n glFunctionArgsToString: glFunctionArgsToString,\r\n\r\n /**\r\n * Given a WebGL context returns a wrapped context that calls\r\n * gl.getError after every command and calls a function if the\r\n * result is not NO_ERROR.\r\n *\r\n * You can supply your own function if you want. For example, if you'd like\r\n * an exception thrown on any GL error you could do this\r\n *\r\n * function throwOnGLError(err, funcName, args) {\r\n * throw WebGLDebugUtils.glEnumToString(err) +\r\n * \" was caused by call to \" + funcName;\r\n * };\r\n *\r\n * ctx = WebGLDebugUtils.makeDebugContext(\r\n * canvas.getContext(\"webgl\"), throwOnGLError);\r\n *\r\n * @param {!WebGLRenderingContext} ctx The webgl context to wrap.\r\n * @param {!function(err, funcName, args): void} opt_onErrorFunc The function\r\n * to call when gl.getError returns an error. If not specified the default\r\n * function calls console.log with a message.\r\n * @param {!function(funcName, args): void} opt_onFunc The\r\n * function to call when each webgl function is called. You\r\n * can use this to log all calls for example.\r\n */\r\n makeDebugContext: makeDebugContext,\r\n\r\n /**\r\n * Given a canvas element returns a wrapped canvas element that will\r\n * simulate lost context. The canvas returned adds the following functions.\r\n *\r\n * loseContext:\r\n * simulates a lost context event.\r\n *\r\n * restoreContext:\r\n * simulates the context being restored.\r\n *\r\n * lostContextInNCalls:\r\n * loses the context after N gl calls.\r\n *\r\n * getNumCalls:\r\n * tells you how many gl calls there have been so far.\r\n *\r\n * setRestoreTimeout:\r\n * sets the number of milliseconds until the context is restored\r\n * after it has been lost. Defaults to 0. Pass -1 to prevent\r\n * automatic restoring.\r\n *\r\n * @param {!Canvas} canvas The canvas element to wrap.\r\n */\r\n makeLostContextSimulatingCanvas: makeLostContextSimulatingCanvas,\r\n\r\n /**\r\n * Resets a context to the initial state.\r\n * @param {!WebGLRenderingContext} ctx The webgl context to\r\n * reset.\r\n */\r\n resetToInitialState: resetToInitialState\r\n };\r\n})();\r\n\r\nexport default WebGLDebugUtils;\r\n","var Graph = function() {\r\n this._values = new Float32Array(Graph.maxGraphValue);\r\n this._index = 0;\r\n this._maxValue = 0.0;\r\n this._x = 0;\r\n this._y = 0;\r\n};\r\nGraph.maxGraphValue = 120;\r\nGraph.prototype = {\r\n getIndex: function() {\r\n return this._index;\r\n },\r\n getValues: function() {\r\n return this._values;\r\n },\r\n setDisplayPosition: function(x, y) {\r\n this._x = x;\r\n this._y = y;\r\n },\r\n getX: function() {\r\n return this._x;\r\n },\r\n getY: function() {\r\n return this._y;\r\n },\r\n addValue: function(value, uvColor) {\r\n var index = this._index;\r\n this._maxValue = value > this._maxValue ? value : this._maxValue;\r\n this._maxValue *= 0.99;\r\n this._values[index] = value / (this._maxValue * 1.1);\r\n if (uvColor) this._values[index] += uvColor;\r\n this._index = (this._index + 1) % Graph.maxGraphValue;\r\n }\r\n};\r\n\r\nexport default Graph;\r\n","import utils from '../osg/utils';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport Geometry from '../osg/Geometry';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport notify from '../osg/notify';\r\nimport Graph from './Graph';\r\n\r\n// captions data (4 vertexes, indexes)\r\n// values data (4 vertexes, indexes)\r\n// graph data (2 vertexes, drawArrays)\r\n\r\nvar BufferStats = function() {\r\n this._usageHint = BufferArray.DYNAMIC_DRAW;\r\n // equivalent of 512 characters for caption, 128 of values characters\r\n // and 6 graph of 120 lines\r\n var nbVertexes = (1024 + 256) * 4 + 6 * 2 * 120;\r\n this._nbVertexes = 0;\r\n this._maxNbVertexes = 0;\r\n\r\n this._captionNbVertexes = 0;\r\n this._valuesNbVertexes = 0;\r\n this._graphsNbVertexes = 0;\r\n\r\n this.resize(nbVertexes);\r\n};\r\n\r\nBufferStats.backgroundColor = 10.0;\r\nBufferStats.redColor = 7.0;\r\nBufferStats.greyColor = 4.0;\r\nBufferStats.whiteColor = 1.0;\r\n\r\nutils.createPrototypeObject(BufferStats, {\r\n getGeometry: function() {\r\n return this._geometry;\r\n },\r\n generateBackground: function(x, y, w, h) {\r\n var vertexes = this._vertexes;\r\n this._nbVertexes += 4;\r\n\r\n vertexes[0] = x;\r\n vertexes[1] = y;\r\n vertexes[2] = 0.0;\r\n vertexes[3] = BufferStats.backgroundColor;\r\n\r\n var x1 = x + w;\r\n var y1 = y + h;\r\n\r\n vertexes[4] = x;\r\n vertexes[5] = y1;\r\n vertexes[6] = 0.0;\r\n vertexes[7] = BufferStats.backgroundColor;\r\n\r\n vertexes[8] = x1;\r\n vertexes[9] = y1;\r\n vertexes[10] = 0.0;\r\n vertexes[11] = BufferStats.backgroundColor;\r\n\r\n vertexes[12] = x1;\r\n vertexes[13] = y;\r\n vertexes[14] = 0.0;\r\n vertexes[15] = BufferStats.backgroundColor;\r\n },\r\n generateCharacter: function(x, y, w, h, ux, ux1, color) {\r\n var vertexes = this._vertexes;\r\n var nbVertexes = this._nbVertexes;\r\n\r\n this._nbVertexes += 4;\r\n var i = nbVertexes * 4;\r\n\r\n vertexes[i++] = x;\r\n vertexes[i++] = y;\r\n vertexes[i++] = ux;\r\n vertexes[i++] = -(0.0 + color);\r\n\r\n var x1 = x + w;\r\n var y1 = y + h;\r\n\r\n vertexes[i++] = x;\r\n vertexes[i++] = y1;\r\n vertexes[i++] = ux;\r\n vertexes[i++] = -(1.0 + color);\r\n\r\n vertexes[i++] = x1;\r\n vertexes[i++] = y1;\r\n vertexes[i++] = ux1;\r\n vertexes[i++] = -(1.0 + color);\r\n\r\n vertexes[i++] = x1;\r\n vertexes[i++] = y;\r\n vertexes[i++] = ux1;\r\n vertexes[i++] = -(0.0 + color);\r\n },\r\n generateText: function(x, y, text, textGenerator, zColor) {\r\n var size = text.length;\r\n if (this._nbVertexes + size * 4 >= this._maxNbVertexes) {\r\n this.resize(this._maxNbVertexes * 2);\r\n }\r\n var characterSizeUV = textGenerator._characterSizeUV;\r\n var characterWidth = textGenerator._characterWidth;\r\n var characterHeight = textGenerator._characterHeight;\r\n for (var i = 0; i < size; i++) {\r\n var characterCode = text.charCodeAt(i);\r\n var uvx = textGenerator.getCharacterUV(characterCode);\r\n this.generateCharacter(\r\n x,\r\n y,\r\n characterWidth,\r\n characterHeight,\r\n uvx,\r\n uvx + characterSizeUV,\r\n zColor\r\n );\r\n\r\n x += characterWidth;\r\n }\r\n return size * characterWidth;\r\n },\r\n generateGraph: function(graph, height) {\r\n if (this._nbVertexes + Graph.maxGraphValue * 2 >= this._maxNbVertexes) {\r\n this.resize(this._maxNbVertexes * 2);\r\n }\r\n var vertexes = this._vertexes;\r\n var nbVertexes = this._nbVertexes;\r\n\r\n var graphValues = graph.getValues();\r\n var nbGraphValues = graphValues.length;\r\n var graphStartIndex = graph.getIndex();\r\n\r\n var x = graph.getX();\r\n var y = graph.getY();\r\n this._nbVertexes += nbGraphValues * 2;\r\n\r\n for (var i = 0; i < nbGraphValues; i++) {\r\n var graphIndex = (graphStartIndex + i) % nbGraphValues;\r\n var graphValue = graphValues[graphIndex];\r\n\r\n var bufferIndex = nbVertexes + i * 2;\r\n var vertexIndex = bufferIndex * 4;\r\n\r\n var value = graphValue;\r\n var color = BufferStats.greyColor;\r\n // check if the value is a warning or not\r\n if (value >= BufferStats.redColor) {\r\n color = BufferStats.redColor;\r\n value -= BufferStats.redColor;\r\n }\r\n\r\n if (value > 1.0) value = 1.0;\r\n value *= height;\r\n if (value < 1.0) value = 1.0;\r\n\r\n vertexes[vertexIndex] = x + i * 2;\r\n vertexes[vertexIndex + 1] = y;\r\n vertexes[vertexIndex + 2] = 0.0;\r\n vertexes[vertexIndex + 3] = color;\r\n\r\n vertexes[vertexIndex + 4] = x + i * 2;\r\n vertexes[vertexIndex + 5] = y + value;\r\n vertexes[vertexIndex + 6] = 0.0;\r\n vertexes[vertexIndex + 7] = color;\r\n }\r\n },\r\n resize: function(nbVertexes) {\r\n notify.log('resize buffer to ' + nbVertexes);\r\n this._maxNbVertexes = nbVertexes;\r\n var vertexes = new Float32Array(nbVertexes * 4);\r\n if (this._vertexes) vertexes.set(this._vertexes);\r\n this._vertexes = vertexes;\r\n\r\n // it's the max number of characters displayable\r\n var nbCharacters = Math.ceil(nbVertexes / 4);\r\n this._indexes = new Uint16Array(nbCharacters * 6);\r\n for (var i = 0, j = 0; i < nbCharacters; i++) {\r\n this._indexes[j++] = i * 4 + 0;\r\n this._indexes[j++] = i * 4 + 1;\r\n this._indexes[j++] = i * 4 + 3;\r\n this._indexes[j++] = i * 4 + 3;\r\n this._indexes[j++] = i * 4 + 1;\r\n this._indexes[j++] = i * 4 + 2;\r\n }\r\n\r\n if (this._geometry) {\r\n this._geometry.getAttributes().Vertex.setElements(this._vertexes);\r\n this._characterPrimitive.getIndices().setElements(this._indexes);\r\n return;\r\n }\r\n\r\n this._geometry = new Geometry();\r\n this._geometry.setName('osgStats-Stats');\r\n\r\n this._geometry.getAttributes().Vertex = new BufferArray(\r\n BufferArray.ARRAY_BUFFER,\r\n this._vertexes,\r\n 4,\r\n true\r\n );\r\n var indexArray = new BufferArray(BufferArray.ELEMENT_ARRAY_BUFFER, this._indexes, 1);\r\n\r\n // for labels and values\r\n this._geometry.getAttributes().Vertex.setUsage(this._usageHint);\r\n\r\n var drawElement = new DrawElements(primitiveSet.TRIANGLES, indexArray);\r\n this._characterPrimitive = drawElement;\r\n this._geometry.getPrimitives().push(this._characterPrimitive);\r\n\r\n var drawArrays = new DrawArrays(primitiveSet.LINES, 0, 0);\r\n this._graphPrimitive = drawArrays;\r\n this._geometry.getPrimitives().push(this._graphPrimitive);\r\n },\r\n update: function() {\r\n var nbTotalCharacters = this._captionNbVertexes + this._valuesNbVertexes;\r\n this._characterPrimitive.setCount(nbTotalCharacters / 4 * 6);\r\n this._graphPrimitive.setCount(this._graphsNbVertexes);\r\n this._graphPrimitive.setFirst(nbTotalCharacters);\r\n\r\n this._geometry.getAttributes().Vertex.dirty();\r\n },\r\n resetCaptions: function() {\r\n this._nbVertexes = 0;\r\n this._captionNbVertexes = 0;\r\n },\r\n resetValues: function() {\r\n this._nbVertexes = this._captionNbVertexes;\r\n this._valuesNbVertexes = 0;\r\n this._graphsNbVertexes = 0;\r\n },\r\n captionsEnd: function() {\r\n this._captionNbVertexes = this._nbVertexes;\r\n },\r\n valuesEnd: function() {\r\n this._valuesNbVertexes = this._nbVertexes - this._captionNbVertexes;\r\n },\r\n graphsEnd: function() {\r\n this._graphsNbVertexes =\r\n this._nbVertexes - (this._valuesNbVertexes + this._captionNbVertexes);\r\n },\r\n getCharacterPrimitive: function() {\r\n return this._characterPrimitive;\r\n },\r\n getGraphPrimitive: function() {\r\n return this._graphPrimitive;\r\n },\r\n getNbVertexes: function() {\r\n return this._nbVertexes;\r\n }\r\n});\r\n\r\nexport default BufferStats;","import utils from '../osg/utils';\r\nvar performance = window.performance;\r\n\r\nvar Counter = function(config) {\r\n this._caption = config.caption;\r\n this._accumValue = 0;\r\n this._accumSamples = 0;\r\n this._accumStart = 0;\r\n this._value = 0;\r\n this._averageValue = 0;\r\n this._time = 0;\r\n this._avgMs = 0;\r\n this._over = config.over > 0.0 ? config.over : 0;\r\n this._below = config.below > 0.0 ? config.below : 0;\r\n this._graph = !!config.graph;\r\n if (config.average) {\r\n this._avgMs = config.avgMs ? config.avgMs : 1000;\r\n }\r\n this._display = false;\r\n};\r\n\r\nutils.createPrototypeObject(Counter, {\r\n isDisplayable: function() {\r\n return this._display;\r\n },\r\n setDisplayable: function(boolean) {\r\n this._display = boolean;\r\n },\r\n getOver: function() {\r\n return this._over;\r\n },\r\n getBelow: function() {\r\n return this._below;\r\n },\r\n getGraph: function() {\r\n return this._graph;\r\n },\r\n getAverageMs: function() {\r\n return this._avgMs;\r\n },\r\n getAverageValue: function() {\r\n return this._averageValue;\r\n },\r\n getValue: function() {\r\n return this._value;\r\n },\r\n average: function(value) {\r\n if (!this._avgMs) return;\r\n\r\n this._accumValue += value;\r\n this._accumSamples++;\r\n var t = performance.now();\r\n if (t - this._accumStart > this._avgMs) {\r\n this._averageValue = this._accumValue / this._accumSamples;\r\n this._accumValue = 0;\r\n this._accumStart = t;\r\n this._accumSamples = 0;\r\n }\r\n },\r\n start: function() {\r\n this._display = true;\r\n this._time = performance.now();\r\n },\r\n end: function() {\r\n this._value = performance.now() - this._time;\r\n this.average(this._value);\r\n },\r\n set: function(value) {\r\n this._display = true;\r\n this._value = value;\r\n this.average(value);\r\n },\r\n tick: function() {\r\n this.end();\r\n this.start();\r\n },\r\n frame: function() {\r\n var delta = performance.now() - this._time;\r\n this.set(1000.0 / delta);\r\n this.start();\r\n }\r\n});\r\n\r\nexport default Counter;","import utils from '../osg/utils';\r\nimport P from 'bluebird';\r\nimport notify from '../osg/notify';\r\n\r\nvar DefaultFont = 'Courier New';\r\n\r\nvar determineFontHeight = function(fontStyle) {\r\n var body = document.getElementsByTagName('body')[0];\r\n var dummy = document.createElement('div');\r\n var dummyText = document.createTextNode('M');\r\n dummy.appendChild(dummyText);\r\n dummy.setAttribute('style', fontStyle);\r\n body.appendChild(dummy);\r\n var result = dummy.offsetHeight;\r\n body.removeChild(dummy);\r\n return result;\r\n};\r\n\r\nvar loadFont = function(fontFamily) {\r\n return new P(function(resolve, reject) {\r\n window.WebFontConfig = {\r\n google: {\r\n families: [fontFamily + ':200']\r\n },\r\n active: function() {\r\n resolve(fontFamily);\r\n },\r\n inactive: function(error) {\r\n reject('loadFont error:' + error);\r\n }\r\n };\r\n var wf = document.createElement('script'),\r\n s = document.scripts[0];\r\n wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';\r\n wf.async = true;\r\n wf.onerror = function() {\r\n reject();\r\n };\r\n s.parentNode.insertBefore(wf, s);\r\n });\r\n};\r\n\r\nvar TextGenerator = function() {\r\n this._canvas = undefined;\r\n this._characterHeight = 0;\r\n this._characterWidth = 0;\r\n this._fontSize = 16;\r\n this._fontFamily = 'Source Code Pro';\r\n this._characterFirstCode = ' '.charCodeAt();\r\n this._characterLastCode = 'z'.charCodeAt();\r\n this._characterSizeUV = 0;\r\n this._backgroundColor = 'rgba(0,0,0,0.0)';\r\n this._createCanvas();\r\n};\r\n\r\nutils.createPrototypeObject(TextGenerator, {\r\n setFontSize: function(size) {\r\n this._fontSize = size;\r\n },\r\n getCharacterWidth: function() {\r\n return this._characterWidth;\r\n },\r\n getCharacterHeight: function() {\r\n return this._characterHeight;\r\n },\r\n getCanvas: function() {\r\n return this._promise;\r\n },\r\n getCharacterUV: function(characterCode) {\r\n var index = characterCode - this._characterFirstCode;\r\n return index * this._characterSizeUV;\r\n },\r\n _fillCanvas: function(fontFamily, fontSize) {\r\n // get font height\r\n var size = fontSize + 'px';\r\n var style = 'font-family: ' + fontFamily + '; font-size: ' + size + ';';\r\n var pixelHeight = determineFontHeight(style);\r\n notify.debug(fontFamily + ' ' + size + ' ==> ' + pixelHeight + ' pixels high.');\r\n\r\n this._characterHeight = Math.ceil(pixelHeight);\r\n var font = fontSize + \"px '\" + fontFamily + \"'\";\r\n var canvas = document.createElement('canvas');\r\n var ctx = canvas.getContext('2d');\r\n this._canvas = canvas;\r\n ctx.font = font;\r\n ctx.textBaseline = 'middle';\r\n\r\n this._characterWidth = ctx.measureText(' ').width;\r\n this._characterWidth = Math.ceil(this._characterWidth);\r\n\r\n var nbCharacters = this._characterLastCode - this._characterFirstCode + 1;\r\n notify.info(\r\n 'Stats character size ' +\r\n this._characterWidth +\r\n ' x ' +\r\n this._characterHeight +\r\n ' texture width ' +\r\n this._characterWidth * nbCharacters\r\n );\r\n\r\n canvas.width = Math.ceil(this._characterWidth * nbCharacters);\r\n canvas.height = this._characterHeight;\r\n\r\n this._characterSizeUV = this._characterWidth / canvas.width;\r\n\r\n ctx.font = font;\r\n ctx.textBaseline = 'middle';\r\n ctx.fillStyle = 'rgb(255,255,255)';\r\n for (var i = this._characterFirstCode, j = 0; i <= this._characterLastCode; i++, j++) {\r\n var code = String.fromCharCode(i);\r\n var x = j * this._characterWidth;\r\n var y = this._characterHeight / 2;\r\n ctx.fillText(code, x, y);\r\n }\r\n return canvas;\r\n },\r\n _createCanvas: function() {\r\n this._promise = loadFont(this._fontFamily)\r\n .then(\r\n function(fontFamily) {\r\n return this._fillCanvas(fontFamily, this._fontSize);\r\n }.bind(this)\r\n )\r\n .catch(\r\n function() {\r\n return this._fillCanvas(DefaultFont, this._fontSize);\r\n }.bind(this)\r\n );\r\n }\r\n});\r\n\r\nexport default TextGenerator;","import utils from '../osg/utils';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport Camera from '../osg/Camera';\r\nimport CullFace from '../osg/CullFace';\r\nimport Depth from '../osg/Depth';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Transform from '../osg/Transform';\r\nimport Texture from '../osg/Texture';\r\nimport { mat4, vec2, vec3 } from '../osg/glMatrix';\r\nimport BufferStats from './BufferStats';\r\nimport Counter from './Counter';\r\nimport Graph from './Graph';\r\nimport TextGenerator from './TextGenerator';\r\nimport IntersectionVisitor from '../osgUtil/IntersectionVisitor';\r\nimport LineSegmentIntersector from '../osgUtil/LineSegmentIntersector';\r\nimport shape from '../osg/shape';\r\nimport BoundingBox from '../osg/BoundingBox';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\n// Stats usages:\r\n// url usable in Options\r\n//\r\n// to active the stats: ?stats=1\r\n//\r\n// to filter content in the stats: statsFilter=cull;myGroup;webgl\r\n//\r\n// to change the fontSize: statsFontSize=40\r\n//\r\n// You can also change the configuration before running the viewer to adds counters\r\n// var config = {\r\n// values: {\r\n// myCounter: {\r\n// caption: 'my uber counter',\r\n// average: true,\r\n// graph: true,\r\n// over: 16\r\n// },\r\n// myCounter2: {\r\n// caption: 'a second counter',\r\n// graph: true,\r\n// below: 16\r\n// }\r\n// groups: [\r\n// {\r\n// name: myGroup,\r\n// caption: 'blah my group',\r\n// values: [ 'myCounter', 'myCounter2' ]\r\n// }\r\n// ]\r\n// };\r\n// getViewerStats().addConfig(config)\r\n// getViewerStats().setShowFilter(['cull', 'myGroup']) // will display only cull\r\n// and myGroup groups\r\n// getViewerStats().setFontSize(50)\r\n\r\nvar PICKING_NODEMASK = 0x8000;\r\n\r\nvar createShader = function() {\r\n var vertexshader = [\r\n 'attribute vec4 Vertex;',\r\n 'uniform mat4 uModelViewMatrix;',\r\n 'uniform mat4 uProjectionMatrix;',\r\n '',\r\n 'varying vec2 vTexCoord0;',\r\n '',\r\n 'void main(void) {',\r\n ' vTexCoord0 = Vertex.zw;',\r\n ' gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex.xy,0.0, 1.0));',\r\n '}'\r\n ].join('\\n');\r\n\r\n var fragmentshader = [\r\n '#define SHADER_NAME STATS',\r\n 'varying vec2 vTexCoord0;',\r\n 'uniform sampler2D Texture0;',\r\n\r\n 'void main(void) {',\r\n ' vec4 color = vec4(1.0);',\r\n ' vec2 uv = vTexCoord0;',\r\n ' int isText = 0;',\r\n ' if ( uv.y < 0.0 ) {',\r\n ' isText = 1;',\r\n ' uv.y = -uv.y;',\r\n ' }',\r\n ' if ( uv.y >= ' + (BufferStats.backgroundColor - 1).toFixed(1) + ' ) {', // background\r\n ' color = vec4(0.0,0.0,0.0,0.5);',\r\n ' uv.y -= ' + BufferStats.backgroundColor.toFixed(1) + ';',\r\n ' } else if ( uv.y >= ' + (BufferStats.redColor - 1).toFixed(1) + ' ) {',\r\n ' color = vec4(1.0,0.0,0.0,1.0);',\r\n ' uv.y -= ' + BufferStats.redColor.toFixed(1) + ';',\r\n ' } else if ( uv.y == ' + (BufferStats.greyColor - 1).toFixed(1) + ' ) {',\r\n ' color = vec4(0.5,0.5,0.5,1.0);',\r\n ' uv.y -= ' + BufferStats.greyColor.toFixed(1) + ';',\r\n ' } else {',\r\n ' uv.y -= ' + BufferStats.whiteColor.toFixed(1) + ';',\r\n ' }',\r\n ' if ( isText == 1 ) {',\r\n ' color *= texture2D( Texture0, uv.xy);',\r\n ' }',\r\n ' gl_FragColor = color;',\r\n '}'\r\n ].join('\\n');\r\n\r\n return new Program(\r\n new Shader('VERTEX_SHADER', vertexshader),\r\n new Shader('FRAGMENT_SHADER', fragmentshader)\r\n );\r\n};\r\n\r\nvar Stats = function(viewer, options) {\r\n this._captionsBuffer = undefined;\r\n this._valuesBuffer = undefined;\r\n\r\n this._dirtyCaptions = true;\r\n this._dirtyValues = true;\r\n\r\n this._viewer = viewer;\r\n this._labelMaxWidth = 0;\r\n this._viewport = viewer.getCamera().getViewport();\r\n\r\n this._node = undefined;\r\n this._text = undefined;\r\n this._offsetGroup = undefined;\r\n\r\n this._counters = {};\r\n this._groups = {};\r\n this._updates = [];\r\n this._displayableCounters = {};\r\n this._x = 0;\r\n this._y = 0;\r\n this._width = 0;\r\n this._height = 0;\r\n\r\n this._maxCaptionTextLength = 32;\r\n\r\n this._lineFactor = 1.1;\r\n this._displayFilter = [];\r\n\r\n this._backgroundWidth = 0;\r\n this._backgroundHeight = 0;\r\n\r\n this._bufferStats = new BufferStats();\r\n this._historyGraph = {};\r\n\r\n this._graphToDisplay = [];\r\n\r\n this._valuesMaxWidth = 6 * 12;\r\n\r\n this._showGraph = false;\r\n\r\n // inputs data\r\n this._backgroundPicking = shape.createTexturedQuadGeometry(0, 0, 0, 10, 0, 0, 0, 10, 0);\r\n this._backgroundPicking.setName('osgStats-Background-picking');\r\n this._dragStop = vec2.create();\r\n this._dragStart = vec2.create();\r\n this._startTransformation = mat4.create();\r\n\r\n this._init(options);\r\n};\r\n\r\nutils.createPrototypeObject(Stats, {\r\n getCounter: function(name) {\r\n if (!this._counters[name]) {\r\n this._counters[name] = new Counter({\r\n caption: name,\r\n average: true\r\n });\r\n }\r\n\r\n return this._counters[name];\r\n },\r\n getBufferStats: function() {\r\n return this._bufferStats;\r\n },\r\n addConfig: function(config) {\r\n if (config.init && !config.init()) return;\r\n\r\n for (var valueName in config.values) {\r\n var valueConfig = config.values[valueName];\r\n var counter = new Counter(valueConfig);\r\n this._counters[valueName] = counter;\r\n }\r\n\r\n if (config.groups) {\r\n for (var i = 0; i < config.groups.length; i++) {\r\n var groupConfig = config.groups[i];\r\n var group = {\r\n caption: groupConfig.caption,\r\n values: groupConfig.values,\r\n textCursorY: new Float32Array(groupConfig.values.length)\r\n };\r\n\r\n var name = groupConfig.name ? groupConfig.name : groupConfig.caption;\r\n this._groups[name] = group;\r\n }\r\n }\r\n\r\n if (config.update) {\r\n this._updates.push(config.update);\r\n }\r\n },\r\n reset: function() {\r\n this._bufferStats.resetCaptions();\r\n this._bufferStats.resetValues();\r\n\r\n this._dirtyCaptions = true;\r\n this._dirtyValue = true;\r\n\r\n this._bufferStats.resize(this._bufferStats._maxNbVertexes);\r\n },\r\n update: function() {\r\n for (var i = 0; i < this._updates.length; i++) {\r\n this._updates[i](this);\r\n }\r\n this._dirtyValues = true;\r\n\r\n if (this._checkViewportChanged() || this._checkCounterDisplayableChanged())\r\n this._dirtyCaptions = true;\r\n\r\n if (this._dirtyCaptions) {\r\n this._bufferStats.resetCaptions();\r\n this._generateCaptions();\r\n this._dirtyCaptions = false;\r\n }\r\n\r\n if (this._dirtyValues) {\r\n this._bufferStats.resetValues();\r\n this._generateValues();\r\n this._dirtyValues = false;\r\n }\r\n },\r\n getNode: function() {\r\n return this._node;\r\n },\r\n setShowFilter: function(groupNamesArray) {\r\n this._dirtyCaptions = true;\r\n if (!groupNamesArray) {\r\n this._displayFilter.length = 0;\r\n return;\r\n }\r\n this._displayFilter = groupNamesArray.slice();\r\n },\r\n _init: function(options) {\r\n // 3D init\r\n var camera = new Camera();\r\n\r\n camera.setRenderOrder(Camera.POST_RENDER, 0);\r\n camera.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n camera.setClearMask(0x0); // dont clear anything\r\n var node = new MatrixTransform();\r\n node.setName('StatsNode');\r\n node.addChild(this._backgroundPicking);\r\n this._nodeTransform = node;\r\n this._backgroundPicking.setNodeMask(0);\r\n\r\n camera.addChild(node);\r\n camera.setName('osgStats');\r\n camera.setViewport(this._viewport);\r\n this._node = camera;\r\n this._text = new TextGenerator();\r\n\r\n var fontSize = 12;\r\n if (options) {\r\n var statsGroupList = options.getString('statsFilter');\r\n if (statsGroupList) {\r\n var filterList = statsGroupList.split(';');\r\n this.setShowFilter(filterList);\r\n }\r\n var statsFontSize = options.getNumber('statsFontSize');\r\n if (statsFontSize !== undefined) fontSize = statsFontSize;\r\n\r\n this._showGraph = options.getBoolean('statsShowGraph');\r\n }\r\n\r\n var texture = new Texture();\r\n texture.setMinFilter(Texture.NEAREST);\r\n texture.setMagFilter(Texture.NEAREST);\r\n this._text.setFontSize(fontSize * this._viewer.getCanvasPixelRatio());\r\n this._text.getCanvas().then(\r\n function(canvas) {\r\n this._dirtyCaptions = true;\r\n var geometry = this._bufferStats.getGeometry();\r\n geometry.setNodeMask(~PICKING_NODEMASK);\r\n node.addChild(geometry);\r\n texture.setImage(canvas);\r\n // invalidate the bounding box, we dont want it\r\n // to be used\r\n geometry.setBound(new BoundingBox());\r\n }.bind(this)\r\n );\r\n\r\n node.getOrCreateStateSet().setAttributeAndModes(createShader());\r\n node.getOrCreateStateSet().setAttributeAndModes(new CullFace(CullFace.DISABLE));\r\n var blendFunc = new BlendFunc('SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA');\r\n node.getOrCreateStateSet().setAttributeAndModes(blendFunc);\r\n node.getOrCreateStateSet().setAttributeAndModes(new Depth(Depth.DISABLE));\r\n node.getOrCreateStateSet().setTextureAttributeAndModes(0, texture);\r\n\r\n var canvas = this._viewer.getGraphicContext().canvas;\r\n\r\n this._canvas = canvas;\r\n\r\n var manager = this._viewer.getInputManager();\r\n\r\n manager.group(InputGroups.STATS).addMappings({\r\n onMouseMove: ['mousemove', 'touchmove'],\r\n onMouseDown: ['mousedown', 'touchstart'],\r\n onMouseUp: ['mouseup', 'mouseout', 'touchend', 'touchcancel']\r\n },\r\n this\r\n );\r\n manager.setPriority(InputGroups.STATS, manager.getHigherPriority(InputGroups.SCENE));\r\n\r\n // canvas.addEventListener('mousemove', this.onMouseMove.bind(this));\r\n // canvas.addEventListener('mousedown', this.onMouseDown.bind(this));\r\n // canvas.addEventListener('mouseup', this.onMouseUp.bind(this));\r\n // canvas.addEventListener('mouseout', this.onMouseUp.bind(this));\r\n //\r\n // canvas.addEventListener('touchmove', this.onMouseMove.bind(this));\r\n // canvas.addEventListener('touchstart', this.onMouseDown.bind(this));\r\n // canvas.addEventListener('touchend', this.onMouseUp.bind(this));\r\n // canvas.addEventListener('touchcancel', this.onMouseUp.bind(this));\r\n },\r\n onMouseDown: function(e) {\r\n var hits = this.computeNearestIntersection(e);\r\n this._onStats = !!hits.length;\r\n if (!this._onStats) return;\r\n\r\n this._viewer.getInputManager().setEnable(InputGroups.SCENE, false);\r\n mat4.copy(this._startTransformation, this._nodeTransform.getMatrix());\r\n vec2.set(this._dragStart, e.canvasX, e.canvasY);\r\n this._dragStop[1] = this._dragStart[1];\r\n },\r\n onMouseMove: (function() {\r\n var tmpVec3 = vec3.create();\r\n return function(e) {\r\n if (!this._onStats) return;\r\n\r\n vec2.set(this._dragStop, e.canvasX, e.canvasY);\r\n var dy = this._dragStop[1] - this._dragStart[1];\r\n mat4.translate(\r\n this._nodeTransform.getMatrix(),\r\n this._startTransformation,\r\n vec3.set(tmpVec3, 0, -dy, 0)\r\n );\r\n };\r\n })(),\r\n onMouseUp: function() {\r\n this._viewer.getInputManager().setEnable(InputGroups.SCENE, true);\r\n this._onStats = false;\r\n },\r\n computeNearestIntersection: (function() {\r\n var lsi = new LineSegmentIntersector();\r\n var origIntersect = vec3.create();\r\n var dstIntersect = vec3.create();\r\n var iv = new IntersectionVisitor();\r\n iv.setIntersector(lsi);\r\n return function(e) {\r\n var x = e.glX;\r\n var y = e.glY;\r\n\r\n lsi.reset();\r\n lsi.set(vec3.set(origIntersect, x, y, 0.0), vec3.set(dstIntersect, x, y, 1.0));\r\n iv.reset();\r\n\r\n this._backgroundPicking.setNodeMask(PICKING_NODEMASK);\r\n iv.setTraversalMask(PICKING_NODEMASK);\r\n this._node.accept(iv);\r\n var hits = lsi.getIntersections();\r\n this._backgroundPicking.setNodeMask(0x0);\r\n\r\n return hits;\r\n };\r\n })(),\r\n _updateBackgroundPicking: function(x, y, w, h) {\r\n var vertexes = this._backgroundPicking.getVertexAttributeList().Vertex.getElements();\r\n vertexes[0] = x;\r\n vertexes[1] = y + h;\r\n\r\n vertexes[3] = x;\r\n vertexes[4] = y;\r\n\r\n vertexes[6] = x + w;\r\n vertexes[7] = y;\r\n\r\n vertexes[9] = x + w;\r\n vertexes[10] = y + h;\r\n this._backgroundPicking.getVertexAttributeList().Vertex.dirty();\r\n this._backgroundPicking.dirtyBound();\r\n },\r\n _generateCaptions: function() {\r\n var initialX = 0;\r\n var characterHeight = this._text.getCharacterHeight();\r\n var textCursorX = initialX;\r\n var textCursorY = this._viewport.height() - characterHeight;\r\n\r\n this._labelMaxWidth = 0;\r\n\r\n // generate background\r\n this._bufferStats.generateBackground(\r\n 0,\r\n this._viewport.height() - this._backgroundHeight,\r\n this._backgroundWidth,\r\n this._backgroundHeight\r\n );\r\n\r\n this._updateBackgroundPicking(\r\n 0,\r\n this._viewport.height() - this._backgroundHeight,\r\n this._backgroundWidth,\r\n this._backgroundHeight\r\n );\r\n\r\n var filters = this._displayFilter;\r\n for (var groupName in this._groups) {\r\n if (groupName && filters.length && filters.indexOf(groupName) === -1) continue;\r\n\r\n var group = this._groups[groupName];\r\n var groupText = '--- ' + group.caption + ' ---';\r\n var textWidth = this._bufferStats.generateText(\r\n textCursorX,\r\n textCursorY,\r\n groupText,\r\n this._text,\r\n BufferStats.whiteColor\r\n );\r\n this._labelMaxWidth = Math.max(textWidth, this._labelMaxWidth);\r\n textCursorX = initialX;\r\n textCursorY -= this._lineFactor * characterHeight;\r\n\r\n for (var j = 0; j < group.values.length; j++) {\r\n var counterName = group.values[j];\r\n var counter = this._counters[counterName];\r\n if (!counter || !counter.isDisplayable()) continue;\r\n\r\n group.textCursorY[j] = textCursorY;\r\n\r\n var text = counter._caption;\r\n // could need to split the label on multi line\r\n var nbSplits = text.length / this._maxCaptionTextLength;\r\n for (var c = 0; c < nbSplits; c++) {\r\n var start = c * this._maxCaptionTextLength;\r\n var splitText = text.substr(start, this._maxCaptionTextLength);\r\n textWidth = this._bufferStats.generateText(\r\n textCursorX,\r\n textCursorY,\r\n splitText,\r\n this._text,\r\n BufferStats.whiteColor\r\n );\r\n this._labelMaxWidth = Math.max(textWidth, this._labelMaxWidth);\r\n textCursorY -= characterHeight;\r\n textCursorX = initialX;\r\n }\r\n }\r\n textCursorY -= characterHeight;\r\n }\r\n this._bufferStats.captionsEnd();\r\n },\r\n _generateValues: function() {\r\n var characterWidth = this._text.getCharacterWidth();\r\n var valuesOffsetX = this._labelMaxWidth + 2 * characterWidth;\r\n var graphOffsetX = this._valuesMaxWidth + 2 * characterWidth;\r\n var characterHeight = this._text.getCharacterHeight();\r\n var textCursorX = valuesOffsetX;\r\n var textCursorY;\r\n\r\n var filters = this._displayFilter;\r\n var valuesMaxWidth = 0;\r\n for (var groupName in this._groups) {\r\n if (groupName && filters.length && filters.indexOf(groupName) === -1) continue;\r\n\r\n var group = this._groups[groupName];\r\n textCursorX = valuesOffsetX;\r\n\r\n for (var j = 0; j < group.values.length; j++) {\r\n var counterName = group.values[j];\r\n var counter = this._counters[counterName];\r\n if (!counter || !counter.isDisplayable()) continue;\r\n\r\n var value = counter.getAverageMs() ? counter.getAverageValue() : counter.getValue();\r\n var text;\r\n if (!Number.isInteger(value)) {\r\n text = value.toFixed(2);\r\n } else {\r\n text = value.toString();\r\n }\r\n\r\n textCursorY = group.textCursorY[j];\r\n var color = BufferStats.whiteColor;\r\n var over = counter.getOver();\r\n var below = counter.getBelow();\r\n if (over !== 0) color = value > over ? BufferStats.redColor : color;\r\n else if (below !== 0) color = value < below ? BufferStats.redColor : color;\r\n\r\n var valueWidth = this._bufferStats.generateText(\r\n textCursorX,\r\n textCursorY,\r\n text,\r\n this._text,\r\n color\r\n );\r\n valuesMaxWidth = Math.max(valueWidth, valuesMaxWidth);\r\n\r\n if (this._showGraph && counter._graph) {\r\n if (!this._historyGraph[counterName]) {\r\n this._historyGraph[counterName] = new Graph();\r\n }\r\n this._graphToDisplay.push(this._historyGraph[counterName]);\r\n this._historyGraph[counterName].setDisplayPosition(\r\n valuesOffsetX + graphOffsetX,\r\n textCursorY\r\n );\r\n this._historyGraph[counterName].addValue(value, color);\r\n }\r\n\r\n textCursorX = valuesOffsetX;\r\n }\r\n }\r\n this._bufferStats.valuesEnd();\r\n\r\n this._valuesMaxWidth = valuesMaxWidth;\r\n\r\n for (var g = 0; g < this._graphToDisplay.length; g++) {\r\n var graph = this._graphToDisplay[g];\r\n this._bufferStats.generateGraph(graph, characterHeight - 2.0);\r\n }\r\n\r\n var totalWidth = valuesOffsetX + graphOffsetX;\r\n\r\n if (this._graphToDisplay.length) totalWidth += Graph.maxGraphValue * 2 + 1;\r\n var totalHeight = this._viewport.height() - textCursorY;\r\n\r\n if (this._backgroundWidth !== totalWidth || this._backgroundHeight !== totalHeight) {\r\n this._backgroundWidth = totalWidth;\r\n this._backgroundHeight = totalHeight;\r\n this._dirtyCaptions = true;\r\n }\r\n this._graphToDisplay.length = 0;\r\n\r\n this._bufferStats.graphsEnd();\r\n this._bufferStats.update();\r\n },\r\n _checkCounterDisplayableChanged: function() {\r\n var changed = false;\r\n for (var key in this._counters) {\r\n var counter = this._counters[key];\r\n if (this._displayableCounters[key] !== counter.isDisplayable()) {\r\n this._displayableCounters[key] = counter.isDisplayable();\r\n changed = true;\r\n }\r\n }\r\n return changed;\r\n },\r\n _checkViewportChanged: function() {\r\n var x = this._viewport.x();\r\n var y = this._viewport.y();\r\n var w = this._viewport.width();\r\n var h = this._viewport.height();\r\n if (x !== this._x || y !== this._y || w !== this._width || h !== this._height) {\r\n this._x = x;\r\n this._y = y;\r\n this._width = w;\r\n this._height = h;\r\n\r\n var camera = this._node;\r\n mat4.ortho(\r\n camera.getProjectionMatrix(),\r\n this._x,\r\n this._width,\r\n this._y,\r\n this._height, -5,\r\n 5\r\n );\r\n return true;\r\n }\r\n return false;\r\n }\r\n});\r\n\r\nexport default Stats;","var values = {\r\n frame: {\r\n caption: 'Total frame time',\r\n over: 16,\r\n average: true,\r\n graph: true,\r\n max: 4\r\n },\r\n stats: {\r\n caption: 'stats',\r\n over: 1,\r\n graph: true\r\n },\r\n fps: {\r\n caption: 'Framerate (FPS)',\r\n below: 30,\r\n average: true\r\n },\r\n raf: {\r\n caption: 'Time since last rAF',\r\n average: true,\r\n avgMs: 500\r\n },\r\n update: {\r\n caption: 'update',\r\n average: true,\r\n graph: true\r\n },\r\n cull: {\r\n caption: 'cull',\r\n average: true,\r\n graph: true,\r\n max: 16\r\n },\r\n render: {\r\n caption: 'render',\r\n average: true,\r\n graph: true\r\n },\r\n glframe: {\r\n caption: 'glframe',\r\n average: true,\r\n graph: true\r\n },\r\n\r\n textureused: {\r\n caption: 'texture used'\r\n },\r\n texturereserved: {\r\n caption: 'texture reserved'\r\n },\r\n texturetotal: {\r\n caption: 'texture total'\r\n },\r\n\r\n pushstateset: {\r\n caption: 'num pushStateSet'\r\n },\r\n applyStateSet: {\r\n caption: 'num applyStateSet'\r\n },\r\n updatecallback: {\r\n caption: 'num updateCallback'\r\n },\r\n\r\n cullcamera: {\r\n caption: 'camera'\r\n },\r\n cullmatrixtransform: {\r\n caption: 'matrixTransform'\r\n },\r\n cullprojection: {\r\n caption: 'projection'\r\n },\r\n cullnode: {\r\n caption: 'node'\r\n },\r\n culllightsource: {\r\n caption: 'lightSource'\r\n },\r\n cullgeometry: {\r\n caption: 'geometry'\r\n }\r\n};\r\n\r\nvar groups = [\r\n {\r\n name: 'framerate',\r\n caption: 'Framerate',\r\n values: ['fps', 'raf']\r\n },\r\n {\r\n name: 'frameBudget',\r\n caption: 'Frame Budget',\r\n base: 'frame',\r\n values: ['frame', 'update', 'cull', 'render', 'glframe', 'stats']\r\n },\r\n {\r\n name: 'sceneGraph',\r\n caption: 'Scene Graph ',\r\n values: ['pushstateset', 'updatecallback', 'applyStateSet']\r\n },\r\n {\r\n name: 'cullVisitor',\r\n caption: 'Cull',\r\n values: [\r\n 'cullnode',\r\n 'cullmatrixtransform',\r\n 'cullcamera',\r\n 'culllighsource',\r\n 'cullprojection',\r\n 'cullgeometry'\r\n ]\r\n },\r\n {\r\n name: 'texture',\r\n caption: 'Texture Memory',\r\n values: ['texturereserved', 'textureused', 'texturetotal']\r\n }\r\n];\r\n\r\nvar config = {\r\n values: values,\r\n groups: groups\r\n};\r\n\r\nexport default config;\r\n","var WebGLRenderingContext = window.WebGLRenderingContext;\r\nvar WebGL2RenderingContext = window.WebGL2RenderingContext;\r\n\r\nvar contextList = [WebGLRenderingContext, WebGL2RenderingContext];\r\n\r\nvar glProxy = function(f, c) {\r\n return function() {\r\n c.apply(this, arguments);\r\n f.apply(this, arguments);\r\n };\r\n};\r\n\r\nvar totalDrawArraysCalls = 0,\r\n totalDrawElementsCalls = 0,\r\n totalUseProgramCalls = 0,\r\n totalFaces = 0,\r\n totalVertices = 0,\r\n totalPoints = 0,\r\n totalBindTexures = 0;\r\nvar statsVertices = 0,\r\n statsFaces = 0,\r\n statsLines = 0;\r\n\r\nvar init = function() {\r\n var hasContext = false;\r\n for (var i = 0; i < contextList.length; i++) {\r\n var WebGLContext = contextList[i];\r\n if (!WebGLContext) continue;\r\n\r\n hasContext = true;\r\n WebGLContext.prototype.drawArrays = glProxy(WebGLContext.prototype.drawArrays, function() {\r\n totalDrawArraysCalls++;\r\n if (arguments[0] === this.POINTS) totalPoints += arguments[2];\r\n else totalVertices += arguments[2];\r\n });\r\n WebGLContext.prototype.drawElements = glProxy(\r\n WebGLContext.prototype.drawElements,\r\n function() {\r\n totalDrawElementsCalls++;\r\n totalFaces += arguments[1] / 3;\r\n totalVertices += arguments[1];\r\n }\r\n );\r\n\r\n WebGLContext.prototype.useProgram = glProxy(WebGLContext.prototype.useProgram, function() {\r\n totalUseProgramCalls++;\r\n });\r\n\r\n WebGLContext.prototype.bindTexture = glProxy(\r\n WebGLContext.prototype.bindTexture,\r\n function() {\r\n totalBindTexures++;\r\n }\r\n );\r\n }\r\n return hasContext;\r\n};\r\n\r\nvar update = function(stats) {\r\n var bufferStats = stats.getBufferStats();\r\n var nbVertexes = bufferStats.getNbVertexes();\r\n var drawElements = bufferStats.getCharacterPrimitive();\r\n var drawArrays = bufferStats.getGraphPrimitive();\r\n\r\n // substracts stats from regular gl stats\r\n totalDrawElementsCalls -= 1; // one drawcall for characters\r\n if (drawArrays.getCount()) totalDrawArraysCalls -= 1; // one draw array for graph\r\n totalBindTexures -= 2;\r\n totalUseProgramCalls -= 1;\r\n totalVertices -= drawElements.getCount() + drawArrays.getCount();\r\n totalFaces -= drawElements.getCount() / 3;\r\n\r\n statsVertices = nbVertexes;\r\n statsFaces = drawElements.getCount() / 3;\r\n statsLines = drawArrays.getCount() / 2;\r\n\r\n stats.getCounter('glDrawCalls').set(totalDrawElementsCalls + totalDrawArraysCalls);\r\n stats.getCounter('glDrawElements').set(totalDrawElementsCalls);\r\n stats.getCounter('glDrawArrays').set(totalDrawArraysCalls);\r\n stats.getCounter('glBindTexture').set(totalBindTexures);\r\n stats.getCounter('glUseProgram').set(totalUseProgramCalls);\r\n stats.getCounter('glFaces').set(totalFaces);\r\n stats.getCounter('glVertices').set(totalVertices);\r\n stats.getCounter('glPoints').set(totalPoints);\r\n\r\n stats.getCounter('statsVertices').set(statsVertices);\r\n stats.getCounter('statsFaces').set(statsFaces);\r\n stats.getCounter('statsLines').set(statsLines);\r\n\r\n statsVertices = 0;\r\n statsFaces = 0;\r\n statsLines = 0;\r\n totalDrawArraysCalls = 0;\r\n totalDrawElementsCalls = 0;\r\n totalUseProgramCalls = 0;\r\n totalFaces = 0;\r\n totalVertices = 0;\r\n totalPoints = 0;\r\n totalBindTexures = 0;\r\n}.bind(this);\r\n\r\nvar config = {\r\n values: {\r\n glDrawCalls: {\r\n caption: 'drawCalls'\r\n },\r\n glDrawElements: {\r\n caption: 'drawElements'\r\n },\r\n glDrawArrays: {\r\n caption: 'drawArrays'\r\n },\r\n glBindTexture: {\r\n caption: 'bindTexture'\r\n },\r\n glUseProgram: {\r\n caption: 'useProgram'\r\n },\r\n glFaces: {\r\n caption: 'totalFaces'\r\n },\r\n glVertices: {\r\n caption: 'totalVertices'\r\n },\r\n glPoints: {\r\n caption: 'totalPoints'\r\n },\r\n statsFaces: {\r\n caption: 'statsFaces'\r\n },\r\n statsVertices: {\r\n caption: 'statsVertices'\r\n },\r\n statsLines: {\r\n caption: 'statsLines'\r\n }\r\n },\r\n groups: [\r\n {\r\n name: 'webgl',\r\n caption: 'WebGL',\r\n values: [\r\n 'glDrawCalls',\r\n 'glDrawElements',\r\n 'glDrawArrays',\r\n 'glUseProgram',\r\n 'glBindTexture',\r\n 'glFaces',\r\n 'glVertices',\r\n 'glPoints',\r\n 'statsVertices',\r\n 'statsFaces',\r\n 'statsLines'\r\n ]\r\n }\r\n ],\r\n update: update,\r\n init: init\r\n};\r\n\r\nexport default config;\r\n","import notify from '../osg/notify';\r\n\r\nvar memory = undefined;\r\n\r\nvar log1024 = Math.log(1024);\r\nvar size = function(v) {\r\n var precision = 100; //Math.pow(10, 2);\r\n var i = Math.floor(Math.log(v) / log1024);\r\n if (v === 0) i = 1;\r\n return Math.round(v * precision / Math.pow(1024, i)) / precision; // + ' ' + sizes[i];\r\n};\r\n\r\nvar init = function() {\r\n if (window.performance && window.performance.memory) memory = window.performance.memory;\r\n if (!memory || memory.totalJSHeapSize === 0) {\r\n notify.warn('Stats will not report memory, not supported by your browse');\r\n }\r\n return !!memory;\r\n};\r\n\r\nvar update = function(stats) {\r\n var usedJSHeapSize = 0;\r\n var totalJSHeapSize = 0;\r\n if (memory) {\r\n usedJSHeapSize = size(memory.usedJSHeapSize);\r\n totalJSHeapSize = size(memory.totalJSHeapSize);\r\n }\r\n stats.getCounter('browserMemory').set(usedJSHeapSize);\r\n stats.getCounter('browserMemoryTotal').set(totalJSHeapSize);\r\n};\r\n\r\nvar config = {\r\n values: {\r\n browserMemory: {\r\n caption: 'Used Memory',\r\n average: true,\r\n avgMs: 1000\r\n },\r\n browserMemoryTotal: {\r\n caption: 'Total Memory'\r\n }\r\n },\r\n groups: [{\r\n name: 'browser',\r\n caption: 'Browser',\r\n values: ['browserMemory', 'browserMemoryTotal']\r\n }],\r\n update: update,\r\n init: init\r\n};\r\n\r\nexport default config;","import notify from '../../osg/notify';\r\n\r\nvar DEFAULT_PRIORITY = 10;\r\nvar MODIFIERS = ['shift', 'alt', 'ctrl', 'meta'];\r\n\r\n/**\r\n * InputGroup\r\n * @constructor\r\n */\r\nvar InputGroup = function(inputManager, name) {\r\n // true when this group is enabled\r\n this._enabled = true;\r\n\r\n // the name of the group\r\n this._name = name;\r\n\r\n //mask attribute when a \"parent\" group is disabled.\r\n this._mask = [];\r\n\r\n // Map of for custom event names to events instances\r\n // { 'customEventName' : [event1, event2 ...]}\r\n // there is one instance of event for each customEvent / nativeEvent combination\r\n this._events = {};\r\n\r\n // Map for native event names to events instances.\r\n this._mappings = {};\r\n\r\n // reference to the inputManager\r\n this._inputManager = inputManager;\r\n\r\n // the callback to collect native events bound to this instance\r\n this._boundCallback = this._collectNativeEvents.bind(this);\r\n\r\n // the group priority (the highest priorities of the events of this group)\r\n this._priority = DEFAULT_PRIORITY;\r\n\r\n // true when the group has at least one source (used only or debug)\r\n this._hasSources = false;\r\n};\r\n\r\nInputGroup.prototype = {\r\n /**\r\n * Adds mappings to this group.\r\n * Mappings are of the form:\r\n * {\r\n * eventName: 'nativeEvent <[params...]>'\r\n * ...\r\n * }\r\n *\r\n * Listener can be a function or an object.\r\n * If it's an object the InputManager will try to bind the listener.eventName method.\r\n *\r\n * @param mappings\r\n * @param listener\r\n */\r\n addMappings: function(mappings, listener) {\r\n for (var key in mappings) {\r\n mappings[this._name + ':' + key] = mappings[key];\r\n delete mappings[key];\r\n }\r\n\r\n this._inputManager.addMappings(mappings, listener);\r\n },\r\n\r\n _collectNativeEvents: function(nativeEvent) {\r\n if (!this._enabled || this._mask.length) {\r\n return;\r\n }\r\n //nativeEvent.preventDefault();\r\n var events = this._mappings[nativeEvent.type];\r\n if (!events) {\r\n return;\r\n }\r\n for (var i = 0; i < events.length; i++) {\r\n var event = events[i];\r\n if (\r\n event._source.isEventRegistered &&\r\n !event._source.isEventRegistered(nativeEvent, event._parsedEvent)\r\n ) {\r\n continue;\r\n }\r\n event._source.populateEvent(nativeEvent, event);\r\n if (!event._nativeEvents) {\r\n event._nativeEvents = [];\r\n }\r\n if (!event._nativeEvents.length) {\r\n //event must be queued\r\n var queue = this._inputManager._queues[event._priority];\r\n if (!queue) {\r\n queue = [];\r\n this._inputManager._queues[event._priority] = queue;\r\n }\r\n queue.push(event);\r\n }\r\n event._nativeEvents.push(nativeEvent);\r\n }\r\n },\r\n\r\n _addEvent: function(nativeEvent, eventName) {\r\n // creating an event instance for each eventName / raw nativeEvent combination.\r\n var fullName = this._name + ':' + eventName;\r\n var registerEvent = false;\r\n // find or init the mapping native event/events instance for this native event\r\n var events = this._mappings[nativeEvent.name];\r\n var event;\r\n if (!events) {\r\n events = [];\r\n this._mappings[nativeEvent.name] = events;\r\n registerEvent = true;\r\n } else {\r\n // try to find an existing event that matches the new one\r\n event = this._findEvent(events, fullName, nativeEvent.raw);\r\n }\r\n\r\n // find or init the mapping eventName/events instance for this eventName\r\n var eventList = this._events[eventName];\r\n if (!eventList) {\r\n eventList = [];\r\n this._events[eventName] = eventList;\r\n }\r\n\r\n if (!event) {\r\n // event not found let's create a new one and add it to the maps\r\n event = new Event(fullName);\r\n events.push(event);\r\n eventList.push(event);\r\n }\r\n\r\n event._parsedEvent = nativeEvent;\r\n event._priority = DEFAULT_PRIORITY;\r\n\r\n // finding the source of the native event and enable the dispatch\r\n var source = this._inputManager._getSource(nativeEvent.name);\r\n if (source) {\r\n if (this._enabled && registerEvent) {\r\n source.setEnable(nativeEvent.name, this._boundCallback, true);\r\n }\r\n this._hasSources = true;\r\n event._source = source;\r\n }\r\n },\r\n\r\n _findEvent: function(list, name, nativeRaw) {\r\n for (var i = 0; i < list.length; i++) {\r\n var evt = list[i];\r\n if (evt.type === name && evt._parsedEvent.raw === nativeRaw) {\r\n return evt;\r\n }\r\n }\r\n return undefined;\r\n },\r\n\r\n _setEnable: function(enable) {\r\n this._enabled = enable;\r\n // adding / removing native events\r\n for (var nativeEvent in this._mappings) {\r\n var events = this._mappings[nativeEvent];\r\n var evt = events[0];\r\n if (!evt._source) {\r\n continue;\r\n }\r\n evt._source.setEnable(nativeEvent, this._boundCallback, enable);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * InputManager\r\n */\r\nvar InputManager = function() {\r\n // Contains all created input groups\r\n this._groups = {};\r\n\r\n // Contains all registered input sources.\r\n this._sources = [];\r\n\r\n // Event queues filled each frame with all the events to dispatch\r\n // queues[0] = [event1, event2]\r\n // queues[1] = [event3, event4]\r\n // ...\r\n // 0 is the top priority queue the higher the index the lowest the priority.\r\n // We use an array here even if some entries are undefined.\r\n // The array is the best compromise, ensuring queues order and iteration performance across browsers.\r\n this._queues = [];\r\n\r\n // initializing the default priority queue\r\n this._queues[DEFAULT_PRIORITY] = [];\r\n\r\n // the map af callbacks\r\n this._callbacks = {};\r\n\r\n // Custom parameters\r\n this._params = {};\r\n\r\n this._maskedGroups = [];\r\n\r\n window.dumpInputGroups = this._dumpInputGroups.bind(this);\r\n window.dumpEventSequence = this._dumpEventSequence.bind(this);\r\n};\r\n\r\nInputManager.prototype = {\r\n /**\r\n * Registers an InputSource.\r\n * Each time a mapping is added to the InputManager, it will try to find a suitable input source for the event,\r\n * among the input sources that have been registered.\r\n * See osgViewer/input/InputSource.js\r\n * @param source\r\n */\r\n registerInputSource: function(source) {\r\n if (!source.setEnable || !source.supportsEvent || !source.getName) {\r\n throw 'Invalid input target ' + JSON.stringify(source);\r\n }\r\n this._sources.push(source);\r\n source.setInputManager(this);\r\n },\r\n\r\n /**\r\n * Returns a registered InputSource named as the given name.\r\n * @param name the name of the input source to find.\r\n * @returns the input source or undefined if it was not found.\r\n */\r\n getInputSource: function(name) {\r\n for (var i = 0; i < this._sources.length; i++) {\r\n var source = this._sources[i];\r\n if (source.getName() === name) {\r\n return source;\r\n }\r\n }\r\n return undefined;\r\n },\r\n\r\n /**\r\n * Adds mappings to the inputManager.\r\n * Mappings are of the form:\r\n * {\r\n * 'groupName:eventName': 'nativeEvent <[params...]>'\r\n * ...\r\n * }\r\n *\r\n * Listener can be a function or an object.\r\n * If it's an object the InputManager will try to bind the listener.eventName method.\r\n *\r\n * @param mappings\r\n * @param listener\r\n */\r\n addMappings: function(mappings, listener) {\r\n for (var key in mappings) {\r\n var nativeEvents = mappings[key];\r\n var groupEvent = key.split(':');\r\n if (groupEvent.length !== 2) {\r\n throw \"Mapping should be of the form 'group:methodName': ['nativeevent1’, 'nativeevent2',...] \";\r\n }\r\n var group = this._getOrCreateGroup(groupEvent[0]);\r\n\r\n var callback;\r\n var eventName = groupEvent[1];\r\n if (listener) {\r\n if (typeof listener === 'object') {\r\n callback = listener[eventName];\r\n if (!callback || typeof callback !== 'function') {\r\n throw 'Cannot find method ' + eventName + ' on ' + listener;\r\n }\r\n callback = callback.bind(listener);\r\n } else if (typeof listener === 'function') {\r\n callback = listener;\r\n } else {\r\n throw 'Invalid listener ' + listener;\r\n }\r\n }\r\n var parsedEvent;\r\n if (typeof nativeEvents === 'string') {\r\n parsedEvent = this._parseNativeEvent(nativeEvents);\r\n group._addEvent(parsedEvent, eventName);\r\n } else {\r\n for (var i = 0; i < nativeEvents.length; i++) {\r\n var nativeEvent = nativeEvents[i];\r\n parsedEvent = this._parseNativeEvent(nativeEvent);\r\n group._addEvent(parsedEvent, eventName);\r\n }\r\n }\r\n\r\n // registering the callback for the new event\r\n this._callbacks[group._name + ':' + eventName] = callback;\r\n }\r\n },\r\n\r\n /**\r\n * Returns a group with the given name.\r\n * Note that this method looks up for an existing group with the given name, and creates it is not found.\r\n * @param name the name of the group\r\n * @returns the group.\r\n */\r\n group: function(name) {\r\n return this._getOrCreateGroup(name);\r\n },\r\n\r\n /**\r\n * Enables or disables the group with the given name.\r\n * @param groupName the group name\r\n * @param enable true to enable, false to disable.\r\n */\r\n setEnable: function(groupName, enable) {\r\n var group = this._groups[groupName];\r\n if (group) {\r\n group._setEnable(enable);\r\n }\r\n\r\n var index;\r\n //check for partial groups.\r\n for (var key in this._groups) {\r\n group = this._groups[key];\r\n\r\n if (enable) {\r\n // remove the group name from the mask\r\n index = group._mask.indexOf(groupName);\r\n if (index >= 0) {\r\n group._mask.splice(index, 1);\r\n this._maskedGroups.splice(this._maskedGroups.indexOf(groupName), 1);\r\n }\r\n } else {\r\n // add the group to the mask\r\n index = group._name.indexOf(groupName);\r\n if (index === 0 && group._name[index + groupName.length] === '.') {\r\n group._mask.push(groupName);\r\n this._maskedGroups.push(groupName);\r\n }\r\n }\r\n }\r\n if (!enable) {\r\n //discard all queued event emitted from this group\r\n for (var i = 0; i < this._queues.length; i++) {\r\n var queue = this._queues[i];\r\n if (!queue) {\r\n continue;\r\n }\r\n for (var j = queue.length - 1; j >= 0; j--) {\r\n var evt = queue[j];\r\n if (evt.type.indexOf(groupName) >= 0) {\r\n queue.splice(j, 1);\r\n evt._nativeEvents.length = 0;\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Sets an event or a group priority\r\n * The priority must be a positive number\r\n * 0 being the highest priority.\r\n *\r\n * @param eventName\r\n * @param priority\r\n */\r\n setPriority: function(eventName, priority) {\r\n var groupEvent = eventName.split(':');\r\n if (priority < 0) {\r\n throw 'priority must be a positive number';\r\n }\r\n var group = this._groups[groupEvent[0]];\r\n\r\n var event, eventList, i;\r\n if (group && groupEvent[1]) {\r\n // setPriority on a specific event\r\n eventList = group._events[groupEvent[1]];\r\n for (i = 0; i < eventList.length; i++) {\r\n event = eventList[i];\r\n event._priority = priority;\r\n }\r\n if (group._priority > priority) {\r\n group._priority = priority;\r\n }\r\n } else {\r\n // set Priority on a group, setting priority on all group's events.\r\n for (var key in this._groups) {\r\n group = this._groups[key];\r\n if (group._name.indexOf(eventName) >= 0) {\r\n for (var evt in group._events) {\r\n eventList = group._events[evt];\r\n for (i = 0; i < eventList.length; i++) {\r\n event = eventList[i];\r\n event._priority = priority;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Return a higher priority than the priority of the group with the given name.\r\n * @param groupName the name of the group\r\n * @returns {number} the priority.\r\n */\r\n getHigherPriority: function(groupName) {\r\n var priority = DEFAULT_PRIORITY;\r\n for (var key in this._groups) {\r\n var group = this._groups[key];\r\n if (group._name.indexOf(groupName) >= 0) {\r\n if (group._priority < priority) {\r\n priority = group._priority;\r\n }\r\n }\r\n }\r\n return priority > 0 ? priority - 1 : 0;\r\n },\r\n\r\n /**\r\n * Gets the parameter for the given name\r\n * @param name the name of the parameter\r\n * @returns {*} the parameter value, undefined if not found\r\n */\r\n getParam: function(name) {\r\n return this._params[name];\r\n },\r\n\r\n /**\r\n * Sets a parameter with the given name and the given value.\r\n * @param name the name of the parameter\r\n * @param value the value of the parameter\r\n */\r\n setParam: function(name, value) {\r\n this._params[name] = value;\r\n },\r\n\r\n /**\r\n * Disables all groups on the manager and clear all listeners attached to DOM elements.\r\n */\r\n cleanup: function() {\r\n for (var key in this._groups) {\r\n var group = this._groups[key];\r\n group._setEnable(false);\r\n }\r\n },\r\n\r\n _parseNativeEvent: function(event) {\r\n var tokens = event.split(' ');\r\n var parsedEvent = {};\r\n parsedEvent.name = tokens[0];\r\n var i;\r\n for (i = 1; i < tokens.length; i++) {\r\n var token = tokens[i];\r\n var value = true;\r\n if (token.indexOf('!') === 0) {\r\n value = false;\r\n token = token.substring(1, token.length);\r\n }\r\n if (MODIFIERS.indexOf(token) >= 0) {\r\n parsedEvent[token] = value;\r\n } else {\r\n parsedEvent.action = token.toLowerCase();\r\n }\r\n }\r\n\r\n if (parsedEvent.action) {\r\n // user may have used ShiftRight or ShiftLeft to specify which shift key he wants to trigger the event.\r\n // in that case adding the shift modifier as the browser will report it like that.\r\n for (i = 0; i < MODIFIERS.length; i++) {\r\n var mod = MODIFIERS[i];\r\n if (parsedEvent.action.indexOf(mod) === 0) {\r\n parsedEvent[mod] = true;\r\n }\r\n }\r\n }\r\n\r\n if (parsedEvent.name.indexOf('key') === 0 && !parsedEvent.action && tokens.length > 1) {\r\n // Key down event, the user wants one of the modifier keys to be the action\r\n // we take the last one\r\n parsedEvent.action = tokens[tokens.length - 1];\r\n }\r\n\r\n parsedEvent.raw = event;\r\n\r\n return parsedEvent;\r\n },\r\n\r\n _getOrCreateGroup: function(name) {\r\n var group = this._groups[name];\r\n if (!group) {\r\n group = new InputGroup(this, name);\r\n this._groups[name] = group;\r\n //check if the group should be masked\r\n for (var i = 0; i < this._maskedGroups.length; i++) {\r\n var mask = this._maskedGroups[i];\r\n if (name.indexOf(mask) === 0) {\r\n group._mask.push(mask);\r\n }\r\n }\r\n }\r\n return group;\r\n },\r\n\r\n /**\r\n * Internal use only.\r\n */\r\n update: function() {\r\n var i;\r\n //polling sources if relevant\r\n for (i = 0; i < this._sources.length; i++) {\r\n var source = this._sources[i];\r\n if (source.poll) {\r\n source.poll();\r\n }\r\n }\r\n\r\n //dispatch all queued events by priority order\r\n for (i = 0; i < this._queues.length; i++) {\r\n var queue = this._queues[i];\r\n if (!queue) {\r\n continue;\r\n }\r\n for (var j = 0; j < queue.length; j++) {\r\n var event = queue[j];\r\n this._callbacks[event.type](event);\r\n //window.dispatchEvent(event);\r\n event._nativeEvents.length = 0;\r\n }\r\n //flush the queue\r\n queue.length = 0;\r\n }\r\n },\r\n\r\n _getSource: function(triggerName) {\r\n for (var i = 0; i < this._sources.length; i++) {\r\n var source = this._sources[i];\r\n if (source.supportsEvent(triggerName)) {\r\n return source;\r\n }\r\n }\r\n },\r\n\r\n _dumpInputGroups: function(filter, onlyEnabled) {\r\n if (filter === true) {\r\n onlyEnabled = filter;\r\n filter = undefined;\r\n }\r\n for (var groupName in this._groups) {\r\n if (filter && groupName.indexOf(filter) < 0) {\r\n continue;\r\n }\r\n var group = this._groups[groupName];\r\n var enabled = group._enabled && !group._mask.length && group._hasSources;\r\n if (onlyEnabled && !enabled) {\r\n continue;\r\n }\r\n notify.groupCollapsed(\r\n '%c' + groupName + (enabled ? ' (enabled)' : ' (disabled)'),\r\n enabled ? '' : 'color: #888888'\r\n );\r\n\r\n notify.log('enabled:', group._enabled);\r\n notify.log('masks:', group._mask);\r\n notify.log('input sources:', group._hasSources);\r\n notify.group('events');\r\n for (var evt in group._events) {\r\n notify.groupCollapsed(evt);\r\n var events = group._events[evt];\r\n for (var i = 0; i < events.length; i++) {\r\n var event = events[i];\r\n var str =\r\n '%c' +\r\n event._parsedEvent.raw +\r\n ' (' +\r\n (event._source ? event._source.getName() : 'unknown source') +\r\n ')';\r\n var color = event._source ? '' : 'color: #888888';\r\n notify.log(str, color);\r\n }\r\n notify.groupCollapsed('function');\r\n notify.log(this._callbacks[group._name + ':' + evt]);\r\n notify.groupEnd();\r\n notify.groupEnd();\r\n }\r\n\r\n notify.groupEnd();\r\n notify.groupEnd();\r\n }\r\n },\r\n\r\n _dumpEventSequence: function(filter, onlyEnabled) {\r\n var eventList = [];\r\n if (filter === true) {\r\n onlyEnabled = filter;\r\n filter = undefined;\r\n }\r\n var enabled;\r\n for (var groupKey in this._groups) {\r\n var group = this._groups[groupKey];\r\n enabled = group._enabled && !group._mask.length && group._hasSources;\r\n if (onlyEnabled && !enabled) {\r\n continue;\r\n }\r\n for (var eventKey in group._events) {\r\n var events = group._events[eventKey];\r\n var list = eventList[events[0]._priority];\r\n if (!list) {\r\n list = [];\r\n eventList[events[0]._priority] = list;\r\n }\r\n for (var i = 0; i < events.length; i++) {\r\n var ev = events[i];\r\n if (!filter || (filter && ev._parsedEvent.raw.indexOf(filter) >= 0)) {\r\n list.push({\r\n name: ev.type,\r\n group: group._name,\r\n on: ev._parsedEvent.raw,\r\n enabled: group._enabled && !group._mask.length && !!ev._source,\r\n source: ev._source ?\r\n '(' + ev._source.getName() + ')' : '(unknown source)'\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (var j = 0; j < eventList.length; j++) {\r\n var evts = eventList[j];\r\n if (evts) {\r\n notify.group('priority ' + j);\r\n var prevEvt;\r\n for (var k = 0; k < evts.length; k++) {\r\n var evt = evts[k];\r\n if (k !== 0 && prevEvt !== evt.name) {\r\n notify.groupEnd();\r\n }\r\n if (prevEvt !== evt.name) {\r\n var grp = this._groups[evt.group];\r\n enabled = grp._enabled && !grp._mask.length && grp._hasSources;\r\n notify.groupCollapsed('%c' + evt.name, enabled ? '' : 'color:#888888');\r\n }\r\n prevEvt = evt.name;\r\n notify.groupCollapsed(\r\n '%c' + evt.on + ' ' + evt.source,\r\n evt.enabled ? '' : 'color:#888888'\r\n );\r\n notify.log(this._callbacks[evt.name]);\r\n notify.groupEnd();\r\n }\r\n notify.groupEnd();\r\n notify.groupEnd();\r\n }\r\n }\r\n }\r\n};\r\n\r\nexport default InputManager;","/**\r\n * Abstract InputSource\r\n * @param canvas\r\n * @constructor\r\n */\r\nvar InputSource = function(target) {\r\n this._target = target;\r\n this._supportedEvents = [];\r\n};\r\nInputSource.prototype = {\r\n supportsEvent: function(eventName) {\r\n for (var i = 0; i < this._supportedEvents.length; i++) {\r\n var event = this._supportedEvents[i];\r\n if (eventName.indexOf(event) === 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n\r\n setInputManager: function(inputManager) {\r\n this._inputManager = inputManager;\r\n }\r\n};\r\n\r\nexport default InputSource;\r\n","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\nimport { vec2 } from '../../../osg/glMatrix';\r\n\r\n// Mouse Wheel event reports different values depending on the browser and OS.\r\n// Standard event \"wheel\" should report a deltaX value. This value is totally inconsistent depending on the browser and the os.\r\n// Chrome has a consistent mouseDelta value across OS (120 for a wheel step).\r\n// Edge has the same mouseDelta value than chrome.\r\n// Safari has the same mouseDelta value than chrome.\r\nvar mouseDeltaFactor = 120;\r\n// Firefox has no mouseDelta and reports a deltaY attribute that is 3 times higher on linux and win (compared to mac) (1 on mac 3 otherwise)\r\n// also deltaY direction is backward compared to wheelDelta\r\nvar deltaYFactor = navigator.platform.indexOf('Mac') === 0 ? -1 : -3;\r\n\r\n/**\r\n * Standard Mouse Event handled directly on the canvas.\r\n * @param canvas\r\n * @param scrollwheel\r\n * @constructor\r\n */\r\nvar InputSourceMouse = function(canvas, options) {\r\n InputSource.call(this, canvas);\r\n this._defaultRatio = vec2.fromValues(1.0, 1.0);\r\n\r\n this._supportedEvents = [\r\n 'click',\r\n 'contextmenu',\r\n 'dblclick',\r\n 'mousedown',\r\n 'mouseenter',\r\n 'mouseleave',\r\n 'mousemove',\r\n 'mouseover',\r\n 'mouseout',\r\n 'mouseup'\r\n ];\r\n\r\n if (!options || options.scrollwheel !== false) {\r\n this._supportedEvents.push('wheel');\r\n }\r\n};\r\nutils.createPrototypeObject(\r\n InputSourceMouse,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'Mouse';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n // here we could parse the name of the event.\r\n // if the name is for example 'click left', only dispatch the event if the left button has ben clicked.\r\n // This would remove a lot of boiler plate from client code.\r\n\r\n if (enable) {\r\n this._target.addEventListener(name, callback);\r\n } else {\r\n this._target.removeEventListener(name, callback);\r\n }\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n // desktop - mouse\r\n customEvent.canvasX = ev.offsetX === undefined ? ev.layerX : ev.offsetX;\r\n customEvent.canvasY = ev.offsetY === undefined ? ev.layerY : ev.offsetY;\r\n\r\n // x, y coordinates in the gl viewport\r\n var ratio = this._inputManager.getParam('pixelRatio');\r\n if (!ratio) ratio = this._defaultRatio;\r\n customEvent.glX = customEvent.canvasX * ratio[0];\r\n customEvent.glY = (this._target.clientHeight - customEvent.canvasY) * ratio[1];\r\n\r\n customEvent.clientX = ev.clientX;\r\n customEvent.clientY = ev.clientY;\r\n customEvent.screenX = ev.screenX;\r\n customEvent.screenX = ev.screenX;\r\n customEvent.pageX = ev.pageX;\r\n customEvent.pageY = ev.pageY;\r\n\r\n // modifiers\r\n customEvent.ctrlKey = ev.ctrlKey;\r\n customEvent.shiftKey = ev.shiftKey;\r\n customEvent.altKey = ev.altKey;\r\n customEvent.metaKey = ev.metaKey;\r\n\r\n //buttons\r\n customEvent.button = ev.button;\r\n customEvent.buttons = ev.buttons;\r\n\r\n if (ev.type === 'wheel') {\r\n if (ev.wheelDelta !== undefined) {\r\n //chrome / safari / edge browser wheel delta\r\n customEvent.deltaY = ev.wheelDelta / mouseDeltaFactor;\r\n } else if (ev.deltaMode === 1) {\r\n // firefox with the standard wheel event (no wheelDelta)\r\n customEvent.deltaY = ev.deltaY / deltaYFactor;\r\n } else {\r\n // firefox with the track pad (no wheelDelta), events are fired 10 times the rate.\r\n customEvent.deltaY = ev.deltaY / (deltaYFactor * 10);\r\n }\r\n customEvent.deltaMode = ev.deltaMode;\r\n customEvent.deltaX = ev.deltaX;\r\n customEvent.deltaZ = ev.deltaZ;\r\n }\r\n },\r\n\r\n isEventRegistered: function(nativeEvent, parsedEvent) {\r\n nativeEvent.preventDefault();\r\n if (parsedEvent.action && nativeEvent.button !== parseInt(parsedEvent.action)) {\r\n return false;\r\n }\r\n if (parsedEvent.ctrl !== undefined && nativeEvent.ctrlKey !== parsedEvent.ctrl) {\r\n return false;\r\n }\r\n if (parsedEvent.shift !== undefined && nativeEvent.shiftKey !== parsedEvent.shift) {\r\n return false;\r\n }\r\n if (parsedEvent.alt !== undefined && nativeEvent.altKey !== parsedEvent.alt) {\r\n return false;\r\n }\r\n if (parsedEvent.meta !== undefined && nativeEvent.metaKey !== parsedEvent.meta) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceMouse'\r\n);\r\n\r\nexport default InputSourceMouse;","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\n\r\n/**\r\n * Standard Keyboard Event handled directly on the canvas.\r\n * @param canvas\r\n * @constructor\r\n */\r\nvar InputSourceKeyboard = function(canvas) {\r\n InputSource.call(this, canvas);\r\n this._supportedEvents = ['keydown', 'keyup', 'keypress'];\r\n};\r\nutils.createPrototypeObject(\r\n InputSourceKeyboard,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'Keyboard';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n if (enable) {\r\n this._target.addEventListener(name, callback);\r\n } else {\r\n this._target.removeEventListener(name, callback);\r\n }\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n customEvent.key = ev.key;\r\n customEvent.keyCode = ev.keyCode;\r\n customEvent.code = ev.code;\r\n customEvent.location = ev.location;\r\n customEvent.repeat = ev.repeat;\r\n\r\n // modifiers\r\n customEvent.ctrlKey = ev.ctrlKey;\r\n customEvent.shiftKey = ev.shiftKey;\r\n customEvent.altKey = ev.altKey;\r\n customEvent.metaKey = ev.metaKey;\r\n },\r\n\r\n isEventRegistered: function(nativeEvent, parsedEvent) {\r\n if (!parsedEvent.action) {\r\n return true;\r\n }\r\n\r\n // IE11 has no nativeEvent.key when hitting \"modifer\" (shift)\r\n if (nativeEvent.key && nativeEvent.key.toLowerCase() !== parsedEvent.action) {\r\n if (nativeEvent.code.toLowerCase() !== parsedEvent.action) {\r\n return false;\r\n }\r\n }\r\n if (parsedEvent.ctrl !== undefined && nativeEvent.ctrlKey !== parsedEvent.ctrl) {\r\n return false;\r\n }\r\n if (parsedEvent.shift !== undefined && nativeEvent.shiftKey !== parsedEvent.shift) {\r\n return false;\r\n }\r\n if (parsedEvent.alt !== undefined && nativeEvent.altKey !== parsedEvent.alt) {\r\n return false;\r\n }\r\n if (parsedEvent.meta !== undefined && nativeEvent.metaKey !== parsedEvent.meta) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceKeyboard'\r\n);\r\n\r\nexport default InputSourceKeyboard;","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\nimport notify from '../../../osg/notify';\r\n\r\n/**\r\n * WebVR Hmd device input handling.\r\n * @param canvas\r\n * @constructor\r\n */\r\nvar InputSourceWebVR = function(elem, options) {\r\n InputSource.call(this);\r\n this._supportedEvents = [\r\n 'vrdisplayposechanged',\r\n 'vrdisplayconnected',\r\n 'vrdisplaynotfound',\r\n 'vrdisplaydisconnected'\r\n ];\r\n\r\n this._callbacks = {};\r\n this._events = {};\r\n for (var i = 0; i < this._supportedEvents.length; i++) {\r\n var eventName = this._supportedEvents[i];\r\n var event = new Event(eventName);\r\n this._events[eventName] = event;\r\n }\r\n this._nbCallbacks = 0;\r\n // We poll the device at regular interval, if ever a headset is plugged in.\r\n // 3 seconds default poll interval\r\n // If the pollInterval is set to 0 or less the polling is disabled and the user\r\n // will have to poll it manually with the pollHeadset method\r\n this._pollInterval =\r\n options && options.pollInterval !== undefined ? options.pollInterval : 3000;\r\n};\r\nutils.createPrototypeObject(\r\n InputSourceWebVR,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'WebVR';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n var callbacks = this._callbacks[name];\r\n if (!callbacks) {\r\n callbacks = [];\r\n this._callbacks[name] = callbacks;\r\n }\r\n var index = callbacks.indexOf(callback);\r\n if (enable) {\r\n if (index < 0) {\r\n callbacks.push(callback);\r\n this._nbCallbacks++;\r\n // only poll for device if we have callbacks.\r\n this._schedulePolling();\r\n }\r\n } else {\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n this._nbCallbacks--;\r\n if (!this._nbCallbacks) {\r\n // no more callbacks let's stop polling\r\n this._cancelPolling();\r\n }\r\n }\r\n }\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n if (ev.vrDisplay) {\r\n customEvent.vrDisplay = ev.vrDisplay;\r\n return;\r\n }\r\n customEvent.pose = ev.pose;\r\n customEvent.sitToStandMatrix = ev.sitToStandMatrix;\r\n customEvent.worldFactor = this._inputManager.getParam('worldFactor');\r\n if (!customEvent.worldFactor) customEvent.worldFactor = 1.0;\r\n },\r\n\r\n _schedulePolling: function() {\r\n if (this._pollInterval > 0 && this._pollingTimeout === undefined) {\r\n this._pollingTimeout = setInterval(this.pollHeadset.bind(this), this._pollInterval);\r\n }\r\n },\r\n\r\n _cancelPolling: function() {\r\n if (this._pollingTimeout !== undefined) {\r\n clearInterval(this._pollingTimeout);\r\n }\r\n },\r\n\r\n pollHeadset: function() {\r\n if (!navigator.getVRDisplays) {\r\n this._hmd = undefined;\r\n this._frameData = undefined;\r\n this.triggerNotFoundEvent();\r\n return;\r\n }\r\n\r\n var self = this;\r\n navigator\r\n .getVRDisplays()\r\n .then(\r\n function(displays) {\r\n if (displays.length === 0) {\r\n this.triggerNotFoundEvent();\r\n return;\r\n }\r\n\r\n if (self._hmd === displays[0]) {\r\n // still the same display nothing to do\r\n return;\r\n }\r\n\r\n notify.log('Found a VR display');\r\n //fire the disconnect event\r\n var event = self._events['vrdisplaydisconnected'];\r\n event.vrDisplay = self._hmd;\r\n this._dispatchEvent(event, self._callbacks['vrdisplaydisconnected']);\r\n\r\n //fire the connect event\r\n event = self._events['vrdisplayconnected'];\r\n event.vrDisplay = displays[0];\r\n this._dispatchEvent(event, self._callbacks['vrdisplayconnected']);\r\n\r\n self._hmd = displays[0];\r\n self._frameData = new window.VRFrameData();\r\n }.bind(this)\r\n )\r\n .catch(function(ex) {\r\n this._hmd = undefined;\r\n this._frameData = undefined;\r\n this.triggerNotFoundEvent();\r\n notify.warn(ex.message);\r\n });\r\n },\r\n\r\n triggerNotFoundEvent: function() {\r\n if (this._pollInterval > 0) {\r\n // we are in auto polling mode, don't trigger the event\r\n return;\r\n }\r\n\r\n // in case of manual polling we trigger an event when no display was found\r\n var event = this._events['vrdisplaynotfound'];\r\n this._dispatchEvent(event, this._callbacks['vrdisplaynotfound']);\r\n },\r\n\r\n setPollInterval: function(interval) {\r\n this._pollInterval = interval;\r\n },\r\n\r\n _dispatchEvent: function(event, callbacks) {\r\n if (!callbacks) return;\r\n\r\n for (var i = 0; i < callbacks.length; i++) {\r\n var callback = callbacks[i];\r\n callback(event);\r\n }\r\n },\r\n\r\n poll: function() {\r\n if (!this._hmd) {\r\n return;\r\n }\r\n\r\n var callbacks = this._callbacks['vrdisplayposechanged'];\r\n if (!callbacks || !callbacks.length) {\r\n return;\r\n }\r\n\r\n //hmd movement\r\n this._hmd.getFrameData(this._frameData);\r\n\r\n var pose = this._frameData.pose;\r\n\r\n if (!pose) return;\r\n\r\n // WebVR up vector is Y\r\n // OSGJS up vector is Z\r\n\r\n var sitToStand =\r\n this._hmd.stageParameters && this._hmd.stageParameters.sittingToStandingTransform;\r\n\r\n var event = this._events['vrdisplayposechanged'];\r\n event.pose = pose;\r\n event.sitToStandMatrix = sitToStand;\r\n\r\n this._dispatchEvent(event, callbacks);\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceWebVR'\r\n);\r\n\r\nexport default InputSourceWebVR;","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\n\r\n/**\r\n * Game Pads input handling\r\n * @constructor\r\n */\r\nvar InputSourceGamePad = function() {\r\n InputSource.call(this);\r\n this._target = window;\r\n this._supportedEvents = [\r\n 'buttondown',\r\n 'buttonup',\r\n 'buttonvalue',\r\n 'axis',\r\n 'gamepadconnected',\r\n 'gamepaddisconnected'\r\n ];\r\n this._callbacks = {};\r\n this._nbCallbacks = 0;\r\n this._gamePadState = [];\r\n\r\n this._valueThreshold = 0.05;\r\n\r\n window.addEventListener(\r\n 'gamepadconnected',\r\n function(e) {\r\n this._newGamePad(e.gamepad);\r\n this._onConnectionStateChange(e, 'gamepadconnected');\r\n }.bind(this)\r\n );\r\n\r\n window.addEventListener(\r\n 'gamepaddisconnected',\r\n function(e) {\r\n this._previousState[e.gamepad.index] = undefined;\r\n this._onConnectionStateChange(e, 'gamepaddisconnected');\r\n }.bind(this)\r\n );\r\n};\r\nutils.createPrototypeObject(\r\n InputSourceGamePad,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'GamePad';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n var callbacks = this._callbacks[name];\r\n if (!callbacks) {\r\n callbacks = [];\r\n this._callbacks[name] = callbacks;\r\n }\r\n var index = callbacks.indexOf(callback);\r\n if (enable) {\r\n if (index < 0) {\r\n callbacks.push(callback);\r\n this._nbCallbacks++;\r\n }\r\n } else {\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n this._nbCallbacks--;\r\n }\r\n }\r\n },\r\n\r\n _onConnectionStateChange: function(event, state) {\r\n var callback = this._callbacks[state];\r\n if (!callback) {\r\n return;\r\n }\r\n callback(event);\r\n },\r\n\r\n _newGamePad: function(gamepad) {\r\n var state = {\r\n buttons: []\r\n };\r\n state._buttonEvents = [];\r\n state._axisEvents = [];\r\n var i;\r\n for (i = 0; i < gamepad.buttons.length; i++) {\r\n state._buttonEvents[i] = {\r\n buttondown: this._initEvent('buttondown', i, gamepad.index, 'button'),\r\n buttonup: this._initEvent('buttonup', i, gamepad.index, 'button'),\r\n buttonvalue: this._initEvent('buttonvalue', i, gamepad.index, 'button')\r\n };\r\n }\r\n\r\n for (i = 0; i < gamepad.axes.length; i++) {\r\n state._axisEvents[i] = {\r\n axis: this._initEvent('axis', i, gamepad.index, 'axis')\r\n };\r\n }\r\n\r\n this._gamePadState[gamepad.index] = state;\r\n },\r\n\r\n setValueThreshold: function(threshold) {\r\n this._valueThreshold = threshold;\r\n },\r\n\r\n _initEvent: function(name, index, gamepadIndex, type) {\r\n var event = new Event(name);\r\n event[type] = index;\r\n event.gamepadIndex = gamepadIndex;\r\n return event;\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n customEvent.gamepadIndex = ev.gamepadIndex;\r\n if (ev.button !== undefined) {\r\n customEvent.button = ev.button;\r\n customEvent.value = ev.value;\r\n }\r\n\r\n if (ev.axis !== undefined) {\r\n customEvent.axis = ev.axis;\r\n customEvent.value = ev.value;\r\n }\r\n },\r\n\r\n isEventRegistered: function(nativeEvent, parsedEvent) {\r\n if (!parsedEvent.action) {\r\n return true;\r\n }\r\n\r\n var value = parseInt(parsedEvent.action);\r\n\r\n if (nativeEvent.button !== undefined && nativeEvent.button !== value) {\r\n return false;\r\n }\r\n\r\n if (nativeEvent.axis !== undefined && nativeEvent.axis !== value) {\r\n return false;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n _fireCallbacks: function(callbacks, event) {\r\n for (var i = 0; i < callbacks.length; i++) {\r\n callbacks[i](event);\r\n }\r\n },\r\n\r\n poll: function() {\r\n if (!this._nbCallbacks) {\r\n return;\r\n }\r\n\r\n var gamepads = navigator.getGamepads();\r\n\r\n if (!gamepads) {\r\n return;\r\n }\r\n\r\n for (var i = 0; i < gamepads.length; i++) {\r\n var gamepad = gamepads[i];\r\n\r\n if (!gamepad) continue;\r\n\r\n var state = this._gamePadState[i];\r\n\r\n if (!state) {\r\n continue;\r\n }\r\n\r\n var buttonDownCallbacks = this._callbacks['buttondown'];\r\n var buttonUpCallbacks = this._callbacks['buttonup'];\r\n var buttonValueCallbacks = this._callbacks['buttonvalue'];\r\n if (buttonDownCallbacks || buttonUpCallbacks || buttonValueCallbacks) {\r\n for (var j = 0; j < gamepad.buttons.length; j++) {\r\n var button = gamepad.buttons[j];\r\n var btnDownEvent = state._buttonEvents[j].buttondown;\r\n btnDownEvent.value = button.value;\r\n var btnUpEvent = state._buttonEvents[j].buttonup;\r\n btnUpEvent.value = button.value;\r\n if (button.pressed && !state.buttons[j]) {\r\n if (buttonDownCallbacks && buttonDownCallbacks.length) {\r\n this._fireCallbacks(buttonDownCallbacks, btnDownEvent);\r\n }\r\n state.buttons[j] = button.pressed;\r\n }\r\n if (!button.pressed && state.buttons[j]) {\r\n //button was pressed but not anymore\r\n if (buttonUpCallbacks && buttonUpCallbacks.length) {\r\n this._fireCallbacks(buttonUpCallbacks, btnUpEvent);\r\n }\r\n state.buttons[j] = false;\r\n }\r\n\r\n if (button.pressed && buttonValueCallbacks && buttonValueCallbacks.length) {\r\n var btnValueEvent = state._buttonEvents[j].buttonvalue;\r\n btnValueEvent.value = button.value;\r\n if (Math.abs(button.value) >= this._valueThreshold) {\r\n this._fireCallbacks(buttonValueCallbacks, btnValueEvent);\r\n }\r\n }\r\n }\r\n }\r\n\r\n var axisCallback = this._callbacks['axis'];\r\n if (!axisCallback) {\r\n continue;\r\n }\r\n\r\n for (j = 0; j < gamepad.axes.length; j++) {\r\n var axis = gamepad.axes[j];\r\n var axisValueEvent = state._axisEvents[j].axis;\r\n axisValueEvent.value = axis;\r\n if (Math.abs(axis) >= this._valueThreshold) {\r\n this._fireCallbacks(axisCallback, axisValueEvent);\r\n }\r\n }\r\n }\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceGamePad'\r\n);\r\n\r\nexport default InputSourceGamePad;","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\n\r\n/**\r\n * Device Orientation input handling\r\n * @constructor\r\n */\r\nvar InputSourceDeviceOrientation = function() {\r\n InputSource.call(this);\r\n this._target = window;\r\n this._callbacks = [];\r\n this._nbCallbacks = 0;\r\n this._event = new Event('deviceorientation');\r\n this._supportedEvents = ['deviceorientation', 'orientationchange'];\r\n this._update = this.onDeviceOrientation.bind(this);\r\n};\r\nutils.createPrototypeObject(\r\n InputSourceDeviceOrientation,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'DeviceOrientation';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n if (name === 'orientationchange') {\r\n if (enable) {\r\n this._target.addEventListener(name, callback);\r\n } else {\r\n this._target.removeEventListener(name, callback);\r\n }\r\n return;\r\n }\r\n\r\n var callbacks = this._callbacks;\r\n var index = callbacks.indexOf(callback);\r\n if (enable) {\r\n if (index < 0) {\r\n callbacks.push(callback);\r\n this._nbCallbacks++;\r\n }\r\n } else {\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n this._nbCallbacks--;\r\n }\r\n }\r\n if (this._nbCallbacks === 1) {\r\n window.addEventListener(name, this._update);\r\n }\r\n if (this._nbCallbacks === 0) {\r\n window.removeEventListener(name, this._update);\r\n }\r\n },\r\n\r\n onDeviceOrientation: function(ev) {\r\n this.populateEvent(ev, this._event);\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n customEvent.absolute = ev.absolute;\r\n customEvent.alpha = ev.alpha;\r\n customEvent.beta = ev.beta;\r\n customEvent.gamma = ev.gamma;\r\n\r\n customEvent.screenOrientation = window.orientation;\r\n },\r\n\r\n isEventRegistered: function(ev) {\r\n if (ev.type === 'deviceorientation') {\r\n if (ev.alpha === null || ev.alpha === undefined) {\r\n return false;\r\n }\r\n } else {\r\n if (window.orientation === null || window.orientation === undefined) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n },\r\n\r\n poll: function() {\r\n if (!this._nbCallbacks) {\r\n return;\r\n }\r\n\r\n for (var i = 0; i < this._callbacks.length; i++) {\r\n this._callbacks[i](this._event);\r\n }\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceDeviceOrientation'\r\n);\r\n\r\nexport default InputSourceDeviceOrientation;","import utils from '../../../osg/utils';\r\nimport InputSource from './InputSource';\r\nimport Hammer from 'hammerjs';\r\nimport { vec2 } from '../../../osg/glMatrix';\r\n\r\n/**\r\n * Handles standard touch events and advanced touch events through Hammer.js\r\n * @param canvas\r\n * @param hammer\r\n * @constructor\r\n */\r\nvar InputSourceTouchScreen = function(canvas) {\r\n InputSource.call(this, canvas);\r\n this._defaultRatio = vec2.fromValues(1.0, 1.0);\r\n\r\n this._hammerEvents = [\r\n 'pan',\r\n 'pinch',\r\n 'press',\r\n 'rotate',\r\n 'swipe',\r\n 'doubletap',\r\n 'doubletap2fingers',\r\n 'singletap'\r\n ];\r\n this._supportedEvents = ['touchstart', 'touchend', 'touchcancel', 'touchmove'];\r\n\r\n this._hammer = new Hammer.Manager(canvas);\r\n\r\n // defaults: { event: 'pan', pointers: 1, direction: Hammer.DIRECTION_HORIZONTAL, threshold: 10 }\r\n this._hammer.add(new Hammer.Pan());\r\n this._hammer.add(new Hammer.Pinch());\r\n\r\n // Let the pan be detected with two fingers.\r\n // 2 => pan, 1 -> rotate\r\n this._hammer.get('pan').set({\r\n threshold: 0,\r\n pointers: 0\r\n });\r\n\r\n var pinch = this._hammer.get('pinch');\r\n // Set a minimal threshold on pinch event, to be detected after pan\r\n // pinch disable as default\r\n pinch.set({\r\n threshold: 0.1,\r\n enable: false\r\n });\r\n pinch.recognizeWith(this._hammer.get('pan'));\r\n\r\n this._hammer.add(\r\n new Hammer.Tap({\r\n event: 'doubletap',\r\n pointers: 1,\r\n taps: 2,\r\n time: 250, // def : 250. Maximum press time in ms.\r\n interval: 450, // def : 300. Maximum time in ms between multiple taps.\r\n threshold: 5, // def : 2. While doing a tap some small movement is allowed.\r\n posThreshold: 50 // def : 30. The maximum position difference between multiple taps.\r\n })\r\n );\r\n\r\n this._hammer.add(\r\n new Hammer.Tap({\r\n event: 'doubletap2fingers',\r\n pointers: 2,\r\n taps: 2,\r\n time: 250,\r\n interval: 450,\r\n threshold: 5,\r\n posThreshold: 50\r\n })\r\n );\r\n\r\n this._hammer.add(\r\n new Hammer.Tap({\r\n event: 'singletap',\r\n pointers: 1,\r\n taps: 1,\r\n time: 250,\r\n interval: 450,\r\n threshold: 5,\r\n posThreshold: 20\r\n })\r\n );\r\n};\r\n\r\nutils.createPrototypeObject(\r\n InputSourceTouchScreen,\r\n utils.objectInherit(InputSource.prototype, {\r\n getName: function() {\r\n return 'TouchScreen';\r\n },\r\n\r\n setEnable: function(name, callback, enable) {\r\n if (this._isNativeEvent(name)) {\r\n if (enable) {\r\n this._target.addEventListener(name, callback);\r\n } else {\r\n this._target.removeEventListener(name, callback);\r\n }\r\n } else {\r\n if (name.indexOf('pinch') >= 0 && enable) {\r\n this._hammer.get('pinch').set({ enable: true });\r\n }\r\n if (enable) {\r\n this._hammer.on(name, callback);\r\n } else {\r\n this._hammer.off(name, callback);\r\n }\r\n }\r\n },\r\n\r\n populateEvent: function(ev, customEvent) {\r\n if (this._isNativeEvent(ev.type)) {\r\n //native event\r\n customEvent.canvasX = customEvent.canvasY = 0;\r\n var touches = ev.touches.length ? ev.touches : ev.changedTouches;\r\n var nbTouches = touches.length;\r\n for (var i = 0; i < nbTouches; ++i) {\r\n customEvent.canvasX += touches[i].clientX / nbTouches;\r\n customEvent.canvasY += touches[i].clientY / nbTouches;\r\n }\r\n // modifiers\r\n customEvent.ctrlKey = ev.ctrlKey;\r\n customEvent.shiftKey = ev.shiftKey;\r\n customEvent.altKey = ev.altKey;\r\n customEvent.metaKey = ev.metaKey;\r\n customEvent.pointers = ev.touches;\r\n } else {\r\n //hammer event\r\n customEvent.canvasX = ev.center.x;\r\n customEvent.canvasY = ev.center.y;\r\n customEvent.scale = ev.scale;\r\n customEvent.rotation = ev.rotation;\r\n customEvent.deltaX = ev.deltaX;\r\n customEvent.deltaY = ev.deltaY;\r\n customEvent.deltaTime = ev.deltaTime;\r\n customEvent.direction = ev.direction;\r\n customEvent.offsetDirection = ev.offsetDirection;\r\n customEvent.pointers = ev.pointers;\r\n customEvent.velocity = ev.velocity;\r\n }\r\n\r\n var offset = this._target.getBoundingClientRect();\r\n customEvent.canvasX += -offset.left;\r\n customEvent.canvasY += -offset.top;\r\n\r\n // x, y coordinates in the gl viewport\r\n var ratio = this._inputManager.getParam('pixelRatio');\r\n if (!ratio) ratio = this._defaultRatio;\r\n customEvent.glX = customEvent.canvasX * ratio[0];\r\n customEvent.glY = (this._target.clientHeight - customEvent.canvasY) * ratio[1];\r\n },\r\n\r\n _isNativeEvent: function(evt) {\r\n return this._supportedEvents.indexOf(evt) >= 0;\r\n },\r\n\r\n isEventRegistered: function(nativeEvent, parsedEvent) {\r\n nativeEvent.preventDefault();\r\n if (nativeEvent.pointerType && nativeEvent.pointerType !== 'touch') {\r\n return false;\r\n }\r\n\r\n if (!parsedEvent.action) {\r\n return true;\r\n }\r\n\r\n if (isNaN(parsedEvent.action)) {\r\n throw 'touch action should be a number representing the number of touches';\r\n }\r\n\r\n var touches = nativeEvent.pointers;\r\n if (!touches) {\r\n touches = nativeEvent.touches;\r\n }\r\n\r\n var nbTouches = parseInt(parsedEvent.action);\r\n\r\n if (nativeEvent.type === 'touchend' || nativeEvent.type === 'touchcancel') {\r\n //on touch end the number of touches will always be below the requested number of touches\r\n if (touches.length >= nbTouches) {\r\n return false;\r\n }\r\n } else {\r\n if (touches.length !== nbTouches) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n },\r\n\r\n supportsEvent: function(eventName) {\r\n var result = InputSource.prototype.supportsEvent.call(this, eventName);\r\n if (result) {\r\n return result;\r\n }\r\n for (var i = 0; i < this._hammerEvents.length; i++) {\r\n var event = this._hammerEvents[i];\r\n if (eventName.indexOf(event) === 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n\r\n getHammer: function() {\r\n return this._hammer;\r\n }\r\n }),\r\n 'osgViewer',\r\n 'InputSourceTouchScreen'\r\n);\r\n\r\nexport default InputSourceTouchScreen;","import notify from '../osg/notify';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Options from '../osg/Options';\r\nimport P from 'bluebird';\r\nimport Timer from '../osg/Timer';\r\nimport TimerGPU from '../osg/TimerGPU';\r\nimport UpdateVisitor from '../osg/UpdateVisitor';\r\nimport utils from '../osg/utils';\r\nimport GLObject from '../osg/GLObject';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport VertexArrayObject from '../osg/VertexArrayObject';\r\nimport Shader from '../osg/Shader';\r\nimport Program from '../osg/Program';\r\nimport Texture from '../osg/Texture';\r\nimport OrbitManipulator from '../osgGA/OrbitManipulator';\r\nimport View from '../osgViewer/View';\r\nimport WebGLUtils from '../osgViewer/webgl-utils';\r\nimport WebGLDebugUtils from '../osgViewer/webgl-debug';\r\nimport Stats from '../osgStats/Stats';\r\nimport defaultStats from '../osgStats/defaultStats';\r\nimport glStats from '../osgStats/glStats';\r\nimport browserStats from '../osgStats/browserStats';\r\nimport InputManager from '../osgViewer/input/InputManager';\r\nimport InputSourceMouse from '../osgViewer/input/source/InputSourceMouse';\r\nimport InputSourceKeyboard from '../osgViewer/input/source/InputSourceKeyboard';\r\nimport InputSourceWebVR from '../osgViewer/input/source/InputSourceWebVR';\r\nimport InputSourceGamePad from '../osgViewer/input/source/InputSourceGamePad';\r\nimport InputSourceDeviceOrientation from '../osgViewer/input/source/InputSourceDeviceOrientation';\r\nimport InputSourceTouchScreen from '../osgViewer/input/source/InputSourceTouchScreen';\r\nimport RenderBin from '../osg/RenderBin';\r\nimport RenderStage from '../osg/RenderStage';\r\nimport StateGraph from '../osg/StateGraph';\r\n\r\nvar Viewer = function(canvas, userOptions, error) {\r\n View.call(this);\r\n\r\n this._startTick = Timer.instance().tick();\r\n this._stats = undefined;\r\n this._done = false;\r\n\r\n // keep reference so that you still have it\r\n // when gl context is lost\r\n this._canvas = canvas;\r\n\r\n var options = this.initOptions(userOptions);\r\n var gl = this.initWebGLContext(canvas, options, error);\r\n\r\n if (!gl) throw 'No WebGL implementation found';\r\n\r\n this._updateVisitor = new UpdateVisitor();\r\n\r\n this.setUpView(gl.canvas, options);\r\n this.initInputManager(options, canvas);\r\n this.initStats(options, canvas);\r\n\r\n this._hmd = null;\r\n this._requestAnimationFrame = window.requestAnimationFrame.bind(window);\r\n this._options = options;\r\n this._contextLost = false;\r\n this._forceRestoreContext = true;\r\n this.renderBinded = this.render.bind(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Viewer,\r\n utils.objectInherit(View.prototype, {\r\n initInputManager: function(options, canvas) {\r\n var inputManager = new InputManager();\r\n this._inputManager = inputManager;\r\n\r\n //Default mouse and keyboard\r\n this._initInputSource(InputSourceMouse, 'Mouse', canvas, options);\r\n this._initInputSource(InputSourceKeyboard, 'Keyboard', document, options);\r\n\r\n // touch inputs, Only activate them if we have a touch device in order to fix problems with IE11\r\n if ('ontouchstart' in window || true) {\r\n this._initInputSource(InputSourceTouchScreen, 'TouchScreen', canvas, options);\r\n }\r\n\r\n this._initInputSource(InputSourceWebVR, 'WebVR', undefined, options);\r\n this._initInputSource(\r\n InputSourceDeviceOrientation,\r\n 'DeviceOrientation',\r\n undefined,\r\n options\r\n );\r\n\r\n if (navigator.getGamepads) {\r\n this._initInputSource(InputSourceGamePad, 'GamePad', undefined, options);\r\n }\r\n\r\n inputManager.addMappings(\r\n { 'viewer.internals:hmdConnect': 'vrdisplayconnected' },\r\n function(ev) {\r\n this.setVRDisplay(ev.vrDisplay);\r\n }.bind(this)\r\n );\r\n\r\n inputManager.setParam('pixelRatio', [this._devicePixelRatio, this._devicePixelRatio]);\r\n },\r\n\r\n _initInputSource: function(sourceClass, optionName, defaultSrcElem, options) {\r\n var opt = options.InputSources ? options.InputSources[optionName] : undefined;\r\n if (opt) {\r\n if (opt.enable !== false) {\r\n var elem = opt.sourceElement || defaultSrcElem;\r\n this._inputManager.registerInputSource(new sourceClass(elem, opt));\r\n }\r\n } else {\r\n this._inputManager.registerInputSource(new sourceClass(defaultSrcElem));\r\n }\r\n },\r\n\r\n getInputManager: function() {\r\n return this._inputManager;\r\n },\r\n\r\n initOptions: function(userOptions) {\r\n // use default options\r\n var options = new Options();\r\n\r\n if (userOptions) {\r\n // user options override by user options\r\n options.extend(userOptions);\r\n }\r\n\r\n // if url options override url options\r\n options.extendWithOptionsURL();\r\n\r\n // Activate global trace on log call\r\n if (options.getBoolean('traceLogCall') === true) notify.traceLogCall = true;\r\n\r\n // Check if Frustum culling is enabled to calculate the clip planes\r\n if (options.getBoolean('enableFrustumCulling') === true)\r\n this.getCamera()\r\n .getRenderer()\r\n .getCullVisitor()\r\n .setEnableFrustumCulling(true);\r\n\r\n return options;\r\n },\r\n\r\n initWebGLContext: function(canvas, options, error) {\r\n // #FIXME see tojiro's blog for webgl lost context stuffs\r\n if (options.get('SimulateWebGLLostContext')) {\r\n canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);\r\n canvas.loseContextInNCalls(options.get('SimulateWebGLLostContext'));\r\n this._canvas = canvas;\r\n }\r\n\r\n var gl = WebGLUtils.setupWebGL(canvas, options, error);\r\n\r\n //www.khronos.org/registry/webgl/specs/latest/1.0/#WEBGLCONTEXTEVENT\r\n canvas.addEventListener(\r\n 'webglcontextlost',\r\n function(event) {\r\n this.contextLost();\r\n if (this._forceRestoreContext !== false) {\r\n event.preventDefault();\r\n }\r\n }.bind(this),\r\n false\r\n );\r\n\r\n canvas.addEventListener(\r\n 'webglcontextrestored',\r\n function() {\r\n this.contextRestored();\r\n }.bind(this),\r\n false\r\n );\r\n\r\n if (notify.reportWebGLError || options.get('reportWebGLError')) {\r\n gl = WebGLDebugUtils.makeDebugContext(gl);\r\n }\r\n\r\n this.initWebGLCaps(gl);\r\n this.setGraphicContext(gl);\r\n\r\n return gl;\r\n },\r\n\r\n // allow user to acknowledge the context lost\r\n // (display a message, etc.)\r\n // - callback return false: no attempt to restore\r\n setContextLostCallback: function(callback) {\r\n this._contextLostCallback = callback;\r\n // just in case callback registration\r\n // happens after the context lost\r\n if (this._contextLost) {\r\n this._forceRestoreContext = callback();\r\n }\r\n },\r\n\r\n setContextRestoreCallback: function(callback) {\r\n this._contextRestoreCallback = callback;\r\n },\r\n\r\n contextLost: function() {\r\n notify.log('webgl context lost');\r\n if (this._contextLostCallback) {\r\n this._forceRestoreContext = this._contextLostCallback();\r\n }\r\n this._contextLost = true;\r\n window.cancelAnimationFrame(this._requestID);\r\n },\r\n\r\n contextRestored: function() {\r\n if (this._forceRestoreContext === false) {\r\n notify.log('webgl context restore not supported - please reload the page - ');\r\n return;\r\n }\r\n // restore is already async\r\n // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2\r\n this.restoreContext();\r\n notify.log('webgl context restored');\r\n },\r\n\r\n restoreContext: function() {\r\n var gl = this.getGraphicContext();\r\n\r\n Shader.onLostContext(gl);\r\n Program.onLostContext(gl);\r\n BufferArray.onLostContext(gl);\r\n VertexArrayObject.onLostContext(gl);\r\n FrameBufferObject.onLostContext(gl);\r\n Texture.getTextureManager(gl).onLostContext(gl);\r\n\r\n GLObject.onLostContext(gl);\r\n\r\n this.getCamera()\r\n .getRenderer()\r\n .getState()\r\n .resetCaches();\r\n\r\n // if it's a different GPU, different webglcaps\r\n this.initWebGLCaps(gl, true);\r\n this.setGraphicContext(gl);\r\n\r\n // different GPU caps means different timer caps\r\n TimerGPU.instance(this.getGraphicContext(), true);\r\n if (this._stats) {\r\n // stats geometries needs special care\r\n this._stats.reset();\r\n }\r\n\r\n // ready to draw again\r\n this._contextLost = false;\r\n this._requestRedraw = true;\r\n\r\n // Warn users context has been restored\r\n if (this._contextRestoreCallback) {\r\n this._contextRestoreCallback(gl);\r\n }\r\n this._runImplementation();\r\n },\r\n\r\n init: function() {\r\n //this._done = false;\r\n },\r\n\r\n getUpdateVisitor: function() {\r\n return this._updateVisitor;\r\n },\r\n\r\n getState: function() {\r\n return this.getCamera()\r\n .getRenderer()\r\n .getState();\r\n },\r\n\r\n initStats: function(options) {\r\n var timerGPU = TimerGPU.instance(this.getGraphicContext());\r\n\r\n if (!options.getBoolean('stats')) {\r\n timerGPU.disable();\r\n return;\r\n }\r\n\r\n this._stats = new Stats(this, options);\r\n this._stats.addConfig(defaultStats);\r\n this._stats.addConfig(glStats);\r\n this._stats.addConfig(browserStats);\r\n\r\n this.getCamera().addChild(this._stats.getNode());\r\n\r\n timerGPU.setCallback(this.callbackTimerGPU.bind(this));\r\n },\r\n\r\n callbackTimerGPU: function(average, queryID) {\r\n if (this._stats) this._stats.getCounter(queryID).set(average / 1e6);\r\n },\r\n\r\n getViewerStats: function() {\r\n return this._stats;\r\n },\r\n\r\n renderingTraversal: function() {\r\n this.getState()._frameStamp = this._frameStamp;\r\n\r\n if (this.getScene().getSceneData())\r\n this.getScene()\r\n .getSceneData()\r\n .getBound();\r\n\r\n if (this.getCamera()) {\r\n var stats = this._stats;\r\n var timerGPU = TimerGPU.instance(this.getGraphicContext());\r\n\r\n var renderer = this.getCamera().getRenderer();\r\n\r\n if (stats) stats.getCounter('cull').start();\r\n\r\n renderer.cull();\r\n\r\n if (stats) stats.getCounter('cull').end();\r\n\r\n timerGPU.pollQueries();\r\n timerGPU.start('glframe');\r\n\r\n if (stats) {\r\n stats.getCounter('render').start();\r\n }\r\n\r\n renderer.draw();\r\n\r\n if (stats) {\r\n stats.getCounter('render').end();\r\n }\r\n\r\n timerGPU.end('glframe');\r\n\r\n if (stats) {\r\n var cullVisitor = renderer.getCullVisitor();\r\n stats.getCounter('cullcamera').set(cullVisitor._numCamera);\r\n stats.getCounter('cullmatrixtransform').set(cullVisitor._numMatrixTransform);\r\n stats.getCounter('cullprojection').set(cullVisitor._numProjection);\r\n stats.getCounter('cullnode').set(cullVisitor._numNode);\r\n stats.getCounter('culllightsource').set(cullVisitor._numLightSource);\r\n stats.getCounter('cullgeometry').set(cullVisitor._numGeometry);\r\n\r\n stats.getCounter('pushstateset').set(renderer.getState()._numPushStateSet);\r\n\r\n stats.getCounter('applyStateSet').set(renderer.getState()._numApply);\r\n }\r\n }\r\n },\r\n\r\n updateTraversal: function() {\r\n var stats = this._stats;\r\n\r\n if (stats) stats.getCounter('update').start();\r\n\r\n // update the scene\r\n this._updateVisitor.resetStats();\r\n this.getScene().updateSceneGraph(this._updateVisitor);\r\n\r\n if (stats)\r\n stats.getCounter('updatecallback').set(this._updateVisitor._numUpdateCallback);\r\n\r\n // Remove ExpiredSubgraphs from DatabasePager\r\n this.getDatabasePager().releaseGLExpiredSubgraphs(0.005);\r\n // In OSG this.is deferred until the draw traversal, to handle multiple contexts\r\n this.flushDeletedGLObjects(0.005);\r\n\r\n if (stats) stats.getCounter('update').end();\r\n },\r\n\r\n advance: function(simulationTime) {\r\n var sTime = simulationTime;\r\n\r\n if (sTime === undefined) sTime = Number.MAX_VALUE;\r\n\r\n var frameStamp = this._frameStamp;\r\n var previousFrameNumber = frameStamp.getFrameNumber();\r\n\r\n frameStamp.setFrameNumber(previousFrameNumber + 1);\r\n\r\n var deltaS = Timer.instance().deltaS(this._startTick, Timer.instance().tick());\r\n frameStamp.setReferenceTime(deltaS);\r\n var lastSimulationTime = frameStamp.getSimulationTime();\r\n frameStamp.setSimulationTime(sTime === Number.MAX_VALUE ? deltaS : sTime); // set simul time\r\n frameStamp.setDeltaTime(frameStamp.getSimulationTime() - lastSimulationTime); // compute delta since last tick\r\n //console.log(frameStamp.getSimulationTime() - lastSimulationTime)\r\n \r\n },\r\n\r\n beginFrame: function() {\r\n var stats = this._stats;\r\n\r\n if (stats) {\r\n stats.getCounter('frame').start();\r\n\r\n stats.getCounter('raf').tick();\r\n stats.getCounter('fps').frame();\r\n }\r\n },\r\n\r\n endFrame: function() {\r\n var frameNumber = this.getFrameStamp().getFrameNumber();\r\n\r\n // update texture stats\r\n if (this._stats) {\r\n Texture.getTextureManager(this.getGraphicContext()).updateStats(\r\n frameNumber,\r\n this._stats\r\n );\r\n\r\n this._stats.getCounter('stats').start();\r\n this._stats.update();\r\n this._stats.getCounter('stats').end();\r\n\r\n this._stats.getCounter('frame').end();\r\n }\r\n },\r\n\r\n checkNeedToDoFrame: function() {\r\n return this._requestContinousUpdate || this._requestRedraw;\r\n },\r\n\r\n frame: function() {\r\n // _contextLost check for code calling viewer::frame directly\r\n // (likely force preload gl resource or direct render control )\r\n if (this._contextLost) return;\r\n\r\n this.beginFrame();\r\n\r\n this.advance();\r\n\r\n // update viewport if a resize occured\r\n var canvasSizeChanged = this.updateViewport();\r\n\r\n // update inputs\r\n this._inputManager.update();\r\n\r\n // setup framestamp\r\n this._updateVisitor.setFrameStamp(this.getFrameStamp());\r\n // Update Manipulator/Event\r\n if (this.getManipulator()) {\r\n this.getManipulator().update(this._updateVisitor);\r\n mat4.copy(\r\n this.getCamera().getViewMatrix(),\r\n this.getManipulator().getInverseMatrix()\r\n );\r\n }\r\n\r\n if (this.checkNeedToDoFrame() || canvasSizeChanged) {\r\n this._requestRedraw = false;\r\n this.updateTraversal();\r\n this.renderingTraversal();\r\n }\r\n\r\n this.endFrame();\r\n\r\n // submit frame to vr headset\r\n if (this._hmd && this._hmd.isPresenting) this._hmd.submitFrame();\r\n },\r\n\r\n setDone: function(bool) {\r\n this._done = bool;\r\n },\r\n\r\n done: function() {\r\n return this._done;\r\n },\r\n\r\n render: function() {\r\n if (!this.done()) {\r\n this._requestID = this._requestAnimationFrame(this.renderBinded, this._canvas);\r\n this.frame();\r\n }\r\n },\r\n\r\n _runImplementation: function() {\r\n this.render();\r\n },\r\n\r\n run: function() {\r\n this._runImplementation();\r\n },\r\n\r\n setVRDisplay: function(hmd) {\r\n this._hmd = hmd;\r\n },\r\n\r\n getVRDisplay: function() {\r\n return this._hmd;\r\n },\r\n\r\n setPresentVR: function(doPresentVR) {\r\n if (!this._hmd) {\r\n notify.warn('no hmd device provided to the viewer!');\r\n return P.reject();\r\n }\r\n\r\n if (!this._hmd.capabilities.canPresent) return P.reject();\r\n\r\n if (doPresentVR) {\r\n // spec is not clear if it should be done after the requestPresent promise or before\r\n this._requestAnimationFrame = this._hmd.requestAnimationFrame.bind(this._hmd);\r\n\r\n var layers = [\r\n {\r\n source: this.getGraphicContext().canvas\r\n }\r\n ];\r\n return this._hmd.requestPresent(layers);\r\n } else {\r\n this._requestAnimationFrame = window.requestAnimationFrame.bind(window);\r\n return this._hmd.exitPresent();\r\n }\r\n },\r\n\r\n setupManipulator: function(manipulator /*, dontBindDefaultEvent */) {\r\n if (manipulator === undefined) {\r\n manipulator = new OrbitManipulator({ inputManager: this._inputManager });\r\n }\r\n\r\n if (manipulator.setNode !== undefined) {\r\n manipulator.setNode(this.getSceneData());\r\n } else {\r\n // for backward compatibility\r\n manipulator.view = this;\r\n }\r\n\r\n manipulator.setCamera(this.getCamera());\r\n this.setManipulator(manipulator);\r\n },\r\n\r\n // updateViewport\r\n updateViewport: function() {\r\n var gl = this.getGraphicContext();\r\n var canvas = gl.canvas;\r\n\r\n var hasChanged = this.computeCanvasSize(canvas);\r\n if (!hasChanged) return false;\r\n\r\n var camera = this.getCamera();\r\n var vp = camera.getViewport();\r\n\r\n var prevWidth = vp.width();\r\n var prevHeight = vp.height();\r\n\r\n var widthChangeRatio = canvas.width / prevWidth;\r\n var heightChangeRatio = canvas.height / prevHeight;\r\n var aspectRatioChange = widthChangeRatio / heightChangeRatio;\r\n vp.setViewport(\r\n Math.round(vp.x() * widthChangeRatio),\r\n Math.round(vp.y() * heightChangeRatio),\r\n Math.round(vp.width() * widthChangeRatio),\r\n Math.round(vp.height() * heightChangeRatio)\r\n );\r\n\r\n if (aspectRatioChange !== 1.0) {\r\n mat4.mul(\r\n camera.getProjectionMatrix(),\r\n camera.getProjectionMatrix(),\r\n mat4.fromScaling(mat4.create(), [1.0 / aspectRatioChange, 1.0, 1.0])\r\n );\r\n }\r\n\r\n return true;\r\n },\r\n\r\n setManipulator: function(manipulator) {\r\n this.setEnableManipulator(false);\r\n\r\n if (!manipulator.getCamera()) manipulator.setCamera(this.getCamera());\r\n\r\n manipulator.setEnable(true);\r\n View.prototype.setManipulator.call(this, manipulator);\r\n },\r\n\r\n setEnableManipulator: function(bool) {\r\n if (!this._manipulator) return;\r\n this._manipulator.setEnable(bool);\r\n },\r\n\r\n dispose: function() {\r\n RenderBin.clean();\r\n RenderStage.clean();\r\n StateGraph.pooledStateGraph.clean();\r\n }\r\n }),\r\n 'osgViewer',\r\n 'Viewer'\r\n);\r\n\r\nexport default Viewer;\r\n","import Renderer from './Renderer';\r\nimport View from './View';\r\nimport Viewer from './Viewer';\r\nimport Scene from './Scene';\r\nimport InputGroups from './input/InputConstants';\r\n\r\nvar osgViewer = {};\r\n\r\nosgViewer.Renderer = Renderer;\r\nosgViewer.View = View;\r\nosgViewer.Viewer = Viewer;\r\nosgViewer.Scene = Scene;\r\nosgViewer.InputGroups = InputGroups;\r\n\r\nexport default osgViewer;\r\n","import osgViewer from '../osgViewer/osgViewer';\r\n\r\nconst InputGroups = osgViewer.InputGroups;\r\n\r\nInputGroups.GLOBAL_ACTIONS = InputGroups.SCENE + '.globalactions'\r\nInputGroups.GLOBAL_FOCUS = 'focuscanvas'\r\nInputGroups.SCENE_VIEWERAPI = InputGroups.SCENE + '.viewerapi'\r\nInputGroups.SCENE_VIEWERAPI_1_4 = InputGroups.SCENE + '.viewerapi_1_4'\r\nInputGroups.FOCUS_INSPECTOR = 'focus.inspector'\r\nInputGroups.SCENE_INSPECTOR = InputGroups.SCENE + '.inspector'\r\nInputGroups.UI_INSPECTOR = InputGroups.UI + '.inspector'\r\nInputGroups.SCENE_INSPECTOR_ZOOM = InputGroups.SCENE_INSPECTOR + '.zoom'\r\nInputGroups.UI_INSPECTOR_ZOOM = InputGroups.UI_INSPECTOR + '.zoom'\r\nInputGroups.ENVIRONMENT = InputGroups.SCENE + '.environment'\r\nInputGroups.DEBUG = 'debug'\r\nInputGroups.DEBUG_TRIPICK = 'debug.tripick'\r\nInputGroups.DEBUG_GEOMPICK = 'debug.geompick'\r\nInputGroups.AUTOSPIN = InputGroups.SCENE + '.autospin'\r\nInputGroups.HOTSPOT = InputGroups.SCENE + '.hotspot'\r\nInputGroups.HOTSPOT_VIEWER = InputGroups.HOTSPOT + '.viewer'\r\nInputGroups.HOTSPOT_EDITOR = InputGroups.HOTSPOT + '.editor'\r\nInputGroups.CAMERA = InputGroups.SCENE + '.camera'\r\nInputGroups.CAMERA_GIZMO = InputGroups.CAMERA + '.gizmo'\r\nInputGroups.SOUND = InputGroups.SCENE + '.sound'\r\nInputGroups.SOUND_GIZMO = InputGroups.SOUND + '.gizmo'\r\nInputGroups.WEBVR = InputGroups.SCENE + '.webvr'\r\nInputGroups.WEBVREDITOR = InputGroups.SCENE + 'webvreditor'\r\nInputGroups.WEBVR_NAVIGATION = InputGroups.WEBVR + '.navigation'\r\nInputGroups.WEBVR_DISPLAY = InputGroups.WEBVR + '.display'\r\nInputGroups.AR = 'ar'\r\nInputGroups.AR_DEBUG = InputGroups.AR + '.debug'\r\nInputGroups.STICKER = 'sticker'\r\nexport default class FeatureEventManager {\r\n constructor(){\r\n this._manager = null\r\n }\r\n init (inputManager) {\r\n this._manager = inputManager;\r\n }\r\n initGlobalClickEvents (featureManager, canvas) {\r\n let xpos = 0,\r\n ypos = 0,\r\n translation = 0;\r\n this._manager.group(InputGroups.GLOBAL_ACTIONS).addMappings(\r\n {\r\n onDoubleClick: ['doubletap', 'doubletap2fingers', 'dblclick'],\r\n onSingleClick: 'singletap',\r\n },\r\n featureManager,\r\n );\r\n\r\n this._manager.group(InputGroups.GLOBAL_ACTIONS).addMappings(\r\n {\r\n preventclick: 'mousedown',\r\n },\r\n function (event) {\r\n (translation = 0), (xpos = event.clientX), (ypos = event.clientY);\r\n },\r\n );\r\n\r\n this._manager.group(InputGroups.GLOBAL_ACTIONS).addMappings(\r\n {\r\n preventmousemove: 'mousemove',\r\n },\r\n function (event) {\r\n translation = Math.max(\r\n translation,\r\n Math.abs(xpos - event.clientX) + Math.abs(ypos - event.clientY),\r\n );\r\n },\r\n );\r\n\r\n this._manager.group(InputGroups.GLOBAL_ACTIONS).addMappings(\r\n {\r\n fallbacksingleclick: 'mouseup',\r\n },\r\n function (t) {\r\n translation < 2 && featureManager.onSingleClick(t);\r\n },\r\n );\r\n\r\n this._manager.group('focuscanvas').addMappings(\r\n {\r\n focus: 'mousedown',\r\n },\r\n function () {\r\n canvas.focus({\r\n preventScroll: true,\r\n });\r\n },\r\n );\r\n\r\n this._manager.setPriority('focuscanvas', 0);\r\n }\r\n\r\n initEnvironment (envFeature) {\r\n this._manager.group(InputGroups.ENVIRONMENT).addMappings(\r\n {\r\n startRotate: ['mousedown alt', 'touchstart 3'],\r\n // rotateLight: ['mousemove alt ctrl !shift'],\r\n // rotateEnv: ['mousemove alt shift !ctrl'],\r\n // rotateEnvAndLight: ['mousemove alt !shift !ctrl', 'panmove 3'],\r\n endRotate: ['mouseup', 'mouseout', 'touchend', 'touchcancel'],\r\n },\r\n envFeature,\r\n ),\r\n this._manager.setPriority(\r\n InputGroups.ENVIRONMENT,\r\n this._manager.getHigherPriority(InputGroups.MANIPULATORS),\r\n );\r\n }\r\n\r\n initSticker(stickerFeature){ \r\n var currentX = 0, currentY = 0, translation = 0\r\n this._manager.group(InputGroups.STICKER).addMappings({\r\n 'mousedown': 'mousedown',\r\n 'mousemove': 'mousemove',\r\n 'mouseup': ['mouseup', 'mouseout'],\r\n 'doubleclick': [ 'dblclick', 'doubletap'],\r\n 'singleclick': ['singletap']\r\n }, stickerFeature)\r\n \r\n this._manager.group(InputGroups.STICKER).addMappings(\r\n {onPreventMouseMove: 'mousemove'}\r\n , evt => {\r\n var tempTranslation = Math.abs(currentX - evt.clientX) + Math.abs(currentY - evt.clientY)\r\n translation = Math.max(translation, tempTranslation)\r\n })\r\n\r\n this._manager.group(InputGroups.STICKER).addMappings(\r\n {onFallbackSingleClick: 'mouseup'}\r\n , evt => {\r\n if (translation < 2) {\r\n stickerFeature.singleclick(evt)\r\n }})\r\n \r\n this._manager.group(InputGroups.STICKER).addMappings(\r\n {onPreventClick: 'mousedown'}, evt => {\r\n translation = 0\r\n currentX = evt.clientX\r\n currentY = evt.clientY\r\n })\r\n this._manager.setPriority(\r\n InputGroups.STICKER,\r\n this._manager.getHigherPriority(InputGroups.STICKER),\r\n );\r\n\r\n\r\n }\r\n initHotspot (hotspotFeature) { }\r\n initCamera (cameraFeature) {\r\n this._manager.group(InputGroups.CAMERA_GIZMO).addMappings(\r\n {\r\n motion: 'mousemove',\r\n startDrag: 'mousedown',\r\n endDrag: ['mouseleave', 'mouseup'],\r\n },\r\n cameraFeature,\r\n ),\r\n this._manager.setPriority(\r\n InputGroups.CAMERA_GIZMO,\r\n this._manager.getHigherPriority(InputGroups.MANIPULATORS),\r\n );\r\n }\r\n\r\n};\r\n","export default {\r\n OPAQUE: 0,\r\n OPAQUE_NO_EARLYZ: 1,\r\n BACKGROUND: 1,\r\n REFRACTION: 2,\r\n TRANSPARENT_CUSTOM_EARLYZ: 8,\r\n TRANSPARENT_NO_EARLYZ_PRE: 9,\r\n TRANSPARENT: 10,\r\n TRANSPARENT_NO_EARLYZ_POST: 11,\r\n EXTRA: 19,\r\n EDITOR_GIZMO: 20,\r\n HOTSPOT: 20,\r\n GRID: 21,\r\n TOOLTIP: 21,\r\n VR_MENU: 21,\r\n WIREFRAME: 22,\r\n VR_CURSOR: 22,\r\n OUTLINE: 23,\r\n DEBUG: 24,\r\n DEBUG_2: 25\r\n};\r\n\r\n","import osg from '../osg/osg';\r\n\r\nexport default {\r\n DEPTH_LESS_WRITE: new osg.Depth(osg.Depth.LESS, 0, 1, true),\r\n DEPTH_LESS_NO_WRITE: new osg.Depth(osg.Depth.LESS, 0, 1, false),\r\n DEPTH_DISABLE: new osg.Depth(osg.Depth.DISABLE, 0, 1, true),\r\n DEPTH_ALWAYS: new osg.Depth(osg.Depth.ALWAYS, 0, 1, true),\r\n DEPTH_NEVER: new osg.Depth(osg.Depth.NEVER, 0, 1, false),\r\n DEPTH_LEQUAL_BACKGROUND_NO_WRITE: new osg.Depth(osg.Depth.LEQUAL, 1, 1, false),\r\n DEPTH_LEQUAL_WRITE: new osg.Depth(osg.Depth.LEQUAL, 0, 1, true),\r\n DEPTH_LEQUAL_NO_WRITE: new osg.Depth(osg.Depth.LEQUAL, 0, 1, false),\r\n DEPTH_EQUAL_NO_WRITE: new osg.Depth(osg.Depth.EQUAL, 0, 1, false),\r\n COLOR_MASK_NONE: new osg.ColorMask(false, false, false, false),\r\n COLOR_MASK_ALPHA: new osg.ColorMask(false, false, false, true),\r\n COLOR_MASK_RGBA: new osg.ColorMask(true, true, true, true),\r\n BLEND_DISABLE: new osg.BlendFunc(),\r\n BLEND_SUBSTRACTIVE: new osg.BlendFunc(osg.BlendFunc.ONE, osg.BlendFunc.ONE_MINUS_SRC_ALPHA),\r\n BLEND_ADDITIVE: new osg.BlendFunc(osg.BlendFunc.ONE, osg.BlendFunc.ONE),\r\n CULL_BACK: new osg.CullFace(osg.CullFace.BACK),\r\n CULL_FRONT: new osg.CullFace(osg.CullFace.FRONT),\r\n CULL_DISABLE: new osg.CullFace(osg.CullFace.DISABLE),\r\n};\r\n","var PickMask = {\r\n PICK_GEOMETRY_FIXED: 1,\r\n PICK_GEOMETRY_ANIMATED: 2,\r\n PICK_GEOMETRY_RIG_BOX: 4,\r\n PICK_GIZMO_LIGHT: 8,\r\n SHADOW_CAST: 16,\r\n SHADOW_BOUNDS: 32,\r\n};\r\nPickMask.PICK_GEOMETRY_SLOW = PickMask.PICK_GEOMETRY_FIXED | PickMask.PICK_GEOMETRY_ANIMATED\r\nPickMask.PICK_GEOMETRY_FAST = PickMask.PICK_GEOMETRY_FIXED | PickMask.PICK_GEOMETRY_RIG_BOX\r\nPickMask.PICK_GEOMETRY = PickMask.PICK_GEOMETRY_FIXED | PickMask.PICK_GEOMETRY_ANIMATED | PickMask.PICK_GEOMETRY_RIG_BOX\r\nPickMask.PICK = PickMask.PICK_GEOMETRY | PickMask.PICK_GIZMO_LIGHT\r\nPickMask.SHADOW = PickMask.SHADOW_BOUNDS | PickMask.SHADOW_CAST\r\nPickMask.PICK_GEOMETRY_SHADOW = PickMask.PICK_GEOMETRY | PickMask.SHADOW\r\nPickMask.NO_SHADOW = ~PickMask.SHADOW\r\nPickMask.NO_PICK = ~PickMask.PICK\r\nPickMask.NO_PICK_NO_SHADOW_CAST = ~(PickMask.PICK | PickMask.SHADOW_CAST)\r\nPickMask.NO_PICK_NO_SHADOW_BOUNDS = ~(PickMask.PICK | PickMask.SHADOW_BOUNDS)\r\nPickMask.NO_PICK_NO_SHADOW = ~(PickMask.PICK | PickMask.SHADOW)\r\n\r\nexport default PickMask;\r\n","import utils from '../osg/utils';\r\nimport Node from '../osg/Node';\r\nimport CullFace from '../osg/CullFace';\r\nimport Depth from '../osg/Depth';\r\nimport Texture from '../osg/Texture';\r\nimport Uniform from '../osg/Uniform';\r\nimport StateSet from '../osg/StateSet';\r\nimport Camera from '../osg/Camera';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport Viewport from '../osg/Viewport';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Shape from '../osg/shape';\r\nimport TransformEnums from '../osg/transformEnums';\r\nimport NextShaderProcessor from '../osgShader/NextShaderProcessor';\r\n\r\n/*\r\nThis class creates a post-processing pipeline based on an user-defined list of passes and .glsl files.\r\nThe user can thus easily change the order or the passes without having to do the usual stuff: creating cameras, stateSets, bind textures, etc.\r\n\r\n======================\r\n=== simple example ===\r\n======================\r\n\r\nvar composer = new ComposerPostProcess();\r\ncomposer.setScreenSize( width, height );\r\n\r\ncomposer.addInternalTexture({\r\n name: 'color',\r\n immuable: true // the texture object won't change and can be safely used with getInternalTexture\r\n});\r\n\r\n// the first %last will be an alias to this texture\r\ncomposer.setInputTexture( 'color' );\r\n\r\nvar passes = [];\r\npasses.push({\r\n func: { name: 'func', file: 'file.glsl' },\r\n\r\n // %last and %next can be seen as stack operators, each %next pushes a texture on the stack while %last takes the top of the stack\r\n // it allows more flexibility when the user want to change the order of the passes withoug having to change the inputs/outputs/filtering/colorspaces of the other passes\r\n // it is also better for performances in some cases because it allows the composer to collapse passes in one pass\r\n textures: [ '%last' ],\r\n uniforms: [ Uniform.createFloat( 3.8, 'factor' ) ],\r\n out: { name: '%next' }\r\n});\r\n\r\ncomposer.build( passes );\r\n\r\nvar color = composer.getInternalTexture( 'color' );\r\n\r\n========================\r\n=== advanced example ===\r\n========================\r\n\r\nvar composer = new ComposerPostProcess();\r\ncomposer.setScreenSize( width, height );\r\n\r\ncomposer.addInternalTexture({\r\n name: 'color',\r\n immuable: true // immuable is used\r\n});\r\n\r\ncomposer.addInternalTexture({\r\n name: 'depth',\r\n reusable: false // besides beeing immuable, the texture won't be reused by other passes, can be useful when the texture is needed after post-processing\r\n});\r\n\r\npasses.push({\r\n func: 'func', // will deduce the file func.glsl'\r\n textures: [ { name: '%last', filter: 'linear' }, 'color' ], // for some reasons, we want to sample that texture in linear\r\n out: { name: 'pass1', divisor: 2.0 } // we want to render this pass into an half-res texture\r\n collapsible: false // we don't want this pass to be collapsed into the last pass\r\n});\r\n\r\npasses.push({\r\n func: 'func2',\r\n header: [ '#define NUM_SAMPLES 10', '#extension GL_EXTENSION_NAME : require' ],\r\n\r\n // %previous is a special predefined value, it will transform the pass into a feedback loop, all is needed now is to swap the textures every frames using:\r\n // composer.swapFeedbackLoopTextures( boolean )\r\n texture: [ 'color', '%previous' ],\r\n out: { name: '%next' }\r\n})\r\n\r\npasses.push({\r\n func: 'func3',\r\n texture: [ 'pass1', '%last', { name: 'pass2', uniformName: '', srgb: true, rgbm: false } ], // force srgb and rgbm, composer won't override this\r\n out: { name: %next', filter: 'linear' } // force the linear filter, composer won't override this\r\n // this pass should be collapsed into the last one, collapsible defaults to false\r\n collapsible: true\r\n})\r\n\r\n// these uniforms will be passed to every shaders created by the composer\r\ncomposer.setGlobalUniforms( [ uniformTime ] );\r\n\r\nvar color = composer.getInternalTexture( 'color' );\r\nvar depth = composer.getInternalTexture( 'depth' );\r\n\r\n*/\r\n\r\nvar ComposerPostProcess = function(functionsFile) {\r\n Node.call(this);\r\n\r\n this._functionsFile = functionsFile || \"functions.glsl\"\r\n\r\n // stuffs for syncing feedback texture uniforms\r\n this._feedbackSwapped = false; // called on feedack swap\r\n this._syncFeedbackUniforms = false; // called on resize\r\n this._syncOnNextFrame = false;\r\n this._lastXratio = 1;\r\n this._lastYratio = 1;\r\n\r\n // partial viewport and drs (dynamic resolution scaling)\r\n this._xViewportRatio = 1.0;\r\n this._yViewportRatio = 1.0;\r\n this._xTextureRatio = 1.0;\r\n this._yTextureRatio = 1.0;\r\n // in case of dynamic resolution scaling : true will do a final upsampling\r\n // to full viewport size\r\n this._finalPassUpScaleToScreen = true;\r\n // wrap uv stuffs\r\n this._methodWrapUV = 0;\r\n this._thresholdWrapUV = 1.0;\r\n this._texInfos = undefined;\r\n\r\n this._screenWidth = this._screenHeight = 0;\r\n\r\n // this._shaderProcessor = ShaderProcessor();\r\n this._shaderProcessor = NextShaderProcessor;\r\n\r\n this._feedbackData = {};\r\n\r\n this._cameras = [];\r\n this._stateSets = [];\r\n this._textureUniforms = [];\r\n\r\n this._programs = {};\r\n\r\n this._externalTextures = {};\r\n this._internalPasses = [];\r\n this._textures = {};\r\n\r\n this._userTextures = {};\r\n\r\n this._currentPoolIndex = 0;\r\n this._texturePool = {};\r\n\r\n this._firstTexture = '';\r\n\r\n var stateSet = this.getOrCreateStateSet();\r\n stateSet.setAttributeAndModes(new Depth(Depth.DISABLE));\r\n stateSet.setAttributeAndModes(new CullFace(CullFace.BACK));\r\n\r\n this.setCullCallback(this);\r\n};\r\n\r\nComposerPostProcess.VertexShader = [\r\n 'attribute vec3 Vertex;',\r\n 'void main(void) {',\r\n ' gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);',\r\n '}',\r\n '',\r\n '#define SHADER_NAME %name%',\r\n ''\r\n].join('\\n');\r\n\r\nComposerPostProcess.FragmentShader = [\r\n '#ifdef GL_FRAGMENT_PRECISION_HIGH\\n precision highp float;\\n#else\\n precision mediump float;\\n#endif',\r\n 'uniform float uRGBMRange;',\r\n 'vec2 gTexCoord;',\r\n '%uniforms%',\r\n '',\r\n '#pragma include \"$FUNCTION_FILE$\"',\r\n '',\r\n '%header%',\r\n '',\r\n '%texturesColorSpace%',\r\n '',\r\n '%functionBodies%',\r\n '',\r\n 'void main() {',\r\n '\\tgTexCoord = gl_FragCoord.xy / uTextureOutputSize.xy;',\r\n '\\tvec4 color = %firstFunc%(%firstArg%);',\r\n '%optionalFuncs%',\r\n '%colorSpaces%',\r\n '\\tgl_FragColor = color;',\r\n '}',\r\n '',\r\n '#define SHADER_NAME %name%',\r\n ''\r\n].join('\\n');\r\n\r\nutils.createPrototypeObject(\r\n ComposerPostProcess,\r\n utils.objectInherit(Node.prototype, {\r\n clear: function() {\r\n this._textures = {};\r\n this._internalPasses.length = 0;\r\n\r\n this._firstTexture = '';\r\n\r\n for (var tex in this._texturePool) {\r\n this._texturePool[tex].usage = -1;\r\n }\r\n\r\n this._feedbackData = {};\r\n\r\n this._cameras.length = 0;\r\n this._stateSets.length = 0;\r\n this._textureUniforms.length = 0;\r\n\r\n this.removeChildren();\r\n },\r\n\r\n clearShaderCache: function() {\r\n this._programs = {};\r\n },\r\n\r\n getGlobalXRatio: function() {\r\n return this._xViewportRatio * this._xTextureRatio;\r\n },\r\n\r\n getGlobalYRatio: function() {\r\n return this._yViewportRatio * this._yTextureRatio;\r\n },\r\n\r\n setFinalPassUpScaleToScreen: function(bool) {\r\n this._finalPassUpScaleToScreen = bool;\r\n },\r\n\r\n _enforceFromInputParameter: function(paramName, inputTexture) {\r\n var texName = inputTexture.name;\r\n var prevTexture = this._textures[texName];\r\n var prevFeedbackTexture = this._textures[texName + 'FeedbackTexture'];\r\n\r\n var newParam = inputTexture[paramName];\r\n if (newParam === undefined) {\r\n return;\r\n }\r\n\r\n // check possible mismatch\r\n if (prevTexture[paramName] !== undefined) {\r\n if (prevTexture[paramName] !== newParam) {\r\n console.error('Mismatch on parameter ' + paramName + ' : ' + texName);\r\n }\r\n }\r\n\r\n prevTexture[paramName] = newParam;\r\n if (prevFeedbackTexture) {\r\n prevFeedbackTexture[paramName] = newParam;\r\n }\r\n },\r\n\r\n _updatePassInfoFromInputs: function(pass, passName, lastPassInfo) {\r\n var outTexture = this._textures[passName];\r\n\r\n var lastPassSrgb = lastPassInfo.srgb;\r\n\r\n // reset\r\n lastPassInfo.srgb = undefined;\r\n\r\n for (var i = 0; i < pass.textures.length; i++) {\r\n var inputTexture = pass.textures[i];\r\n this._renameTextureAlias(inputTexture, passName, lastPassInfo.name);\r\n\r\n var texInfoName = inputTexture.name;\r\n if (this._externalTextures[texInfoName]) {\r\n continue;\r\n }\r\n\r\n this._usages[texInfoName] = (this._usages[texInfoName] || 0) + 1;\r\n\r\n var requestSrgb = inputTexture.srgb;\r\n\r\n // copy user inputs\r\n this._enforceFromInputParameter('filter', inputTexture);\r\n this._enforceFromInputParameter('rgbm', inputTexture);\r\n this._enforceFromInputParameter('srgb', inputTexture);\r\n\r\n // notify a texture to be encoded in srgb if previous pass was in linear\r\n var texture = this._textures[texInfoName];\r\n if (!texture) {\r\n var orig = texInfoName.substring(0, texInfoName.indexOf('FeedbackTexture'));\r\n texture = this._textures[orig];\r\n }\r\n\r\n if (lastPassSrgb !== undefined && requestSrgb !== undefined) {\r\n if (lastPassSrgb !== requestSrgb) {\r\n texture.encodeSRGB = true;\r\n }\r\n }\r\n\r\n this._setInferredParameter('rgbmInferred', 'rgbm', outTexture, texture);\r\n this._setInferredParameter('srgbInferred', 'srgb', outTexture, texture);\r\n }\r\n\r\n if (lastPassInfo.srgb === undefined) {\r\n lastPassInfo.srgb =\r\n outTexture.srgb === undefined ? outTexture.srgbInferred : outTexture.srgb;\r\n }\r\n },\r\n\r\n _setInferredParameter: function(paramInfer, param, dest, src) {\r\n if (dest[paramInfer] === undefined) {\r\n dest[paramInfer] = src[param] === undefined ? src[paramInfer] : src[param];\r\n }\r\n },\r\n\r\n _createTextureOut: function(pass, passName, isLastPass) {\r\n var outTexture = {\r\n srgb: pass.out.srgb,\r\n rgbm: pass.out.rgbm,\r\n filter: pass.out.filter,\r\n type: pass.out.type\r\n };\r\n\r\n // enforce : not rgbm if we are in float\r\n var isFloat = pass.out.type !== Texture.UNSIGNED_BYTE;\r\n if (outTexture.rgbm === undefined && (isLastPass || isFloat)) {\r\n outTexture.rgbm = false;\r\n }\r\n\r\n // enforce : linear space if we have rgbm or float texture\r\n if (outTexture.srgb === undefined) {\r\n if (isLastPass) outTexture.srgb = true;\r\n else if (outTexture.rgbm || isFloat) outTexture.srgb = false;\r\n }\r\n\r\n return outTexture;\r\n },\r\n\r\n _processUserPasses: function(userPasses) {\r\n userPasses = this._internalPasses.concat(userPasses);\r\n var passes = this._preprocessUserPasses(userPasses);\r\n\r\n var numPasses = passes.length;\r\n\r\n var outPasses = [];\r\n\r\n var lastPassInfo = {\r\n name: this._firstTexture,\r\n srgb: undefined\r\n };\r\n\r\n var duplicateNames = {};\r\n\r\n for (var i = 0; i < numPasses; i++) {\r\n var pass = passes[i];\r\n\r\n var isLastPass = i === numPasses - 1;\r\n if (!isLastPass && this._collapsePasses(pass, passes[i + 1])) {\r\n passes.splice(i + 1, 1);\r\n numPasses--;\r\n i--;\r\n\r\n continue;\r\n }\r\n\r\n var passName = pass.out.name;\r\n var isNext = passName === '%next';\r\n\r\n if (isNext) {\r\n passName = pass.funcs.join('_');\r\n\r\n if (duplicateNames[passName]) {\r\n passName += duplicateNames[passName]++;\r\n } else {\r\n duplicateNames[passName] = 1;\r\n }\r\n }\r\n\r\n // create textures\r\n var outTexture = this._createTextureOut(pass, passName, isLastPass);\r\n this._textures[passName] = outTexture;\r\n\r\n this._updatePassInfoFromInputs(pass, passName, lastPassInfo);\r\n\r\n // feedback texture share same parameters\r\n if (pass.feedbackLoop) {\r\n this._textures[passName + 'FeedbackTexture'] = {\r\n srgb: outTexture.srgb,\r\n rgbm: outTexture.rgbm,\r\n srgbInferred: outTexture.srgbInferred,\r\n rgbmInferred: outTexture.rgbmInferred,\r\n filter: outTexture.filter\r\n };\r\n }\r\n\r\n if (isNext) {\r\n lastPassInfo.name = passName;\r\n pass.out.name = passName;\r\n }\r\n\r\n outPasses.push(pass);\r\n }\r\n\r\n return outPasses;\r\n },\r\n\r\n // the number of textures needed by the post-processing stack can be deduced using the user data\r\n // each texture has an unique name from which an usage number is computed\r\n // each time a texture is sampled, the usage is decremented\r\n // when is reaches 0 it means that the texture won't be used anymore so it can be reused\r\n // besides the usage number, the divisor, internal type and the filtering of the texture are used to make sure it can safely be reused\r\n _hasFreeTexture: function(passName, filter, out) {\r\n // passName that directly matches a texture name\r\n if (passName === out.name && this._texturePool[passName]) {\r\n return passName;\r\n }\r\n\r\n if (out.immuable) {\r\n return;\r\n }\r\n\r\n for (var key in this._texturePool) {\r\n var poolTexture = this._texturePool[key];\r\n\r\n // not reusable (could be used after postprocess)\r\n if (!poolTexture.reusable) continue;\r\n\r\n // still required for a future postprocess pass\r\n if (poolTexture.usage > 0) continue;\r\n\r\n // different resolution\r\n if (poolTexture.texture.divisor !== out.divisor) continue;\r\n\r\n // different type (/!\\ important, we could change type runtime, that way we cause lot of memory)\r\n if (poolTexture.texture.getInternalFormatType() !== out.type) continue;\r\n\r\n // first usage\r\n if (poolTexture.usage === -1) {\r\n if (poolTexture.texture.getMinFilter() !== filter) {\r\n poolTexture.texture.setMinFilter(filter);\r\n poolTexture.texture.setMagFilter(filter);\r\n }\r\n\r\n return key;\r\n }\r\n\r\n // reuse\r\n if (poolTexture.texture.getMinFilter() === filter) {\r\n return key;\r\n }\r\n }\r\n\r\n return;\r\n },\r\n\r\n _setOrCreateTextureKey: function(usage, passName, out) {\r\n var isLinear = this._textures[passName].filter === 'linear';\r\n var filterEnum = isLinear ? Texture.LINEAR : Texture.NEAREST;\r\n\r\n var poolKey = this._hasFreeTexture(passName, filterEnum, out);\r\n if (poolKey) {\r\n this._texturePool[poolKey].usage = usage;\r\n this._textures[passName].key = poolKey;\r\n return;\r\n }\r\n\r\n if (out.immuable) {\r\n poolKey = passName;\r\n } else {\r\n poolKey = 'key' + this._currentPoolIndex++;\r\n }\r\n\r\n this._texturePool[poolKey] = {\r\n usage: usage,\r\n texture: this._createTexture(passName, out.divisor, out.type, filterEnum),\r\n immuable: out.immuable,\r\n reusable: out.reusable\r\n };\r\n\r\n if (out.divisor === -1) {\r\n this._texturePool[poolKey].width = out.width;\r\n this._texturePool[poolKey].height = out.height;\r\n }\r\n\r\n this._textures[passName].key = poolKey;\r\n },\r\n\r\n _addStateSet: function(pass, stateSet) {\r\n for (var i = 0; i < pass.funcs.length; i++) {\r\n var passName = pass.funcs[i].name;\r\n\r\n this._stateSets[passName] = stateSet;\r\n }\r\n },\r\n\r\n _addTextureToStateSet: function(textureInfo, stateSet, unit, uniforms, isFeedback) {\r\n stateSet.addUniform(Uniform.createInt1(unit, textureInfo.uniformName));\r\n\r\n var name = textureInfo.name;\r\n var texture;\r\n\r\n if (this._textures[name] !== undefined) {\r\n var key = this._textures[name].key;\r\n texture = this._texturePool[key].texture;\r\n } else {\r\n texture = this._externalTextures[name];\r\n }\r\n\r\n this._addTextureUniforms(\r\n textureInfo.uniformName,\r\n texture,\r\n stateSet,\r\n uniforms,\r\n isFeedback\r\n );\r\n\r\n if (textureInfo.uniformName === 'TexturePrevious') {\r\n return unit;\r\n }\r\n\r\n stateSet.setTextureAttributeAndModes(unit, texture);\r\n\r\n return undefined;\r\n },\r\n\r\n _getUniformName: function(uniformName) {\r\n return 'u' + uniformName[0].toUpperCase() + uniformName.slice(1);\r\n },\r\n\r\n _addTextureUniforms: function(uniformName, texture, stateSet, uniforms, isFeedback) {\r\n var uName = this._getUniformName(uniformName);\r\n\r\n var uSize = Uniform.createFloat2(uName + 'Size');\r\n var uRatio = Uniform.createFloat2(uName + 'Ratio');\r\n\r\n stateSet.addUniform(uSize);\r\n stateSet.addUniform(uRatio);\r\n\r\n uniforms.push(uSize);\r\n uniforms.push(uRatio);\r\n\r\n this._textureUniforms.push({\r\n size: uSize,\r\n ratio: uRatio,\r\n texture: texture,\r\n isFeedback: !!isFeedback\r\n });\r\n },\r\n\r\n _checkInferredParameters: function() {\r\n for (var key in this._textures) {\r\n var tex = this._textures[key];\r\n if (tex.srgb === undefined) tex.srgb = tex.srgbInferred;\r\n if (tex.rgbm === undefined) tex.rgbm = tex.rgbmInferred;\r\n }\r\n },\r\n\r\n _buildPass: function(index, passes) {\r\n var pass = passes[index];\r\n var passName = pass.out.name;\r\n\r\n this._setOrCreateTextureKey(this._usages[passName], passName, pass.out);\r\n\r\n var feedbackName = pass.out.name + 'FeedbackTexture';\r\n\r\n if (pass.feedbackLoop) {\r\n this._setOrCreateTextureKey(this._usages[feedbackName], feedbackName, pass.out);\r\n }\r\n\r\n // internal pass (user texture)\r\n if (!pass.funcs.length) {\r\n var key = this._textures[passName].key;\r\n this._userTextures[passName] = this._texturePool[key].texture;\r\n return;\r\n }\r\n\r\n var stateSet = new StateSet();\r\n this._addStateSet(pass, stateSet);\r\n\r\n var i;\r\n for (i = 0; i < pass.uniforms.length; i++) {\r\n stateSet.addUniform(pass.uniforms[i]);\r\n }\r\n\r\n var uniforms = [];\r\n\r\n var previousTextureUnit = undefined;\r\n\r\n for (i = 0; i < pass.textures.length; i++) {\r\n var texInfo = pass.textures[i];\r\n\r\n var isFeedback = texInfo.name === feedbackName;\r\n if (!isFeedback && !this._externalTextures[texInfo.name]) {\r\n var poolKey = this._textures[texInfo.name].key;\r\n this._texturePool[poolKey].usage--;\r\n }\r\n\r\n var unit = this._addTextureToStateSet(texInfo, stateSet, i, uniforms, isFeedback);\r\n if (unit !== undefined) {\r\n previousTextureUnit = unit;\r\n }\r\n\r\n if (this._feedbackData[texInfo.name] === undefined) {\r\n continue;\r\n }\r\n\r\n var nextPass = {\r\n stateSet: stateSet,\r\n textureUnit: i\r\n };\r\n\r\n this._feedbackData[texInfo.name].nextPasses.push(nextPass);\r\n }\r\n\r\n var outputTexture = undefined;\r\n if (index !== passes.length - 1) {\r\n var outputKey = this._textures[passName].key;\r\n outputTexture = this._texturePool[outputKey].texture;\r\n }\r\n\r\n this._addTextureUniforms('TextureOutput', outputTexture, stateSet, uniforms);\r\n\r\n stateSet.setAttributeAndModes(this._createProgram(pass, uniforms));\r\n\r\n if (pass.feedbackLoop) {\r\n this._feedbackData[passName] = this._createFeedbackLoopCameras(\r\n passName,\r\n stateSet,\r\n outputTexture,\r\n previousTextureUnit\r\n );\r\n } else {\r\n this.addChild(this._createCamera(passName, stateSet, outputTexture));\r\n }\r\n },\r\n\r\n _buildGraphFromPasses: function(passes) {\r\n for (var i = 0; i < passes.length; i++) {\r\n this._buildPass(i, passes);\r\n }\r\n },\r\n\r\n build: function(userPasses) {\r\n this._usages = {};\r\n\r\n // process array of passes\r\n var passes = this._processUserPasses(userPasses);\r\n\r\n // fallback on inferred information for srgb/rgbm/filter\r\n this._checkInferredParameters(passes);\r\n\r\n // create textures, cameras and shader\r\n this._buildGraphFromPasses(passes);\r\n\r\n this.resize(this._screenWidth, this._screenHeight);\r\n },\r\n\r\n _createFeedbackLoopCameras: function(name, stateSet, outputTexture, previousTextureUnit) {\r\n var previousKey = this._textures[name + 'FeedbackTexture'].key;\r\n var previousTexture = this._texturePool[previousKey].texture;\r\n\r\n var common = new Node();\r\n common.setStateSet(stateSet);\r\n\r\n var camera1 = this._createFeedbackLoopCamera(\r\n name,\r\n outputTexture,\r\n previousTexture,\r\n previousTextureUnit\r\n );\r\n var camera2 = this._createFeedbackLoopCamera(\r\n name + 'FeedbackTexture',\r\n previousTexture,\r\n outputTexture,\r\n previousTextureUnit\r\n );\r\n\r\n camera2.setNodeMask(0x0);\r\n\r\n common.addChild(camera1);\r\n common.addChild(camera2);\r\n\r\n this.addChild(common);\r\n\r\n var feedbackLoopData = {};\r\n feedbackLoopData.camera1 = camera1;\r\n feedbackLoopData.camera2 = camera2;\r\n feedbackLoopData.texture1 = outputTexture;\r\n feedbackLoopData.texture2 = previousTexture;\r\n feedbackLoopData.nextPasses = [];\r\n\r\n return feedbackLoopData;\r\n },\r\n\r\n _createFeedbackLoopCamera: function(cameraName, dstTexture, srcTexture, srcUnit) {\r\n var stateSet = new StateSet();\r\n stateSet.setTextureAttributeAndModes(srcUnit, srcTexture);\r\n\r\n var camera = this._createCamera(cameraName, stateSet, dstTexture);\r\n camera.setStateSet(stateSet);\r\n\r\n return camera;\r\n },\r\n\r\n _createCamera: function(name, stateSet, outputTexture) {\r\n var camera = new Camera();\r\n camera.setName(name);\r\n camera.setStateSet(stateSet);\r\n camera.setClearMask(0x0);\r\n camera.setReferenceFrame(TransformEnums.ABSOLUTE_RF);\r\n\r\n if (outputTexture) {\r\n camera.setRenderOrder(Camera.PRE_RENDER, 0);\r\n camera.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, outputTexture);\r\n }\r\n\r\n camera.setViewport(new Viewport());\r\n\r\n var quad = Shape.createTexturedFullScreenFakeQuadGeometry(this.getInstanceID());\r\n quad.setName('composer layer');\r\n camera.addChild(quad);\r\n\r\n this._cameras.push(camera);\r\n return camera;\r\n },\r\n\r\n swapFeedbackLoopTextures: function(frame0) {\r\n for (var key in this._feedbackData) {\r\n var data = this._feedbackData[key];\r\n\r\n data.camera1.setNodeMask(frame0 ? ~0x0 : 0x0);\r\n data.camera2.setNodeMask(frame0 ? 0x0 : ~0x0);\r\n\r\n var texture = frame0 ? data.texture1 : data.texture2;\r\n\r\n for (var j = 0; j < data.nextPasses.length; j++) {\r\n var nextPass = data.nextPasses[j];\r\n nextPass.stateSet.setTextureAttributeAndModes(nextPass.textureUnit, texture);\r\n }\r\n }\r\n\r\n this._feedbackSwapped = true;\r\n },\r\n\r\n _createFuncFromUserData: function(userFunc) {\r\n var func =\r\n typeof userFunc === 'string'\r\n ? { name: userFunc, file: userFunc + '.glsl' }\r\n : userFunc;\r\n\r\n // now funcs.join( '_' ) only join the name of the functions instead of every members of the object\r\n func.toString = function() {\r\n return this.name;\r\n };\r\n\r\n return func;\r\n },\r\n\r\n _createTextureInfoFromUserData: function(userData) {\r\n var texInfo = {\r\n name: '',\r\n uniformName: '',\r\n rgbm: undefined,\r\n srgb: undefined,\r\n filter: undefined\r\n };\r\n\r\n if (typeof userData === 'string') {\r\n texInfo.name = userData;\r\n } else {\r\n texInfo.name = userData.name;\r\n\r\n if (userData.uniformName) texInfo.uniformName = userData.uniformName;\r\n if (userData.rgbm !== undefined) texInfo.rgbm = userData.rgbm;\r\n if (userData.srgb !== undefined) texInfo.srgb = userData.srgb;\r\n if (userData.filter !== undefined) texInfo.filter = userData.filter;\r\n }\r\n\r\n return texInfo;\r\n },\r\n\r\n _preprocessUserPasses: function(userPasses) {\r\n var passes = [];\r\n\r\n for (var i = 0; i < userPasses.length; i++) {\r\n var userPass = userPasses[i];\r\n\r\n var pass = {};\r\n pass.funcs = [];\r\n\r\n if (userPass.func) {\r\n pass.funcs.push(this._createFuncFromUserData(userPass.func));\r\n }\r\n\r\n pass.textures = [];\r\n\r\n pass.feedbackLoop = false;\r\n\r\n if (userPass.textures !== undefined) {\r\n if (!Array.isArray(userPass.textures)) {\r\n userPass.textures = [userPass.textures];\r\n }\r\n\r\n for (var j = 0; j < userPass.textures.length; j++) {\r\n var tex = this._createTextureInfoFromUserData(userPass.textures[j]);\r\n\r\n if (tex.name === '%previous') {\r\n pass.feedbackLoop = true;\r\n }\r\n\r\n pass.textures.push(tex);\r\n }\r\n }\r\n\r\n if (typeof userPass.header === 'string') {\r\n pass.header = [userPass.header];\r\n } else {\r\n pass.header = userPass.header || [];\r\n }\r\n\r\n if (userPass.uniforms !== undefined) {\r\n if (Array.isArray(userPass.uniforms)) {\r\n pass.uniforms = userPass.uniforms;\r\n } else {\r\n pass.uniforms = [userPass.uniforms];\r\n }\r\n } else {\r\n pass.uniforms = [];\r\n }\r\n\r\n pass.out = userPass.out;\r\n // filter/rgbm/srgb are undefined by default\r\n pass.out.divisor = pass.out.divisor || 1.0;\r\n\r\n pass.out.type = pass.out.type || Texture.UNSIGNED_BYTE;\r\n if (pass.out.immuable === undefined) pass.out.immuable = false;\r\n if (pass.out.reusable === undefined) pass.out.reusable = true;\r\n\r\n if (pass.feedbackLoop || pass.out.divisor === -1) {\r\n pass.out.immuable = true;\r\n pass.out.reusable = false;\r\n }\r\n\r\n pass.collapsible = userPass.collapsible || false;\r\n passes.push(pass);\r\n }\r\n\r\n return passes;\r\n },\r\n\r\n _canBeCollapsed: function(currentPass, nextPass) {\r\n // this won't merge passes with named textures even if they are collapsible\r\n // is this what we want?\r\n return (\r\n currentPass.funcs.length &&\r\n nextPass.collapsible &&\r\n currentPass.out.name === '%next' &&\r\n currentPass.out.divisor === nextPass.out.divisor &&\r\n // we dont want to merge fixed size texture if the same isn't equal\r\n currentPass.out.width === currentPass.out.width &&\r\n currentPass.out.height === currentPass.out.height\r\n );\r\n },\r\n\r\n _collapsePasses: function(currentPass, nextPass) {\r\n if (!this._canBeCollapsed(currentPass, nextPass)) {\r\n return false;\r\n }\r\n\r\n currentPass.funcs = currentPass.funcs.concat(nextPass.funcs);\r\n currentPass.header = currentPass.header.concat(nextPass.header);\r\n\r\n currentPass.textures = this._mergeWithoutDuplicates(\r\n currentPass.textures,\r\n nextPass.textures,\r\n function(a, b) {\r\n return a.name === b.name;\r\n }\r\n );\r\n\r\n currentPass.uniforms = this._mergeWithoutDuplicates(\r\n currentPass.uniforms,\r\n nextPass.uniforms,\r\n function(a, b) {\r\n return a.getName() === b.getName();\r\n }\r\n );\r\n\r\n // not sure if we should collapse feedbackLoop into lastpass?\r\n return true;\r\n },\r\n\r\n _renameTextureAlias: function(texture, passName, lastPassName) {\r\n if (texture.name === '%last') {\r\n texture.name = lastPassName;\r\n texture.uniformName = texture.uniformName || 'TextureInput';\r\n } else if (texture.name === '%previous') {\r\n texture.name = passName + 'FeedbackTexture';\r\n texture.uniformName = texture.uniformName || 'TexturePrevious';\r\n } else if (!texture.uniformName) {\r\n texture.uniformName = texture.name;\r\n }\r\n },\r\n\r\n _createTexture: function(name, divisor, type, filter) {\r\n var texture = new Texture();\r\n texture.setTextureSize(1, 1);\r\n texture.setInternalFormatType(type);\r\n\r\n // not always necessary to have 4 channels, might be interesting to set it in pass\r\n texture.setInternalFormat(Texture.RGBA);\r\n\r\n texture.setMinFilter(filter);\r\n texture.setMagFilter(filter);\r\n\r\n texture.divisor = divisor;\r\n texture.setName(name);\r\n\r\n return texture;\r\n },\r\n\r\n _computeHashFromPass: function(pass) {\r\n var hash = '';\r\n\r\n for (var i = 0; i < pass.funcs.length; i++) {\r\n hash += pass.funcs[i].name + '_' + pass.funcs[i].file + '_';\r\n }\r\n\r\n if (pass.header) {\r\n hash += pass.header.join('_');\r\n }\r\n\r\n for (i = 0; i < pass.textures.length; i++) {\r\n hash += !!pass.textures[i].rgbm + '_' + !!pass.textures[i].srgb + '_';\r\n }\r\n\r\n hash += !!pass.out.encodeSRGB + '_';\r\n hash += !!this._textures[pass.out.name].rgbm + '_';\r\n\r\n return hash;\r\n },\r\n\r\n _writeDeclarations: function(source, uniforms, textures, header) {\r\n var str = 'uniform sampler2D TextureInput;\\n';\r\n\r\n var i;\r\n for (i = 0; i < textures.length; i++) {\r\n var tname = textures[i].uniformName || textures[i].name;\r\n str += 'uniform sampler2D ' + tname + ';\\n';\r\n }\r\n for (i = 0; i < uniforms.length; i++) {\r\n var uniform = uniforms[i];\r\n str += 'uniform ' + uniform.getType() + ' ' + uniform.getName() + ';\\n';\r\n }\r\n\r\n source = source.replace('%uniforms%', str);\r\n\r\n if (header) {\r\n source = source.replace('%header%', header.join('\\n'));\r\n }\r\n\r\n return source;\r\n },\r\n\r\n setMethodWrapUV: function(method, threshold) {\r\n // hook every texture call to handle viewport/texture ratio\r\n // when reading out of texture assigned zone\r\n\r\n // 0 - do nothing\r\n // 1 - clamp uv\r\n // 2 - black color\r\n if (method !== undefined) this._methodWrapUV = method;\r\n if (threshold !== undefined) this._thresholdWrapUV = threshold;\r\n this._texInfos = undefined;\r\n },\r\n\r\n _getInfos: function() {\r\n if (this._texInfos) return this._texInfos;\r\n\r\n var bodySimple = 'texture2D(%tex, (uv) * %ratio)';\r\n var bodyNearest =\r\n 'texture2D(%tex, (floor((uv) * %size) + 0.5) * %ratio / %size, -99999.0)';\r\n var bodyBias = 'texture2D(%tex, (uv) * %ratio)';\r\n\r\n // see setMethodWrapUV\r\n var val = this._thresholdWrapUV.toExponential();\r\n if (this._methodWrapUV === 1) {\r\n var replaceValue = 'min(uv, 1.0 - ' + val + ' / %size.xy)';\r\n bodySimple = bodySimple.replace(/(uv)/g, replaceValue);\r\n bodyNearest = bodyNearest.replace(/(uv)/g, replaceValue);\r\n bodyBias = bodyBias.replace(/(uv)/g, replaceValue);\r\n } else if (this._methodWrapUV === 2) {\r\n var prefix = 'step((uv).x, 1.0 - ' + val + ' / %size.x) *';\r\n prefix += 'step((uv).y, 1.0 - ' + val + ' / %size.y) * ';\r\n bodySimple = prefix + bodySimple;\r\n bodyNearest = prefix + bodyNearest;\r\n bodyBias = prefix + bodyBias;\r\n }\r\n\r\n this._texInfos = {\r\n TEXTURE_2D: {\r\n signature: 'TEXTURE_2D_%tex(uv)',\r\n body: bodySimple\r\n },\r\n TEXTURE_2D_NEAREST: {\r\n signature: 'TEXTURE_2D_NEAREST_%tex(uv)',\r\n body: bodyNearest\r\n },\r\n TEXTURE_2D_BIAS: {\r\n signature: 'TEXTURE_2D_BIAS_%tex(uv, bias)',\r\n body: bodyBias\r\n }\r\n };\r\n\r\n return this._texInfos;\r\n },\r\n\r\n _extractTextures: function(file) {\r\n var infos = this._getInfos();\r\n\r\n var lines = file.match(/TEXTURE_2D(?:_BIAS|_NEAREST)?_\\w+\\(/g);\r\n if (!lines) return {};\r\n\r\n var textures = {};\r\n\r\n for (var j = 0; j < lines.length; j++) {\r\n var str = lines[j].match(/((TEXTURE_2D(?:_BIAS|_NEAREST)?)_(\\w+))\\(/);\r\n var info = infos[str[2]];\r\n\r\n textures[str[1]] = {\r\n name: str[3],\r\n signature: info.signature,\r\n body: info.body\r\n };\r\n }\r\n\r\n return textures;\r\n },\r\n\r\n _writeFunctionBodies: function(source, funcs, textures, collapsible) {\r\n var colorSpacesDefines = [];\r\n var functionBodies = '';\r\n var defineKeys = {};\r\n\r\n for (var i = 0; i < funcs.length; i++) {\r\n var file = this._shaderProcessor.getShaderTextPure(funcs[i].file);\r\n functionBodies += file + '\\n';\r\n }\r\n\r\n // resolve pragma include\r\n // var includeList = [ 'functions.glsl']; // included in composer main shader\r\n var includeList = [ this._functionsFile ]; // included in composer main shader\r\n functionBodies = this._shaderProcessor.processIncludes(functionBodies, includeList);\r\n\r\n var textureDefines = this._extractTextures(functionBodies);\r\n if (collapsible) {\r\n var tex2dInfo = this._getInfos().TEXTURE_2D;\r\n textureDefines.TEXTURE_2D_TextureInput = {\r\n name: 'TextureInput',\r\n signature: tex2dInfo.signature,\r\n body: tex2dInfo.body\r\n };\r\n }\r\n\r\n for (var key in textureDefines) {\r\n if (defineKeys[key]) {\r\n continue;\r\n }\r\n\r\n defineKeys[key] = true;\r\n\r\n var defineInfo = textureDefines[key];\r\n var texName = defineInfo.name;\r\n\r\n var rgbm = false;\r\n // check if the textures is rgbm\r\n for (var j = 0; j < textures.length; j++) {\r\n var inTex = textures[j];\r\n if (inTex.uniformName !== texName) {\r\n continue;\r\n }\r\n\r\n var tex = this._textures[inTex.name];\r\n if (tex && tex.rgbm) {\r\n rgbm = tex.rgbm;\r\n break;\r\n }\r\n }\r\n\r\n var code = defineInfo.body;\r\n if (rgbm) code = 'vec4(decodeRGBM(' + code + ', uRGBMRange), 1.0)';\r\n code = '#define ' + defineInfo.signature + ' (' + code + ')';\r\n\r\n // replace %stuff by uniform names\r\n var uName = this._getUniformName(texName);\r\n code = code.replace(/%size/g, uName + 'Size');\r\n code = code.replace(/%ratio/g, uName + 'Ratio');\r\n code = code.replace(/%tex/g, texName);\r\n\r\n colorSpacesDefines.push(code);\r\n }\r\n\r\n source = source.replace('%texturesColorSpace%', colorSpacesDefines.join('\\n'));\r\n\r\n // allows multi-line defines in sub-shaders\r\n return source.replace('%functionBodies%', functionBodies.replace(/\\\\\\n/g, ''));\r\n },\r\n\r\n _writeMainFunction: function(source, funcs, collapsible, textureName) {\r\n source = source.replace('%firstFunc%', funcs[0].name);\r\n\r\n var arg = collapsible ? 'TEXTURE_2D_TextureInput(gTexCoord)' : '';\r\n source = source.replace('%firstArg%', arg);\r\n\r\n var str = '';\r\n\r\n for (var i = 1; i < funcs.length; i++) {\r\n str += '\\tcolor = ' + funcs[i].name + '(color);\\n';\r\n }\r\n\r\n source = source.replace('%optionalFuncs%', str);\r\n\r\n if (this._textures[textureName].encodeSRGB === true) {\r\n var func = this._textures[textureName].srgb ? 'linearTosRGB' : 'sRGBToLinear';\r\n str = '\\tcolor.rgb = ' + func + '(color.rgb);\\n';\r\n } else {\r\n str = '';\r\n }\r\n\r\n if (this._textures[textureName].rgbm) {\r\n str += '\\tcolor = encodeRGBM(color.rgb, uRGBMRange);';\r\n } else {\r\n str += '';\r\n }\r\n\r\n return source.replace('%colorSpaces%', str);\r\n },\r\n\r\n // an hash string is created using the user pass data before creating a program\r\n // shaders are stored inside a map using this string, so the composer knows there is no need to rebuild it if it already exists\r\n\r\n _removeDuplicatedUniforms: function(source) {\r\n var lines = source.split('\\n');\r\n\r\n var uniforms = {};\r\n\r\n var numLines = lines.length;\r\n\r\n for (var i = 0; i < numLines; i++) {\r\n var match = lines[i].match(/uniform(?:\\s+){1,}\\w+(?:\\s+){1,}(\\w+)/);\r\n if (match === null) {\r\n continue;\r\n }\r\n\r\n var name = match[1];\r\n\r\n if (uniforms[name] !== undefined) {\r\n lines.splice(i, 1);\r\n numLines--;\r\n i--;\r\n } else {\r\n uniforms[name] = true;\r\n }\r\n }\r\n\r\n return lines.join('\\n');\r\n },\r\n\r\n _createProgram: function(pass, uniforms) {\r\n var hash = this._computeHashFromPass(pass);\r\n if (this._programs[hash] !== undefined) {\r\n return this._programs[hash];\r\n }\r\n\r\n const fragment = ComposerPostProcess.FragmentShader.replace(\"$FUNCTION_FILE$\", this._functionsFile)\r\n\r\n var source = this._writeDeclarations(\r\n fragment,\r\n uniforms,\r\n pass.textures,\r\n pass.header\r\n );\r\n\r\n source = this._writeFunctionBodies(source, pass.funcs, pass.textures, pass.collapsible);\r\n source = this._writeMainFunction(source, pass.funcs, pass.collapsible, pass.out.name);\r\n\r\n source = source.replace('%name%', pass.out.name);\r\n source = this._removeDuplicatedUniforms(source);\r\n\r\n var vertexSource = ComposerPostProcess.VertexShader.replace('%name%', pass.out.name);\r\n var program = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vertexSource),\r\n new Shader(Shader.FRAGMENT_SHADER, source)\r\n );\r\n\r\n this._programs[hash] = program;\r\n return program;\r\n },\r\n\r\n resize: function(width, height) {\r\n this.setScreenSize(width, height);\r\n\r\n // resize texture\r\n for (var key in this._texturePool) {\r\n var texture = this._texturePool[key].texture;\r\n\r\n if (this._texturePool[key].width !== undefined) {\r\n texture.setTextureSize(\r\n this._texturePool[key].width,\r\n this._texturePool[key].height\r\n );\r\n\r\n continue;\r\n }\r\n\r\n texture.setTextureSize(\r\n this._getTextureSize(width, texture.divisor),\r\n this._getTextureSize(height, texture.divisor)\r\n );\r\n }\r\n\r\n this.resizeRatio();\r\n },\r\n\r\n resizeRatio: function(xViewport, yViewport, xTexture, yTexture) {\r\n if (xViewport !== undefined) this._xViewportRatio = xViewport;\r\n if (yViewport !== undefined) this._yViewportRatio = yViewport;\r\n if (xTexture !== undefined) this._xTextureRatio = xTexture;\r\n if (yTexture !== undefined) this._yTextureRatio = yTexture;\r\n\r\n this._resizeViewports();\r\n this._resizeTextureUniforms();\r\n },\r\n\r\n _resizeViewports: function() {\r\n var xRatio = this.getGlobalXRatio();\r\n var yRatio = this.getGlobalYRatio();\r\n\r\n var cameras = this._cameras;\r\n for (var i = 0; i < cameras.length; ++i) {\r\n var camera = cameras[i];\r\n\r\n var isRtt = camera.isRenderToTextureCamera();\r\n var divisor = 1;\r\n if (isRtt) {\r\n var attachment = camera.getAttachments()[FrameBufferObject.COLOR_ATTACHMENT0];\r\n divisor = attachment.texture.divisor;\r\n }\r\n\r\n if (i === cameras.length - 1 && this._finalPassUpScaleToScreen) {\r\n xRatio = this._xViewportRatio;\r\n yRatio = this._yViewportRatio;\r\n }\r\n\r\n if (divisor === -1) {\r\n continue;\r\n }\r\n\r\n var width = this._getTextureSize(this._screenWidth, divisor / xRatio);\r\n var height = this._getTextureSize(this._screenHeight, divisor / yRatio);\r\n\r\n camera.getViewport().setViewport(0, 0, width, height);\r\n }\r\n },\r\n\r\n _resizeTextureUniforms: function() {\r\n var xRatio = this.getGlobalXRatio();\r\n var yRatio = this.getGlobalYRatio();\r\n\r\n var xFinalRatio = this._finalPassUpScaleToScreen ? this._xViewportRatio : xRatio;\r\n var yFinalRatio = this._finalPassUpScaleToScreen ? this._yViewportRatio : yRatio;\r\n\r\n // we delay the uniform size/ratio of the feedback texture on next frame\r\n this._syncFeedbackUniforms = true;\r\n\r\n var tunifs = this._textureUniforms;\r\n for (var i = 0; i < tunifs.length; ++i) {\r\n var obj = tunifs[i];\r\n var size = obj.size.getInternalArray();\r\n var ratio = obj.ratio.getInternalArray();\r\n\r\n // feedback texture update is delayed (unless first frame)\r\n if (obj.isFeedback && size[0]) {\r\n continue;\r\n }\r\n\r\n ratio[0] = xRatio;\r\n ratio[1] = yRatio;\r\n\r\n var texture = obj.texture;\r\n // final pass\r\n if (!texture) {\r\n size[0] = this._screenWidth * xFinalRatio;\r\n size[1] = this._screenHeight * yFinalRatio;\r\n continue;\r\n }\r\n\r\n // external texture\r\n if (!texture.divisor || texture.divisor < 0) {\r\n size[0] = texture.getWidth();\r\n size[1] = texture.getHeight();\r\n\r\n ratio[0] = ratio[1] = 1.0;\r\n continue;\r\n }\r\n\r\n // don't floor/round/ceil\r\n // (it may be useful when we force a nearest fetch in a shader)\r\n size[0] = xRatio * texture.getWidth();\r\n size[1] = yRatio * texture.getHeight();\r\n }\r\n },\r\n\r\n _resizeFeedbackTextureUniforms: function() {\r\n var xRatio = this._lastXratio;\r\n var yRatio = this._lastYratio;\r\n\r\n var tunifs = this._textureUniforms;\r\n for (var i = 0; i < tunifs.length; ++i) {\r\n var obj = tunifs[i];\r\n if (!obj.isFeedback) continue;\r\n\r\n var size = obj.size.getInternalArray();\r\n var ratio = obj.ratio.getInternalArray();\r\n\r\n var texture = obj.texture;\r\n ratio[0] = xRatio;\r\n ratio[1] = yRatio;\r\n\r\n size[0] = xRatio * texture.getWidth();\r\n size[1] = yRatio * texture.getHeight();\r\n }\r\n },\r\n\r\n cull: function() {\r\n if (this._syncOnNextFrame) {\r\n this._resizeFeedbackTextureUniforms();\r\n this._syncOnNextFrame = false;\r\n }\r\n\r\n if (this._syncFeedbackUniforms) {\r\n if (this._feedbackSwapped) {\r\n this._syncFeedbackUniforms = false;\r\n this._syncOnNextFrame = true;\r\n this._lastXratio = this.getGlobalXRatio();\r\n this._lastYratio = this.getGlobalYRatio();\r\n }\r\n }\r\n\r\n this._feedbackSwapped = false;\r\n return true;\r\n },\r\n\r\n _mergeWithoutDuplicates: function(a, b, compareFunc) {\r\n for (var i = 0; i < b.length; i++) {\r\n var element = b[i];\r\n\r\n var add = true;\r\n\r\n for (var j = 0; j < a.length; j++) {\r\n if (compareFunc(a[j], element)) {\r\n add = false;\r\n break;\r\n }\r\n }\r\n\r\n if (add) {\r\n a.push(element);\r\n }\r\n }\r\n\r\n return a;\r\n },\r\n\r\n _getTextureSize: function(size, divisor) {\r\n return Math.max(1.0, Math.round(size / divisor));\r\n },\r\n\r\n setScreenSize: function(width, height) {\r\n this._screenWidth = width;\r\n this._screenHeight = height;\r\n },\r\n\r\n setShaderProcessor: function(shaderProcessor) {\r\n this._shaderProcessor = shaderProcessor;\r\n },\r\n\r\n // textures owned by the composer, they will be cached/reused/resized unless reusable or immuable\r\n addInternalTexture: function(desc) {\r\n this._internalPasses.push({\r\n out: {\r\n name: desc.name,\r\n divisor: desc.divisor,\r\n type: desc.type,\r\n filter: desc.filter,\r\n srgb: desc.srgb,\r\n rgbm: desc.rgbm,\r\n immuable: desc.immuable,\r\n reusable: desc.reusable\r\n }\r\n });\r\n },\r\n\r\n // textures not owned by the composer, they won't be cached/reused/resized\r\n addExternalTexture: function(key, texture) {\r\n this._externalTextures[key] = texture;\r\n },\r\n\r\n setInputTexture: function(key) {\r\n this._firstTexture = key;\r\n },\r\n\r\n getCameras: function() {\r\n return this._cameras;\r\n },\r\n\r\n getStateSetPass: function(passName) {\r\n return this._stateSets[passName];\r\n },\r\n\r\n getInternalTexture: function(alias) {\r\n return this._userTextures[alias];\r\n }\r\n }),\r\n 'osgUtil',\r\n 'ComposerPostProcess'\r\n);\r\n\r\nexport default ComposerPostProcess;\r\n","import BufferArray from '../osg/BufferArray';\r\nimport Geometry from '../osg/Geometry';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\n\r\nvar glPrecision = ['#ifdef GL_ES', 'precision highp float;', '#endif'].join('\\n');\r\n\r\nvar program;\r\nvar getOrCreateShader = function() {\r\n if (program) return program;\r\n var shaderName = '#define SHADER_NAME GizmoLine3D';\r\n var vertexshader = [\r\n glPrecision,\r\n 'attribute vec3 Vertex;',\r\n 'uniform mat4 uModelViewMatrix;',\r\n 'uniform mat4 uProjectionMatrix;',\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);',\r\n '}'\r\n ].join('\\n');\r\n\r\n var fragmentshader = [\r\n glPrecision,\r\n 'uniform vec4 uColor;',\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' gl_FragColor = uColor;',\r\n '}'\r\n ].join('\\n');\r\n\r\n program = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vertexshader),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentshader)\r\n );\r\n return program;\r\n};\r\n\r\nvar program2D;\r\nvar getOrCreateShader2D = function() {\r\n if (program2D) return program2D;\r\n var shaderName = '#define SHADER_NAME GizmoLine2D';\r\n var vertexshader = [\r\n glPrecision,\r\n 'attribute vec2 Vertex;',\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' gl_Position = vec4(Vertex, 0.0, 1.0);',\r\n '}'\r\n ].join('\\n');\r\n\r\n var fragmentshader = [\r\n glPrecision,\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);',\r\n '}'\r\n ].join('\\n');\r\n\r\n program2D = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vertexshader),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentshader)\r\n );\r\n return program2D;\r\n};\r\n\r\nvar programQC;\r\nvar getOrCreateShaderQuadCircle = function() {\r\n if (programQC) return programQC;\r\n var shaderName = '#define SHADER_NAME GizmoQuadCircle';\r\n var vertexshader = [\r\n glPrecision,\r\n 'attribute vec3 Vertex;',\r\n 'uniform mat4 uModelViewMatrix;',\r\n 'uniform mat4 uProjectionMatrix;',\r\n 'varying vec3 vViewVertex;',\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' vViewVertex = Vertex;',\r\n ' gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);',\r\n '}'\r\n ].join('\\n');\r\n\r\n var fragmentshader = [\r\n glPrecision,\r\n 'uniform float uAngle;',\r\n 'uniform vec3 uBase;',\r\n 'varying vec3 vViewVertex;',\r\n 'const float PI = 3.14159265358979323846264;',\r\n 'const float PI2 = PI * 2.0;',\r\n shaderName,\r\n '',\r\n 'void main(void) {',\r\n ' if(length(vViewVertex) > 0.5)',\r\n ' discard;',\r\n ' vec3 vn = normalize(vViewVertex);',\r\n ' float angle = atan(uBase.y * vn.x - uBase.x * vn.y, dot(uBase, vn));',\r\n ' if(angle > 0.0) {',\r\n ' if(uAngle >= 0.0 && angle > uAngle) discard;',\r\n ' if(uAngle < -PI && angle < uAngle + PI2) discard;',\r\n ' if(uAngle < 0.0 && uAngle > -PI) discard;',\r\n ' }',\r\n ' if(angle < 0.0) {',\r\n ' if(uAngle <= 0.0 && angle < uAngle) discard;',\r\n ' if(uAngle > PI && angle > uAngle - PI2) discard;',\r\n ' if(uAngle > 0.0 && uAngle < PI) discard;',\r\n ' }',\r\n ' gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5);',\r\n '}'\r\n ].join('\\n');\r\n\r\n programQC = new Program(\r\n new Shader(Shader.VERTEX_SHADER, vertexshader),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentshader)\r\n );\r\n return programQC;\r\n};\r\n\r\nvar resetPrograms = function() {\r\n program = undefined;\r\n program2D = undefined;\r\n programQC = undefined;\r\n};\r\n\r\nvar createDebugLineGeometry = function() {\r\n var g = new Geometry();\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, new Float32Array(4), 2);\r\n var primitive = new DrawArrays(primitiveSet.LINES, 0, 2);\r\n g.getPrimitives().push(primitive);\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShader2D());\r\n return g;\r\n};\r\n\r\nvar createTorusGeometry = function(\r\n argRadiusOut,\r\n argRadiusWidth,\r\n argNbRadial,\r\n argNbTubular,\r\n argArc\r\n) {\r\n var radiusOut = argRadiusOut !== undefined ? argRadiusOut : 1.0;\r\n var radiusWidth = argRadiusWidth !== undefined ? argRadiusWidth : 0.2;\r\n var nbRadial = argNbRadial !== undefined ? argNbRadial : 6;\r\n var nbTubular = argNbTubular !== undefined ? argNbTubular : 64;\r\n var arc = argArc !== undefined ? argArc : Math.PI * 2;\r\n\r\n var nbVertices = (nbRadial + 1) * (nbTubular + 1);\r\n var nbTriangles = nbRadial * nbTubular * 2;\r\n var g = new Geometry();\r\n var vertices = new Float32Array(nbVertices * 3);\r\n var indices = new Uint16Array(nbTriangles * 3);\r\n arc = arc || Math.PI * 2;\r\n var id = 0;\r\n var k = 0;\r\n var i = 0;\r\n var j = 0;\r\n for (j = 0; j <= nbRadial; ++j) {\r\n for (i = 0; i <= nbTubular; ++i) {\r\n var u = i / nbTubular * arc;\r\n var v = j / nbRadial * Math.PI * 2;\r\n k = id * 3;\r\n vertices[k] = (radiusOut + radiusWidth * Math.cos(v)) * Math.cos(u);\r\n vertices[k + 1] = (radiusOut + radiusWidth * Math.cos(v)) * Math.sin(u);\r\n vertices[k + 2] = radiusWidth * Math.sin(v);\r\n id++;\r\n }\r\n }\r\n id = 0;\r\n for (j = 1; j <= nbRadial; ++j) {\r\n for (i = 1; i <= nbTubular; ++i) {\r\n k = id * 6;\r\n indices[k] = (nbTubular + 1) * j + i - 1;\r\n indices[k + 1] = indices[k + 3] = (nbTubular + 1) * (j - 1) + i - 1;\r\n indices[k + 2] = indices[k + 5] = (nbTubular + 1) * j + i;\r\n indices[k + 4] = (nbTubular + 1) * (j - 1) + i;\r\n id++;\r\n }\r\n }\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShader());\r\n g\r\n .getPrimitives()\r\n .push(\r\n new DrawElements(\r\n primitiveSet.TRIANGLES,\r\n new BufferArray(BufferArray.ELEMENT_ARRAY_BUFFER, indices, 1)\r\n )\r\n );\r\n return g;\r\n};\r\n\r\nvar createCylinderGeometry = function(\r\n argRadiusTop,\r\n argRadiusBottom,\r\n argHeight,\r\n argRadialSegments,\r\n argHeightSegments,\r\n argTopCap,\r\n argLowCap\r\n) {\r\n var radiusTop = argRadiusTop !== undefined ? argRadiusTop : 1.0;\r\n var radiusBottom = argRadiusBottom !== undefined ? argRadiusBottom : 1.0;\r\n var height = argHeight !== undefined ? argHeight : 5.0;\r\n var radialSegments = argRadialSegments !== undefined ? argRadialSegments : 32;\r\n var heightSegments = argHeightSegments !== undefined ? argHeightSegments : 1;\r\n var topCap = argTopCap !== undefined ? argTopCap : true;\r\n var lowCap = argLowCap !== undefined ? argLowCap : true;\r\n\r\n topCap = topCap && radiusTop > 0.0;\r\n lowCap = lowCap && radiusBottom > 0.0;\r\n var heightHalf = height * 0.5;\r\n\r\n var nbVertices = (heightSegments + 1) * (radialSegments + 1);\r\n var nbTriangles = heightSegments * radialSegments * 2;\r\n if (topCap) {\r\n nbVertices += 1;\r\n nbTriangles += radialSegments;\r\n }\r\n if (lowCap) {\r\n nbVertices += 1;\r\n nbTriangles += radialSegments;\r\n }\r\n var g = new Geometry();\r\n var vertices = new Float32Array(nbVertices * 3);\r\n var indices = new Uint16Array(nbTriangles * 3);\r\n\r\n var id = 0;\r\n var k = 0;\r\n var i = 0;\r\n var j = 0;\r\n for (i = 0; i <= heightSegments; i++) {\r\n var v = i / heightSegments;\r\n var radius = v * (radiusBottom - radiusTop) + radiusTop;\r\n for (j = 0; j <= radialSegments; j++) {\r\n var u = j / radialSegments;\r\n k = id * 3;\r\n vertices[k] = radius * Math.sin(u * Math.PI * 2);\r\n vertices[k + 1] = radius * Math.cos(u * Math.PI * 2);\r\n vertices[k + 2] = -v * height + heightHalf;\r\n id++;\r\n }\r\n }\r\n\r\n id = 0;\r\n for (j = 0; j < radialSegments; j++) {\r\n for (i = 0; i < heightSegments; i++) {\r\n k = id * 6;\r\n indices[k] = (radialSegments + 1) * i + j;\r\n indices[k + 1] = indices[k + 3] = (radialSegments + 1) * (i + 1) + j;\r\n indices[k + 2] = indices[k + 5] = (radialSegments + 1) * i + j + 1;\r\n indices[k + 4] = (radialSegments + 1) * (i + 1) + j + 1;\r\n id++;\r\n }\r\n }\r\n id *= 2;\r\n var last;\r\n if (topCap) {\r\n last = (lowCap ? vertices.length - 6 : vertices.length - 3) / 3;\r\n vertices[last * 3 + 2] = heightHalf;\r\n for (j = 0; j < radialSegments; j++) {\r\n k = id * 3;\r\n indices[k] = j;\r\n indices[k + 1] = j + 1;\r\n indices[k + 2] = last;\r\n id++;\r\n }\r\n }\r\n\r\n if (lowCap) {\r\n last = (vertices.length - 3) / 3;\r\n vertices[last * 3 + 2] = -heightHalf;\r\n var end = (radialSegments + 1) * i;\r\n for (j = 0; j < radialSegments; j++) {\r\n k = id * 3;\r\n indices[k] = end + j + 1;\r\n indices[k + 1] = end + j;\r\n indices[k + 2] = last;\r\n id++;\r\n }\r\n }\r\n\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShader());\r\n g\r\n .getPrimitives()\r\n .push(\r\n new DrawElements(\r\n primitiveSet.TRIANGLES,\r\n new BufferArray(BufferArray.ELEMENT_ARRAY_BUFFER, indices, 1)\r\n )\r\n );\r\n return g;\r\n};\r\n\r\nvar createCircleGeometry = function(nbVertices, radius, argArc) {\r\n var g = new Geometry();\r\n var vertices = new Float32Array(nbVertices * 3);\r\n var arc = argArc || Math.PI * 2;\r\n for (var i = 0; i < nbVertices; ++i) {\r\n var j = i * 3;\r\n var segment = arc * i / nbVertices;\r\n vertices[j] = Math.cos(segment) * radius;\r\n vertices[j + 1] = Math.sin(segment) * radius;\r\n }\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n var primitive = new DrawArrays(primitiveSet.LINE_STRIP, 0, nbVertices);\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShader());\r\n g.getPrimitives().push(primitive);\r\n return g;\r\n};\r\n\r\nvar createPlaneGeometry = function(width, height) {\r\n var offx = width ? width * 0.5 : 0.5;\r\n var offy = height ? height * 0.5 : 0.5;\r\n\r\n var g = new Geometry();\r\n var vertices = new Float32Array(12);\r\n vertices[0] = -offx;\r\n vertices[1] = -offy;\r\n\r\n vertices[3] = offx;\r\n vertices[4] = -offy;\r\n\r\n vertices[6] = -offx;\r\n vertices[7] = offy;\r\n\r\n vertices[9] = offx;\r\n vertices[10] = offy;\r\n\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n var primitive = new DrawArrays(primitiveSet.TRIANGLE_STRIP, 0, 4);\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShader());\r\n g.getPrimitives().push(primitive);\r\n return g;\r\n};\r\n\r\nvar createQuadCircleGeometry = function() {\r\n var g = createPlaneGeometry();\r\n g.getOrCreateStateSet().setAttributeAndModes(getOrCreateShaderQuadCircle());\r\n return g;\r\n};\r\n\r\nvar GizmoGeometry = {};\r\nGizmoGeometry.createCircleGeometry = createCircleGeometry;\r\nGizmoGeometry.createCylinderGeometry = createCylinderGeometry;\r\nGizmoGeometry.createTorusGeometry = createTorusGeometry;\r\nGizmoGeometry.createDebugLineGeometry = createDebugLineGeometry;\r\nGizmoGeometry.createPlaneGeometry = createPlaneGeometry;\r\nGizmoGeometry.createQuadCircleGeometry = createQuadCircleGeometry;\r\nGizmoGeometry.resetPrograms = resetPrograms;\r\n\r\nexport default GizmoGeometry;\r\n","import Shape from '../osg/shape';\r\n\r\n/*\r\n * Given a Camera, update a wireframe representation of its\r\n * view frustum from a projection and depthrange\r\n * @param Geomtry g frustum geometry\r\n * @param Matrix proj Projection\r\n * @param Vec2 dR depthRange (optional, only if proj is infinite)\r\n */\r\nvar updateFrustum = function(proj, dR) {\r\n var near, far;\r\n if (!dR) {\r\n // Get near and far from the Projection matrix.\r\n near = proj[14] / (proj[10] - 1.0);\r\n far = proj[14] / (1.0 + proj[10]);\r\n } else {\r\n near = dR[0];\r\n far = dR[1];\r\n }\r\n\r\n // Get the sides of the near plane.\r\n var nLeft = near * (proj[8] - 1.0) / proj[0];\r\n var nRight = near * (1.0 + proj[8]) / proj[0];\r\n var nTop = near * (1.0 + proj[9]) / proj[5];\r\n var nBottom = near * (proj[9] - 1.0) / proj[5];\r\n\r\n // Get the sides of the far plane.\r\n var fLeft = far * (proj[8] - 1.0) / proj[0];\r\n var fRight = far * (1.0 + proj[8]) / proj[0];\r\n var fTop = far * (1.0 + proj[9]) / proj[5];\r\n var fBottom = far * (proj[9] - 1.0) / proj[5];\r\n\r\n var vBuff = this.getAttributes().Vertex;\r\n var v = vBuff.getElements();\r\n\r\n // eight corners of the near and far planes.\r\n v[0] = nLeft;\r\n v[1] = nBottom;\r\n v[2] = -near;\r\n\r\n v[3] = nRight;\r\n v[4] = nBottom;\r\n v[5] = -near;\r\n\r\n v[6] = nRight;\r\n v[7] = nTop;\r\n v[8] = -near;\r\n\r\n v[9] = nLeft;\r\n v[10] = nTop;\r\n v[11] = -near;\r\n\r\n v[12] = fLeft;\r\n v[13] = fBottom;\r\n v[14] = -far;\r\n\r\n v[15] = fRight;\r\n v[16] = fBottom;\r\n v[17] = -far;\r\n\r\n v[18] = fRight;\r\n v[19] = fTop;\r\n v[20] = -far;\r\n\r\n v[21] = fLeft;\r\n v[22] = fTop;\r\n v[23] = -far;\r\n\r\n vBuff.dirty();\r\n};\r\n/*\r\n * Given a Camera, create a wireframe representation\r\n * of its view frustum\r\n */\r\nvar createDebugFrustrumGeometry = function() {\r\n var g = Shape.createBoundingBoxGeometry();\r\n g.updateGeometry = updateFrustum;\r\n return g;\r\n};\r\n\r\nexport default {\r\n createDebugFrustumGeometry: createDebugFrustrumGeometry\r\n};\r\n","import Node from '../osg/Node';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport Depth from '../osg/Depth';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport CullFace from '../osg/CullFace';\r\nimport Uniform from '../osg/Uniform';\r\nimport { vec2, vec3, vec4, mat4, quat } from '../osg/glMatrix';\r\nimport IntersectionVisitor from '../osgUtil/IntersectionVisitor';\r\nimport LineSegmentIntersector from '../osgUtil/LineSegmentIntersector';\r\nimport GizmoGeometry from '../osgUtil/gizmoGeometry';\r\nimport TransformEnums from '../osg/transformEnums';\r\nimport utils from '../osg/utils';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar HideCullCallback = function() {};\r\nHideCullCallback.prototype = {\r\n cull: function() {\r\n return false;\r\n }\r\n};\r\n\r\nvar blendAttribute = new BlendFunc(BlendFunc.SRC_ALPHA, BlendFunc.ONE_MINUS_SRC_ALPHA);\r\n\r\nvar LineCustomIntersector = function(testPlane) {\r\n this._testPlane = testPlane; // intersection plane or line\r\n this._inter = vec3.create(); // translate distance\r\n LineSegmentIntersector.call(this);\r\n};\r\nutils.createPrototypeObject(\r\n LineCustomIntersector,\r\n utils.objectInherit(LineSegmentIntersector.prototype, {\r\n setTestPlane: function(testPlane) {\r\n this._testPlane = testPlane; // intersection plane or line\r\n },\r\n getTranslateDistance: function() {\r\n return this._inter;\r\n },\r\n enter: (function() {\r\n var axis = vec3.create();\r\n var dir = vec3.create();\r\n\r\n return function(node) {\r\n if (node._nbAxis === undefined) return true;\r\n\r\n vec3.init(axis);\r\n axis[node._nbAxis] = 1.0;\r\n if (!this._testPlane) {\r\n // intersection line line\r\n vec3.normalize(dir, vec3.sub(dir, this._iEnd, this._iStart));\r\n\r\n var a01 = -vec3.dot(dir, axis);\r\n var b0 = vec3.dot(this._iStart, dir);\r\n var det = Math.abs(1.0 - a01 * a01);\r\n\r\n var b1 = -vec3.dot(this._iStart, axis);\r\n vec3.init(this._inter);\r\n this._inter[node._nbAxis] = (a01 * b0 - b1) / det;\r\n } else {\r\n // intersection line plane\r\n var dist1 = vec3.dot(this._iStart, axis);\r\n var dist2 = vec3.dot(this._iEnd, axis);\r\n // ray copplanar to triangle\r\n if (dist1 === dist2) return false;\r\n // intersection between ray and triangle\r\n var val = -dist1 / (dist2 - dist1);\r\n this._inter[0] = this._iStart[0] + (this._iEnd[0] - this._iStart[0]) * val;\r\n this._inter[1] = this._iStart[1] + (this._iEnd[1] - this._iStart[1]) * val;\r\n this._inter[2] = this._iStart[2] + (this._iEnd[2] - this._iStart[2]) * val;\r\n }\r\n return false;\r\n };\r\n })(),\r\n intersectTriangle: function() {},\r\n intersectLine: function() {},\r\n intersectPoint: function() {}\r\n }),\r\n 'osgUtil',\r\n 'LineCustomIntersector'\r\n);\r\n\r\n// for getWorldMatrix\r\nvar _TMP_MAT = mat4.create();\r\n\r\n// The MT node can be detected as such because they\r\n// have a '_nbAxis' property on them (x=0, y=1, z=2)\r\n//\r\n// MatrixTransform _________________________________________\r\n// | | |\r\n// ____ Rotate Translate TranslatePlane\r\n// | / | \\ / | \\ / | \\\r\n// MT MT MT MT MT MT MT MT MT MT\r\n// | \\ | / \\ | / \\ | /\r\n// FullArc \\|/ \\|/ \\|/\r\n// ____|_____ ___|________ ___|________\r\n// | | | | | |\r\n// DrawArc HideNode DrawArrow HideNode DrawPlane HideNode\r\n// | | |\r\n// PickArc PickArrow PickPlane\r\n//\r\nvar NodeGizmo = function(viewer) {\r\n MatrixTransform.call(this);\r\n\r\n this._tmask = 1; // traversal mask when picking the scene\r\n\r\n // When attaching the gizmo on a node, there's 2 ways:\r\n // - if _autoInsertMT is true and no direct parent has an editMask\r\n // we insert a matrixTransform that we are going to edit\r\n // - otherwise we look for the nearest MatrixTransform with an editMask on the graph\r\n this._autoInsertMT = false;\r\n this._correctPivotOnAutoInsert = false;\r\n\r\n this._viewer = viewer;\r\n this._canvas = viewer.getGraphicContext().canvas;\r\n\r\n this._rotateNode = new MatrixTransform();\r\n this._translateNode = new MatrixTransform();\r\n this._planeNode = new MatrixTransform();\r\n\r\n this._rotateInLocal = true; // local vs world space\r\n this._translateInLocal = true; // local vs world space\r\n this._showAngle = new MatrixTransform();\r\n\r\n //for realtime picking\r\n this._downCanvasCoord = vec2.create();\r\n this._hoverNode = null; // the hovered x/y/z MT node\r\n this._keepHoverColor = vec4.create();\r\n\r\n // for editing\r\n this._isEditing = false;\r\n\r\n this._editLineOrigin = vec3.create();\r\n this._editLineDirection = vec3.create();\r\n this._editOffset = vec3.create();\r\n\r\n // cached matrices when starting the editing operations\r\n this._editLocal = mat4.create();\r\n this._editWorldTrans = mat4.create();\r\n this._editWorldScaleRot = mat4.create();\r\n this._editInvWorldScaleRot = mat4.create();\r\n\r\n // red line, it can be useful as helpers too\r\n this._debugNode = new Node();\r\n\r\n this._lastDistToEye = 0.0; // see updateGizmo comment\r\n\r\n this._attachedNode = null;\r\n this._pivotOffset = vec3.create(); // to center the gizmo and rotation pivot when inserting MT\r\n this.attachToNode(null);\r\n\r\n // Intersectors\r\n this._lsi = new LineCustomIntersector();\r\n this._origIntersect = vec3.create();\r\n this._dstIntersect = vec3.create();\r\n this._iv = new IntersectionVisitor();\r\n this._iv.setIntersector(this._lsi);\r\n\r\n this.init();\r\n};\r\n\r\n// picking masks\r\nNodeGizmo.NO_PICK = 1 << 0;\r\n\r\nNodeGizmo.PICK_ARC_X = 1 << 1;\r\nNodeGizmo.PICK_ARC_Y = 1 << 2;\r\nNodeGizmo.PICK_ARC_Z = 1 << 3;\r\n\r\nNodeGizmo.PICK_ARROW_X = 1 << 4;\r\nNodeGizmo.PICK_ARROW_Y = 1 << 5;\r\nNodeGizmo.PICK_ARROW_Z = 1 << 6;\r\n\r\nNodeGizmo.PICK_PLANE_X = 1 << 7;\r\nNodeGizmo.PICK_PLANE_Y = 1 << 8;\r\nNodeGizmo.PICK_PLANE_Z = 1 << 9;\r\n\r\nNodeGizmo.NO_FULL_CIRCLE = 1 << 10; // don't display the full non pickable circle (visual cue)\r\nNodeGizmo.CORRECT_PIVOT = 1 << 11; // recompute pivot to center of bound node instead of local origin\r\n\r\nNodeGizmo.PICK_ARC = NodeGizmo.PICK_ARC_X | NodeGizmo.PICK_ARC_Y | NodeGizmo.PICK_ARC_Z;\r\nNodeGizmo.PICK_ARROW = NodeGizmo.PICK_ARROW_X | NodeGizmo.PICK_ARROW_Y | NodeGizmo.PICK_ARROW_Z;\r\nNodeGizmo.PICK_PLANE = NodeGizmo.PICK_PLANE_X | NodeGizmo.PICK_PLANE_Y | NodeGizmo.PICK_PLANE_Z;\r\n\r\nNodeGizmo.PICK_GIZMO = NodeGizmo.PICK_ARC | NodeGizmo.PICK_ARROW | NodeGizmo.PICK_PLANE;\r\n\r\n// retrieve nearest editable node\r\nvar GetNearestEditableNode = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_PARENTS);\r\n this._editableNode = null;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n GetNearestEditableNode,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function() {\r\n NodeVisitor.prototype.reset.call(this);\r\n this._editableNode = null;\r\n },\r\n getEditableNode: function() {\r\n return this._editableNode;\r\n },\r\n apply: function(node) {\r\n if (this._editableNode) return;\r\n\r\n var editMask = node.editMask;\r\n if (editMask && editMask & NodeGizmo.PICK_GIZMO) {\r\n this._editableNode = node;\r\n return;\r\n }\r\n\r\n this.traverse(node);\r\n }\r\n })\r\n);\r\n\r\nutils.createPrototypeNode(\r\n NodeGizmo,\r\n utils.objectInherit(MatrixTransform.prototype, {\r\n setRotateInLocal: function(bool) {\r\n this._rotateInLocal = bool;\r\n },\r\n\r\n setTranslateInLocal: function(bool) {\r\n this._translateInLocal = bool;\r\n },\r\n\r\n setTraversalMask: function(tmask) {\r\n this._tmask = tmask;\r\n },\r\n\r\n setAutoMatrixTransformInsertion: function(bool) {\r\n this._autoInsertMT = bool;\r\n },\r\n\r\n setCorrectPivotOnAutoInsert: function(bool) {\r\n this._correctPivotOnAutoInsert = bool;\r\n },\r\n\r\n isEditing: function() {\r\n return this._isEditing;\r\n },\r\n\r\n getAttachedNode: function() {\r\n return this._attachedNode;\r\n },\r\n\r\n init: function() {\r\n this.getOrCreateStateSet().setAttributeAndModes(new Depth(Depth.DISABLE));\r\n this.getOrCreateStateSet().setAttributeAndModes(new CullFace(CullFace.DISABLE));\r\n\r\n this.addUpdateCallback(this);\r\n this.addChild(this.initNodeTranslate());\r\n this.addChild(this.initNodeTranslatePlane());\r\n this.addChild(this.initNodeRotate());\r\n if (this._debugNode) {\r\n this._debugNode.addChild(GizmoGeometry.createDebugLineGeometry());\r\n this.addChild(this._debugNode);\r\n this._debugNode.setNodeMask(0x0);\r\n }\r\n\r\n var manager = this._viewer.getInputManager();\r\n\r\n manager.group(InputGroups.NODE_GIZMO).addMappings(\r\n {\r\n onMouseMove: ['mousemove', 'touchmove'],\r\n onMouseDown: ['mousedown', 'touchstart'],\r\n onMouseUp: ['mouseup', 'mouseout', 'touchend', 'touchcancel']\r\n },\r\n this\r\n );\r\n manager.setPriority(\r\n InputGroups.NODE_GIZMO,\r\n manager.getHigherPriority(InputGroups.MANIPULATORS)\r\n );\r\n },\r\n\r\n _insertEditNode: function(parent, node) {\r\n var mtInsert = new MatrixTransform();\r\n\r\n mtInsert.editMask = NodeGizmo.PICK_GIZMO;\r\n if (this._correctPivotOnAutoInsert) mtInsert.editMask |= NodeGizmo.CORRECT_PIVOT;\r\n\r\n parent.addChild(mtInsert);\r\n parent.removeChild(node);\r\n mtInsert.addChild(node);\r\n\r\n mtInsert._isInserted = true;\r\n\r\n return mtInsert;\r\n },\r\n\r\n _findEditNodeFromNodePath: function(nodepath) {\r\n if (!nodepath) return null;\r\n\r\n var node = nodepath[nodepath.length - 1];\r\n if (node.editMask) return node;\r\n\r\n if (!this._autoInsertMT) {\r\n for (var i = nodepath.length - 1; i >= 0; --i) {\r\n var editMask = nodepath[i].editMask;\r\n if (editMask && editMask & NodeGizmo.PICK_GIZMO) return nodepath[i];\r\n }\r\n\r\n return null;\r\n }\r\n\r\n var parent = nodepath[nodepath.length - 2];\r\n // direct parent is already an editable node\r\n if (parent.editMask) return parent;\r\n return this._insertEditNode(parent, node);\r\n },\r\n\r\n _findEditNodeFromNode: function(node) {\r\n if (!node) return null;\r\n if (node.editMask) return node;\r\n\r\n if (this._autoInsertMT) {\r\n var parents = node.getParents();\r\n // direct parent is already an editable node\r\n for (var i = 0; i < parents.length; ++i) {\r\n var editMask = parents[i].editMask;\r\n if (editMask && editMask & NodeGizmo.PICK_GIZMO) return parents[i];\r\n }\r\n\r\n // we have to choose an arbitrary parent here\r\n return this._insertEditNode(parents[0], node);\r\n }\r\n\r\n if (!this._getEditNodeVisitor) {\r\n this._getEditNodeVisitor = new GetNearestEditableNode();\r\n } else {\r\n this._getEditNodeVisitor.reset();\r\n }\r\n\r\n node.accept(this._getEditNodeVisitor);\r\n return this._getEditNodeVisitor.getEditableNode();\r\n },\r\n\r\n attachToNodePath: function(nodepath) {\r\n var editNode = this._findEditNodeFromNodePath(nodepath);\r\n this._attachEditNode(editNode, nodepath && nodepath[nodepath.length - 1]);\r\n },\r\n\r\n attachToNode: function(node) {\r\n var editNode = this._findEditNodeFromNode(node);\r\n this._attachEditNode(editNode, node);\r\n },\r\n\r\n _attachEditNode: function(editNode, userNode) {\r\n this._attachedNode = editNode;\r\n\r\n if (editNode && userNode && userNode !== editNode) {\r\n if (editNode.editMask & NodeGizmo.CORRECT_PIVOT) {\r\n vec3.copy(this._pivotOffset, userNode.getBoundingSphere().center());\r\n }\r\n }\r\n\r\n this.updateGizmoMask();\r\n },\r\n\r\n updateGizmoMask: function() {\r\n if (!this._attachedNode) {\r\n vec3.init(this._pivotOffset);\r\n this.setNodeMask(0x0);\r\n return;\r\n }\r\n\r\n var mask = this._attachedNode.editMask;\r\n\r\n this.setNodeMask(mask & NodeGizmo.PICK_GIZMO ? NodeGizmo.NO_PICK : 0x0);\r\n\r\n this._translateNode.setNodeMask(\r\n mask & NodeGizmo.PICK_ARROW ? NodeGizmo.PICK_ARROW : 0x0\r\n );\r\n this._rotateNode.setNodeMask(mask & NodeGizmo.PICK_ARC ? NodeGizmo.PICK_ARC : 0x0);\r\n this._planeNode.setNodeMask(mask & NodeGizmo.PICK_PLANE ? NodeGizmo.PICK_PLANE : 0x0);\r\n\r\n var transChildren = this._translateNode.getChildren();\r\n transChildren[0].setNodeMask(\r\n mask & NodeGizmo.PICK_ARROW_X ? NodeGizmo.PICK_ARROW_X : 0x0\r\n );\r\n transChildren[1].setNodeMask(\r\n mask & NodeGizmo.PICK_ARROW_Y ? NodeGizmo.PICK_ARROW_Y : 0x0\r\n );\r\n transChildren[2].setNodeMask(\r\n mask & NodeGizmo.PICK_ARROW_Z ? NodeGizmo.PICK_ARROW_Z : 0x0\r\n );\r\n\r\n // children 0 is full arc\r\n var rotChildren = this._rotateNode.getChildren();\r\n rotChildren[0].setNodeMask(mask & NodeGizmo.NO_FULL_CIRCLE ? 0x0 : NodeGizmo.NO_PICK);\r\n rotChildren[1].setNodeMask(mask & NodeGizmo.PICK_ARC_X ? NodeGizmo.PICK_ARC_X : 0x0);\r\n rotChildren[2].setNodeMask(mask & NodeGizmo.PICK_ARC_Y ? NodeGizmo.PICK_ARC_Y : 0x0);\r\n rotChildren[3].setNodeMask(mask & NodeGizmo.PICK_ARC_Z ? NodeGizmo.PICK_ARC_Z : 0x0);\r\n\r\n var planeChildren = this._planeNode.getChildren();\r\n planeChildren[0].setNodeMask(\r\n mask & NodeGizmo.PICK_PLANE_X ? NodeGizmo.PICK_PLANE_X : 0x0\r\n );\r\n planeChildren[1].setNodeMask(\r\n mask & NodeGizmo.PICK_PLANE_Y ? NodeGizmo.PICK_PLANE_Y : 0x0\r\n );\r\n planeChildren[2].setNodeMask(\r\n mask & NodeGizmo.PICK_PLANE_Z ? NodeGizmo.PICK_PLANE_Z : 0x0\r\n );\r\n },\r\n\r\n onNodeHovered: (function() {\r\n var hoverColor = vec4.fromValues(1.0, 1.0, 0.0, 1.0);\r\n\r\n return function(hit) {\r\n if (this._hoverNode)\r\n this._hoverNode\r\n .getStateSet()\r\n .getUniform('uColor')\r\n .setFloat4(this._keepHoverColor);\r\n if (!hit) {\r\n this._hoverNode = null;\r\n return;\r\n }\r\n\r\n // stop at the first X/Y/Z matrix node\r\n var np = hit._nodePath;\r\n var i = np.length - 1;\r\n var node = np[i];\r\n while (node._nbAxis === undefined) {\r\n if (i === 0) return;\r\n node = np[--i];\r\n }\r\n\r\n var unif = node.getStateSet().getUniform('uColor');\r\n this._hoverNode = node;\r\n vec4.copy(this._keepHoverColor, unif.getInternalArray());\r\n unif.setFloat4(hoverColor);\r\n };\r\n })(),\r\n\r\n initNodeRotate: function() {\r\n var drawArcXYZ = GizmoGeometry.createTorusGeometry(1.0, 0.01, 6, 64, Math.PI * 2);\r\n var drawArc = GizmoGeometry.createTorusGeometry(1.0, 0.01, 6, 64, Math.PI);\r\n var pickArc = GizmoGeometry.createTorusGeometry(1.0, 0.1, 6, 64, Math.PI);\r\n\r\n var mtXYZ = new MatrixTransform();\r\n var mtX = new MatrixTransform();\r\n var mtY = new MatrixTransform();\r\n var mtZ = new MatrixTransform();\r\n mtX._nbAxis = 0;\r\n mtY._nbAxis = 1;\r\n mtZ._nbAxis = 2;\r\n\r\n var hideNode = new Node();\r\n hideNode.setCullCallback(new HideCullCallback());\r\n hideNode.addChild(pickArc);\r\n\r\n // set masks\r\n drawArcXYZ.setNodeMask(NodeGizmo.NO_PICK);\r\n drawArc.setNodeMask(NodeGizmo.NO_PICK);\r\n mtX.setNodeMask(NodeGizmo.PICK_ARC_X);\r\n mtY.setNodeMask(NodeGizmo.PICK_ARC_Y);\r\n mtZ.setNodeMask(NodeGizmo.PICK_ARC_Z);\r\n\r\n mtXYZ.addChild(drawArcXYZ);\r\n mtX.addChild(drawArc);\r\n mtY.addChild(drawArc);\r\n mtZ.addChild(drawArc);\r\n\r\n mtX.addChild(hideNode);\r\n mtY.addChild(hideNode);\r\n mtZ.addChild(hideNode);\r\n\r\n mtXYZ\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.2, 0.2, 0.2, 1.0), 'uColor'));\r\n mtX\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(1.0, 0.0, 0.0, 1.0), 'uColor'));\r\n mtY\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 1.0, 0.0, 1.0), 'uColor'));\r\n mtZ\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 0.0, 1.0, 1.0), 'uColor'));\r\n\r\n var showAngle = this._showAngle;\r\n showAngle.getOrCreateStateSet().setAttributeAndModes(blendAttribute);\r\n showAngle.setNodeMask(0x0);\r\n showAngle\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat3(vec3.fromValues(1.0, 0.0, 0.0), 'uBase'));\r\n showAngle.getOrCreateStateSet().addUniform(Uniform.createFloat(0.0, 'uAngle'));\r\n showAngle.addChild(GizmoGeometry.createQuadCircleGeometry());\r\n\r\n var rotate = this._rotateNode;\r\n rotate.setNodeMask(NodeGizmo.PICK_ARC);\r\n rotate.addChild(mtXYZ);\r\n rotate.addChild(mtX);\r\n rotate.addChild(mtY);\r\n rotate.addChild(mtZ);\r\n rotate.addChild(showAngle);\r\n return rotate;\r\n },\r\n\r\n initNodeTranslate: function() {\r\n var aHeight = 1.5;\r\n var aConeHeight = 0.3;\r\n var pickStart = 0.5; // offset (because of the picking plane)\r\n var pickHeight = (aHeight - pickStart + aConeHeight) * 1.1;\r\n\r\n // cone arrow\r\n var mtCone = new MatrixTransform();\r\n mat4.fromTranslation(\r\n mtCone.getMatrix(),\r\n vec3.fromValues(0.0, 0.0, aHeight + aConeHeight * 0.5)\r\n );\r\n mtCone.addChild(\r\n GizmoGeometry.createCylinderGeometry(0.0, 0.07, aConeHeight, 32, 1, true, true)\r\n );\r\n // arrow base\r\n var mtArrow = new MatrixTransform();\r\n mat4.fromTranslation(mtArrow.getMatrix(), vec3.fromValues(0.0, 0.0, aHeight * 0.5));\r\n mtArrow.addChild(\r\n GizmoGeometry.createCylinderGeometry(0.01, 0.01, aHeight, 32, 1, true, true)\r\n );\r\n // draw arrow\r\n var drawArrow = new Node();\r\n drawArrow.addChild(mtArrow);\r\n drawArrow.addChild(mtCone);\r\n\r\n var pickArrow = GizmoGeometry.createCylinderGeometry(\r\n 0.1,\r\n 0.1,\r\n pickHeight,\r\n 32,\r\n 1,\r\n true,\r\n true\r\n );\r\n\r\n var mtX = new MatrixTransform();\r\n var mtY = new MatrixTransform();\r\n var mtZ = new MatrixTransform();\r\n mtX._nbAxis = 0;\r\n mtY._nbAxis = 1;\r\n mtZ._nbAxis = 2;\r\n\r\n mat4.fromRotation(mtX.getMatrix(), Math.PI * 0.5, vec3.fromValues(0.0, 1.0, 0.0));\r\n mat4.fromRotation(mtY.getMatrix(), -Math.PI * 0.5, vec3.fromValues(1.0, 0.0, 0.0));\r\n\r\n var hideNode = new MatrixTransform();\r\n hideNode.setCullCallback(new HideCullCallback());\r\n mat4.fromTranslation(\r\n hideNode.getMatrix(),\r\n vec3.fromValues(0.0, 0.0, pickStart + pickHeight * 0.5)\r\n );\r\n hideNode.addChild(pickArrow);\r\n\r\n // set masks\r\n drawArrow.setNodeMask(NodeGizmo.NO_PICK);\r\n mtX.setNodeMask(NodeGizmo.PICK_ARROW_X);\r\n mtY.setNodeMask(NodeGizmo.PICK_ARROW_Y);\r\n mtZ.setNodeMask(NodeGizmo.PICK_ARROW_Z);\r\n\r\n mtX.addChild(drawArrow);\r\n mtY.addChild(drawArrow);\r\n mtZ.addChild(drawArrow);\r\n\r\n mtX.addChild(hideNode);\r\n mtY.addChild(hideNode);\r\n mtZ.addChild(hideNode);\r\n\r\n mtX\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(1.0, 0.0, 0.0, 1.0), 'uColor'));\r\n mtY\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 1.0, 0.0, 1.0), 'uColor'));\r\n mtZ\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 0.0, 1.0, 1.0), 'uColor'));\r\n\r\n var translate = this._translateNode;\r\n translate.setNodeMask(NodeGizmo.PICK_ARROW);\r\n translate.addChild(mtX);\r\n translate.addChild(mtY);\r\n translate.addChild(mtZ);\r\n return translate;\r\n },\r\n\r\n initNodeTranslatePlane: function() {\r\n var mtPlane = new MatrixTransform();\r\n mat4.fromTranslation(mtPlane.getMatrix(), vec3.fromValues(0.5, 0.5, 0.0));\r\n mat4.mul(\r\n mtPlane.getMatrix(),\r\n mat4.fromScaling(mat4.create(), vec3.fromValues(0.5, 0.5, 1.0)),\r\n mtPlane.getMatrix()\r\n );\r\n mtPlane.addChild(GizmoGeometry.createPlaneGeometry());\r\n\r\n var mtX = new MatrixTransform();\r\n var mtY = new MatrixTransform();\r\n var mtZ = new MatrixTransform();\r\n mtX._nbAxis = 0;\r\n mtY._nbAxis = 1;\r\n mtZ._nbAxis = 2;\r\n\r\n mat4.fromRotation(mtX.getMatrix(), -Math.PI * 0.5, vec3.fromValues(0.0, 1.0, 0.0));\r\n mat4.fromRotation(mtY.getMatrix(), Math.PI * 0.5, vec3.fromValues(1.0, 0.0, 0.0));\r\n\r\n // set masks\r\n mtX.setNodeMask(NodeGizmo.PICK_PLANE_X);\r\n mtY.setNodeMask(NodeGizmo.PICK_PLANE_Y);\r\n mtZ.setNodeMask(NodeGizmo.PICK_PLANE_Z);\r\n\r\n mtX.addChild(mtPlane);\r\n mtY.addChild(mtPlane);\r\n mtZ.addChild(mtPlane);\r\n\r\n mtX\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(1.0, 0.0, 0.0, 0.3), 'uColor'));\r\n mtY\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 1.0, 0.0, 0.3), 'uColor'));\r\n mtZ\r\n .getOrCreateStateSet()\r\n .addUniform(Uniform.createFloat4(vec4.fromValues(0.0, 0.0, 1.0, 0.3), 'uColor'));\r\n\r\n var plane = this._planeNode;\r\n plane.setNodeMask(NodeGizmo.PICK_PLANE);\r\n plane.getOrCreateStateSet().setAttributeAndModes(blendAttribute);\r\n plane.addChild(mtX);\r\n plane.addChild(mtY);\r\n plane.addChild(mtZ);\r\n return plane;\r\n },\r\n\r\n updateArcRotation: (function() {\r\n var qTmp = quat.create();\r\n var quatx = quat.setAxisAngle(quat.create(), [0.0, 1.0, 0.0], -Math.PI * 0.5);\r\n var quaty = quat.setAxisAngle(quat.create(), [1.0, 0.0, 0.0], -Math.PI * 0.5);\r\n return function(eye) {\r\n var rotateNode = this._rotateNode;\r\n var arcs = rotateNode.getChildren();\r\n // eye arc\r\n qTmp[0] = -eye[1];\r\n qTmp[1] = eye[0];\r\n qTmp[2] = 0.0;\r\n qTmp[3] = 1.0 + eye[2];\r\n quat.normalize(qTmp, qTmp);\r\n mat4.fromQuat(arcs[0].getMatrix(), qTmp);\r\n // x arc\r\n quat.setAxisAngle(qTmp, [1.0, 0.0, 0.0], Math.atan2(eye[2], eye[1]));\r\n quat.mul(qTmp, qTmp, quatx);\r\n mat4.fromQuat(arcs[1].getMatrix(), qTmp);\r\n // y arc\r\n quat.setAxisAngle(qTmp, [0.0, 1.0, 0.0], Math.atan2(-eye[0], -eye[2]));\r\n quat.mul(qTmp, qTmp, quaty);\r\n mat4.fromQuat(arcs[2].getMatrix(), qTmp);\r\n // z arc\r\n quat.setAxisAngle(qTmp, [0.0, 0.0, 1.0], Math.atan2(-eye[0], eye[1]));\r\n mat4.fromQuat(arcs[3].getMatrix(), qTmp);\r\n\r\n arcs[1].dirtyBound();\r\n arcs[2].dirtyBound();\r\n arcs[3].dirtyBound();\r\n };\r\n })(),\r\n\r\n getTransformType: function(nodeIn) {\r\n // should probably be a visitor with traverse parents instead\r\n var node = nodeIn;\r\n while (node.getParents().length > 0) {\r\n var refFrame = node.referenceFrame;\r\n if (refFrame !== undefined && refFrame === TransformEnums.ABSOLUTE_RF) {\r\n return TransformEnums.ABSOLUTE_RF;\r\n }\r\n node = node.getParents()[0];\r\n }\r\n return TransformEnums.RELATIVE_RF;\r\n },\r\n\r\n getAttachedNodeWorldMatrix: function() {\r\n var worldMat = this._attachedNode.getWorldMatrix(undefined, _TMP_MAT);\r\n return mat4.translate(worldMat, worldMat, this._pivotOffset);\r\n },\r\n\r\n update: (function() {\r\n var eye = vec3.create();\r\n var worldTrans = vec3.create();\r\n var tmpVec = vec3.create();\r\n\r\n var tmpMat = mat4.create();\r\n\r\n return function() {\r\n if (!this._attachedNode) return;\r\n\r\n var ttype = this.getTransformType(this._attachedNode);\r\n this.setReferenceFrame(ttype);\r\n this.setCullingActive(ttype === TransformEnums.RELATIVE_RF);\r\n var worldMat = this.getAttachedNodeWorldMatrix();\r\n\r\n // world trans\r\n mat4.getTranslation(worldTrans, worldMat);\r\n\r\n // normalize gizmo size\r\n var scaleFactor = 3.0;\r\n if (ttype === TransformEnums.ABSOLUTE_RF) {\r\n eye[0] = eye[1] = eye[2] = 0.0;\r\n } else {\r\n // normalize gizmo size relative to screen size\r\n var proj = this._viewer.getCamera().getProjectionMatrix();\r\n var scaleFov = this._canvas.clientWidth * 0.023 * proj[0];\r\n this._viewer.getManipulator().getEyePosition(eye);\r\n // while we are editing we don't normalize the gizmo\r\n // it gives a better depth feedback, especially if we are editing a geometry that has\r\n // a constant screen size (for example an icon)\r\n this._lastDistToEye = this._isEditing\r\n ? this._lastDistToEye\r\n : vec3.distance(worldTrans, eye);\r\n scaleFactor *= this._lastDistToEye / scaleFov;\r\n }\r\n\r\n // set the position of gizmo\r\n var gizmoMatrix = this.getMatrix();\r\n mat4.fromTranslation(gizmoMatrix, worldTrans);\r\n\r\n // set scale of gizmo\r\n vec3.set(tmpVec, scaleFactor, scaleFactor, scaleFactor);\r\n mat4.mul(gizmoMatrix, gizmoMatrix, mat4.fromScaling(tmpMat, tmpVec));\r\n\r\n vec3.sub(eye, eye, worldTrans);\r\n vec3.normalize(eye, eye);\r\n\r\n // rotate node\r\n if (this._rotateInLocal || this._translateInLocal) {\r\n // world scale\r\n mat4.getScale(tmpVec, worldMat);\r\n var invScale = mat4.fromScaling(tmpMat, tmpVec);\r\n mat4.invert(invScale, invScale);\r\n\r\n var worldRot = mat4.mul(worldMat, worldMat, invScale);\r\n worldRot[12] = worldRot[13] = worldRot[14] = 0.0;\r\n\r\n if (this._translateInLocal) {\r\n mat4.copy(this._translateNode.getMatrix(), worldRot);\r\n mat4.copy(this._planeNode.getMatrix(), worldRot);\r\n }\r\n\r\n if (this._rotateInLocal) {\r\n mat4.copy(this._rotateNode.getMatrix(), worldRot);\r\n mat4.invert(worldRot, worldRot);\r\n vec3.transformMat4(eye, eye, worldRot);\r\n }\r\n } else {\r\n mat4.identity(this._rotateNode.getMatrix());\r\n }\r\n\r\n this.updateArcRotation(eye);\r\n this._rotateNode.dirtyBound();\r\n this._translateNode.dirtyBound();\r\n this._planeNode.dirtyBound();\r\n\r\n if (this._isEditing) {\r\n mat4.copy(this._showAngle.getMatrix(), this._hoverNode.getMatrix());\r\n }\r\n };\r\n })(),\r\n\r\n computeNearestIntersection: (function() {\r\n var sortByRatio = function(a, b) {\r\n return a._ratio - b._ratio;\r\n };\r\n\r\n return function(e, tmask) {\r\n // canvas to webgl coord\r\n var viewer = this._viewer;\r\n var canvas = this._canvas;\r\n var x = e.canvasX * (viewer._canvasWidth / canvas.clientWidth);\r\n var y =\r\n (canvas.clientHeight - e.canvasY) *\r\n (viewer._canvasHeight / canvas.clientHeight);\r\n\r\n var hits = this._viewer.computeIntersections(x, y, tmask);\r\n\r\n if (hits.length === 0) return undefined;\r\n\r\n hits.sort(sortByRatio);\r\n return hits[0];\r\n };\r\n })(),\r\n\r\n setOnlyGizmoPicking: function() {\r\n // enable picking only for the gizmo\r\n this._viewer.getCamera().addChild(this);\r\n this._viewer.getSceneData().setNodeMask(0x0);\r\n this.setNodeMask(~0x0);\r\n },\r\n\r\n setOnlyScenePicking: function() {\r\n this._viewer.getCamera().removeChild(this);\r\n this._viewer.getSceneData().setNodeMask(~0x0);\r\n this.setNodeMask(NodeGizmo.NO_PICK);\r\n },\r\n\r\n pickGizmo: function(e, tmask) {\r\n this.setOnlyGizmoPicking();\r\n var hit = this.computeNearestIntersection(e, tmask);\r\n this.setOnlyScenePicking();\r\n return hit;\r\n },\r\n\r\n getCanvasPositionFromWorldPoint: (function() {\r\n var mat = mat4.create();\r\n\r\n return function(worldPoint, out) {\r\n var cam = this._viewer.getCamera();\r\n\r\n var screenPoint = out;\r\n\r\n if (cam.getViewport()) {\r\n cam.getViewport().computeWindowMatrix(mat);\r\n } else {\r\n mat4.identity(mat);\r\n }\r\n\r\n mat4.mul(mat, mat, cam.getProjectionMatrix());\r\n if (this.getReferenceFrame() === TransformEnums.RELATIVE_RF)\r\n mat4.mul(mat, mat, cam.getViewMatrix());\r\n\r\n vec3.transformMat4(screenPoint, worldPoint, mat);\r\n\r\n // canvas to webgl coord\r\n var viewer = this._viewer;\r\n var canvas = this._canvas;\r\n screenPoint[0] = screenPoint[0] / (viewer._canvasWidth / canvas.clientWidth);\r\n screenPoint[1] =\r\n canvas.clientHeight -\r\n screenPoint[1] / (viewer._canvasHeight / canvas.clientHeight);\r\n return screenPoint;\r\n };\r\n })(),\r\n\r\n onMouseDown: function(e) {\r\n vec2.set(this._downCanvasCoord, e.canvasX, e.canvasY);\r\n if (!this._hoverNode || !this._attachedNode) return;\r\n\r\n this._viewer.setEnableManipulator(false);\r\n\r\n this.saveEditMatrices();\r\n var nm = this._hoverNode.getParents()[0].getNodeMask();\r\n this._isEditing = true;\r\n\r\n if (nm & NodeGizmo.PICK_ARC) {\r\n this._translateNode.setNodeMask(0x0);\r\n this._planeNode.setNodeMask(0x0);\r\n this.startRotateEdit(e);\r\n } else if (nm & NodeGizmo.PICK_ARROW) {\r\n this._rotateNode.setNodeMask(0x0);\r\n this._planeNode.setNodeMask(0x0);\r\n this.startTranslateEdit(e);\r\n } else if (nm & NodeGizmo.PICK_PLANE) {\r\n this._rotateNode.setNodeMask(0x0);\r\n this._translateNode.setNodeMask(0x0);\r\n this.startPlaneEdit(e);\r\n }\r\n },\r\n\r\n saveEditMatrices: function() {\r\n mat4.copy(this._editLocal, this._attachedNode.getMatrix());\r\n // save the world translation\r\n var wm = this.getAttachedNodeWorldMatrix();\r\n mat4.fromTranslation(this._editWorldTrans, vec3.fromValues(wm[12], wm[13], wm[14]));\r\n // save the inv of world rotation + scale\r\n mat4.copy(this._editWorldScaleRot, wm);\r\n // removes translation\r\n this._editWorldScaleRot[12] = this._editWorldScaleRot[13] = this._editWorldScaleRot[14] = 0.0;\r\n mat4.invert(this._editInvWorldScaleRot, this._editWorldScaleRot);\r\n },\r\n\r\n startRotateEdit: function(e) {\r\n var gizmoMat = this._rotateNode.getWorldMatrix(undefined, _TMP_MAT);\r\n\r\n // center of gizmo on screen\r\n var projCenter = vec3.create();\r\n vec3.transformMat4(projCenter, projCenter, gizmoMat);\r\n this.getCanvasPositionFromWorldPoint(projCenter, projCenter);\r\n\r\n // pick rotate gizmo\r\n var hit = this.pickGizmo(e, this._hoverNode.getNodeMask() | NodeGizmo.PICK_ARC);\r\n if (!hit) return;\r\n\r\n // compute tangent direction\r\n var sign = this._hoverNode._nbAxis === 0 ? -1.0 : 1.0;\r\n var tang = vec3.create();\r\n\r\n tang[0] = sign * hit._localIntersectionPoint[1];\r\n tang[1] = -sign * hit._localIntersectionPoint[0];\r\n tang[2] = hit._localIntersectionPoint[2];\r\n\r\n // project tangent on screen\r\n var projArc = vec3.create();\r\n vec3.transformMat4(projArc, tang, this._hoverNode.getMatrix());\r\n vec3.transformMat4(projArc, projArc, gizmoMat);\r\n this.getCanvasPositionFromWorldPoint(projArc, projArc);\r\n\r\n var dir = this._editLineDirection;\r\n vec2.sub(dir, projArc, projCenter);\r\n vec2.normalize(dir, dir);\r\n\r\n // show angle\r\n this._showAngle.setNodeMask(NodeGizmo.NO_PICK);\r\n hit._localIntersectionPoint[2] = 0.0;\r\n var stateAngle = this._showAngle.getStateSet();\r\n stateAngle.getUniform('uAngle').setFloat(0.0);\r\n stateAngle\r\n .getUniform('uBase')\r\n .setVec3(vec3.normalize(hit._localIntersectionPoint, hit._localIntersectionPoint));\r\n\r\n this._editLineOrigin[0] = e.canvasX;\r\n this._editLineOrigin[1] = e.canvasY;\r\n },\r\n\r\n startTranslateEdit: function(e) {\r\n var origin = this._editLineOrigin;\r\n var dir = this._editLineDirection;\r\n\r\n // 3d origin (center of gizmo)\r\n var gizmoMat = this._translateNode.getWorldMatrix(undefined, _TMP_MAT);\r\n mat4.getTranslation(origin, gizmoMat);\r\n\r\n // 3d direction\r\n vec3.init(dir);\r\n dir[this._hoverNode._nbAxis] = 1.0;\r\n if (this._translateInLocal) {\r\n vec3.transformMat4(dir, dir, this._editWorldScaleRot);\r\n vec3.normalize(dir, dir);\r\n }\r\n vec3.add(dir, origin, dir);\r\n\r\n // project on canvas\r\n this.getCanvasPositionFromWorldPoint(origin, origin);\r\n this.getCanvasPositionFromWorldPoint(dir, dir);\r\n\r\n vec2.sub(dir, dir, origin);\r\n vec2.normalize(dir, dir);\r\n\r\n var offset = this._editOffset;\r\n vec2.set(offset, e.canvasX, e.canvasY);\r\n vec2.sub(offset, offset, origin);\r\n },\r\n\r\n startPlaneEdit: function(e) {\r\n var origin = this._editLineOrigin; // just used to determine the 2d offset\r\n\r\n // 3d origin (center of gizmo)\r\n var gizmoMat = this._planeNode.getWorldMatrix(undefined, _TMP_MAT);\r\n mat4.getTranslation(origin, gizmoMat);\r\n\r\n // project on canvas\r\n this.getCanvasPositionFromWorldPoint(origin, origin);\r\n\r\n var offset = this._editOffset;\r\n vec2.set(offset, e.canvasX, e.canvasY);\r\n vec2.sub(offset, offset, origin);\r\n },\r\n\r\n drawLineCanvasDebug: function(x1, y1, x2, y2) {\r\n this._debugNode.setNodeMask(NodeGizmo.NO_PICK);\r\n var buffer = this._debugNode.getChildren()[0].getAttributes().Vertex;\r\n buffer.getElements()[0] = x1 / this._canvas.clientWidth * 2 - 1.0;\r\n buffer.getElements()[1] =\r\n (this._canvas.clientHeight - y1) / this._canvas.clientHeight * 2 - 1.0;\r\n buffer.getElements()[2] = x2 / this._canvas.clientWidth * 2 - 1.0;\r\n buffer.getElements()[3] =\r\n (this._canvas.clientHeight - y2) / this._canvas.clientHeight * 2 - 1.0;\r\n buffer.dirty();\r\n },\r\n\r\n pickAndSelect: function(e) {\r\n this.setNodeMask(0x0);\r\n var hit = this.computeNearestIntersection(e, this._tmask);\r\n this.attachToNodePath(hit ? hit._nodePath : hit);\r\n },\r\n\r\n onMouseUp: function(e) {\r\n this._viewer.setEnableManipulator(true);\r\n if (this._debugNode) this._debugNode.setNodeMask(0x0);\r\n\r\n var v = vec2.fromValues(e.canvasX, e.canvasY);\r\n\r\n if (vec2.distance(v, this._downCanvasCoord) === 0.0) this.pickAndSelect(e);\r\n\r\n this._showAngle.setNodeMask(0x0);\r\n this._isEditing = false;\r\n if (!this._hoverNode) return;\r\n this.updateGizmoMask();\r\n },\r\n\r\n onMouseMove: function(e) {\r\n if (!this._attachedNode) return;\r\n var hit;\r\n if (this._isEditing === false) {\r\n hit = this.pickGizmo(e, NodeGizmo.PICK_GIZMO);\r\n this.onNodeHovered(hit);\r\n return;\r\n }\r\n\r\n if (!this._hoverNode) return;\r\n\r\n var par = this._hoverNode.getParents()[0];\r\n if (par === this._rotateNode) this.updateRotateEdit(e);\r\n else if (par === this._translateNode) this.updateTranslateEdit(e);\r\n else if (par === this._planeNode) this.updatePlaneEdit(e);\r\n },\r\n\r\n updateRotateEdit: (function() {\r\n var mrot = mat4.create();\r\n var vec = vec2.create();\r\n var vecX = vec3.fromValues(1.0, 0.0, 0.0);\r\n var vecY = vec3.fromValues(0.0, 1.0, 0.0);\r\n var vecZ = vec3.fromValues(0.0, 0.0, 1.0);\r\n var negatePivot = vec3.create();\r\n\r\n return function(e) {\r\n var origin = this._editLineOrigin;\r\n var dir = this._editLineDirection;\r\n\r\n vec2.set(vec, e.canvasX, e.canvasY);\r\n vec2.sub(vec, vec, origin);\r\n var dist = vec2.dot(vec, dir);\r\n\r\n if (this._debugNode) {\r\n var ox = origin[0];\r\n var oy = origin[1];\r\n this.drawLineCanvasDebug(ox, oy, ox + dir[0] * dist, oy + dir[1] * dist);\r\n }\r\n\r\n var minClient = Math.min(this._canvas.clientWidth, this._canvas.clientHeight);\r\n var angle = 7 * dist / minClient;\r\n angle %= Math.PI * 2;\r\n\r\n var nbAxis = this._hoverNode._nbAxis;\r\n if (nbAxis === 0) mat4.fromRotation(mrot, -angle, vecX);\r\n else if (nbAxis === 1) mat4.fromRotation(mrot, -angle, vecY);\r\n else if (nbAxis === 2) mat4.fromRotation(mrot, -angle, vecZ);\r\n\r\n var uAngle = this._showAngle.getOrCreateStateSet().getUniform('uAngle');\r\n uAngle.setFloat(nbAxis === 0 ? -angle : angle);\r\n\r\n if (!this._rotateInLocal) {\r\n mat4.mul(mrot, this._editInvWorldScaleRot, mrot);\r\n mat4.mul(mrot, mrot, this._editWorldScaleRot);\r\n }\r\n\r\n // rotate around origin pivot (geometry center)\r\n // the classic rotation around pivot : -T * R * T\r\n var attMat = this._attachedNode.getMatrix();\r\n mat4.translate(attMat, this._editLocal, this._pivotOffset);\r\n mat4.mul(attMat, attMat, mrot);\r\n mat4.translate(attMat, attMat, vec3.negate(negatePivot, this._pivotOffset));\r\n\r\n this._attachedNode.dirtyBound();\r\n };\r\n })(),\r\n\r\n updateTranslateEdit: (function() {\r\n var vec = vec2.create();\r\n var tra = vec3.create();\r\n\r\n return function(e) {\r\n var origin = this._editLineOrigin;\r\n var dir = this._editLineDirection;\r\n\r\n vec2.set(vec, e.canvasX, e.canvasY);\r\n vec2.sub(vec, vec, origin);\r\n vec2.sub(vec, vec, this._editOffset);\r\n\r\n var dist = vec2.dot(vec, dir);\r\n vec[0] = origin[0] + dir[0] * dist;\r\n vec[1] = origin[1] + dir[1] * dist;\r\n\r\n if (this._debugNode) this.drawLineCanvasDebug(origin[0], origin[1], vec[0], vec[1]);\r\n\r\n // canvas to webgl coord\r\n var viewer = this._viewer;\r\n var canvas = this._canvas;\r\n var coordx = vec[0] * (viewer._canvasWidth / canvas.clientWidth);\r\n var coordy =\r\n (canvas.clientHeight - vec[1]) * (viewer._canvasHeight / canvas.clientHeight);\r\n\r\n // project 2D point on the 3d line\r\n this._lsi.reset();\r\n this._lsi.setTestPlane(false);\r\n this._lsi.set(\r\n vec3.set(this._origIntersect, coordx, coordy, 0.0),\r\n vec3.set(this._dstIntersect, coordx, coordy, 1.0)\r\n );\r\n this._iv.reset();\r\n this._iv.setTraversalMask(this._hoverNode.getNodeMask());\r\n\r\n mat4.copy(this.getMatrix(), this._editWorldTrans);\r\n\r\n this.setOnlyGizmoPicking();\r\n this._viewer._camera.accept(this._iv);\r\n this.setOnlyScenePicking();\r\n\r\n if (!this._translateInLocal) {\r\n vec3.transformMat4(\r\n tra,\r\n this._lsi.getTranslateDistance(),\r\n this._editInvWorldScaleRot\r\n );\r\n } else {\r\n mat4.getScale(tra, this._editInvWorldScaleRot);\r\n\r\n var inter = this._lsi.getTranslateDistance();\r\n vec3.mul(tra, tra, inter);\r\n }\r\n\r\n mat4.translate(this._attachedNode.getMatrix(), this._editLocal, tra);\r\n\r\n this._attachedNode.dirtyBound();\r\n };\r\n })(),\r\n\r\n updatePlaneEdit: (function() {\r\n var vec = vec2.create();\r\n var tra = vec3.create();\r\n\r\n return function(e) {\r\n vec2.set(vec, e.canvasX, e.canvasY);\r\n vec2.sub(vec, vec, this._editOffset);\r\n\r\n // canvas to webgl coord\r\n var viewer = this._viewer;\r\n var canvas = this._canvas;\r\n var coordx = vec[0] * (viewer._canvasWidth / canvas.clientWidth);\r\n var coordy =\r\n (canvas.clientHeight - vec[1]) * (viewer._canvasHeight / canvas.clientHeight);\r\n\r\n // project 2D point on the 3d plane\r\n this._lsi.reset();\r\n this._lsi.setTestPlane(true);\r\n this._lsi.set(\r\n vec3.set(this._origIntersect, coordx, coordy, 0.0),\r\n vec3.set(this._dstIntersect, coordx, coordy, 1.0)\r\n );\r\n this._iv.reset();\r\n this._iv.setTraversalMask(this._hoverNode.getNodeMask());\r\n\r\n mat4.copy(this.getMatrix(), this._editWorldTrans);\r\n\r\n this.setOnlyGizmoPicking();\r\n this._viewer._camera.accept(this._iv);\r\n this.setOnlyScenePicking();\r\n\r\n if (!this._translateInLocal) {\r\n vec3.transformMat4(\r\n tra,\r\n this._lsi.getTranslateDistance(),\r\n this._editInvWorldScaleRot\r\n );\r\n } else {\r\n mat4.getScale(tra, this._editInvWorldScaleRot);\r\n var inter = this._lsi.getTranslateDistance();\r\n vec3.mul(tra, tra, inter);\r\n }\r\n\r\n mat4.translate(this._attachedNode.getMatrix(), this._editLocal, tra);\r\n\r\n this._attachedNode.dirtyBound();\r\n };\r\n })()\r\n }),\r\n 'osgUtil',\r\n 'NodeGizmo'\r\n);\r\n\r\nexport default NodeGizmo;\r\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Plane from '../osg/Plane';\r\nimport IntersectFunctor from '../osgUtil/IntersectFunctor';\r\n\r\nvar PolytopeIntersection = function() {\r\n IntersectFunctor.Intersection.call(this);\r\n\r\n this._intersectionPoints = [];\r\n this._distance = 0;\r\n this._maxDistance = 0;\r\n this._numIntersectionPoints = 0;\r\n};\r\n\r\n// Settings are needed.\r\nvar PolytopeIntersectFunctor = function() {\r\n IntersectFunctor.call(this);\r\n\r\n this._src = [];\r\n this._dest = [];\r\n this._maxNumIntersectionsPoints = 6;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n PolytopeIntersectFunctor,\r\n utils.objectInherit(IntersectFunctor.prototype, {\r\n reset: function() {\r\n IntersectFunctor.prototype.reset.call(this);\r\n this._src = [];\r\n this._dest = [];\r\n },\r\n\r\n enter: function(bbox) {\r\n if (this._intersector.getPolytope().containsBoundingBox(bbox)) {\r\n this._intersector.getPolytope().pushCurrentMask();\r\n return true;\r\n }\r\n return false;\r\n },\r\n\r\n leave: function() {\r\n this._intersector.getPolytope().popCurrentMask();\r\n },\r\n\r\n addIntersection: function() {\r\n this._src = utils.arrayUniq(this._src);\r\n var src = this._src;\r\n\r\n var center = vec3.create();\r\n var maxDistance = -Number.MAX_VALUE;\r\n var referencePlane = this._intersector._iReferencePlane;\r\n for (var i = 0; i < src.length; ++i) {\r\n vec3.add(center, center, src[i]);\r\n var d = Plane.distanceToPlane(referencePlane, src[i]);\r\n if (d > maxDistance) maxDistance = d;\r\n }\r\n\r\n vec3.scale(center, center, 1.0 / src.length);\r\n\r\n var intersection = this.initIntersection(new PolytopeIntersection());\r\n intersection._distance = Plane.distanceToPlane(referencePlane, center);\r\n intersection._maxDistance = maxDistance;\r\n vec3.copy(intersection._localIntersectionPoint, center);\r\n\r\n var maxNum = this._maxNumIntersectionsPoints;\r\n intersection._numIntersectionPoints = src.length < maxNum ? src.length : maxNum;\r\n\r\n for (i = 0; i < intersection._numIntersectionPoints; ++i) {\r\n intersection._intersectionPoints.push(vec3.clone(this._src[i]));\r\n }\r\n },\r\n\r\n contains: function() {\r\n var polytope = this._intersector.getPolytope();\r\n var planeList = polytope.getPlanes();\r\n\r\n var resultMask = polytope.getCurrentMask();\r\n if (!resultMask) return true;\r\n\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < planeList.length; ++i) {\r\n if (resultMask & (selectorMask === 0)) {\r\n selectorMask <<= 1;\r\n continue;\r\n }\r\n\r\n this._dest = [];\r\n var plane = planeList[i];\r\n var vPrevious = this._src[0];\r\n var dPrevious = Plane.distanceToPlane(plane, vPrevious);\r\n for (var j = 1; j < this._src.length; ++j) {\r\n var vCurrent = this._src[j];\r\n var dCurrent = Plane.distanceToPlane(plane, vCurrent);\r\n if (dPrevious >= 0.0) {\r\n this._dest.push(vec3.clone(vPrevious));\r\n }\r\n if (dPrevious * dCurrent < 0.0) {\r\n var distance = dPrevious - dCurrent;\r\n var rCurrent = dPrevious / distance;\r\n //(*v_previous)*(1.0-r_current) + (*v_current)*r_current;\r\n var vnew = vec3.add(\r\n vec3.create(),\r\n vec3.scale(vec3.create(), vPrevious, 1.0 - rCurrent),\r\n vec3.scale(vec3.create(), vCurrent, rCurrent)\r\n );\r\n this._dest.push(vnew);\r\n }\r\n dPrevious = dCurrent;\r\n vPrevious = vCurrent;\r\n }\r\n if (dPrevious >= 0.0) {\r\n this._dest.push(vec3.clone(vPrevious));\r\n }\r\n if (this._dest.length <= 1) {\r\n return false;\r\n }\r\n // swap values\r\n var swap = this._src.slice();\r\n this._src = this._dest.slice();\r\n this._dest = swap;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n containsPoint: function(v0) {\r\n if (this._intersector.getPolytope().containsVertex(v0)) {\r\n // initialize the set of vertices to test.\r\n this._src = [];\r\n this._src[0] = v0;\r\n return true;\r\n }\r\n return false;\r\n },\r\n\r\n containsLine: function(v0, v1) {\r\n // initialize the set of vertices to test.\r\n this._src = [];\r\n this._src[0] = v0;\r\n this._src[1] = v1;\r\n this._src[2] = v0;\r\n return this.contains();\r\n },\r\n\r\n containsTriangle: function(v0, v1, v2) {\r\n // initialize the set of vertices to test.\r\n this._src = [];\r\n this._src[0] = v0;\r\n this._src[1] = v1;\r\n this._src[2] = v2;\r\n this._src[3] = v0;\r\n return this.contains();\r\n },\r\n\r\n intersectPoint: function(v0) {\r\n if (this.containsPoint(v0)) this.addIntersection();\r\n },\r\n\r\n intersectLine: function(v0, v1) {\r\n if (this.containsLine(v0, v1)) this.addIntersection();\r\n },\r\n\r\n intersectTriangle: function(v0, v1, v2) {\r\n if (this.containsTriangle(v0, v1, v2)) this.addIntersection();\r\n }\r\n }),\r\n 'osgUtil',\r\n 'PolytopeIntersectFunctor'\r\n);\r\n\r\nexport default PolytopeIntersectFunctor;\r\n","import utils from '../osg/utils';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Polytope from '../osg/Polytope';\r\nimport Plane from '../osg/Plane';\r\nimport Intersector from '../osgUtil/Intersector';\r\nimport PolytopeIntersectFunctor from '../osgUtil/PolytopeIntersectFunctor';\r\n\r\n/** Concrete class for implementing polytope intersections with the scene graph.\r\n * To be used in conjunction with IntersectionVisitor. */\r\nvar PolytopeIntersector = function() {\r\n Intersector.call(this);\r\n\r\n this._index = 0;\r\n // We use one for reference and other for the intersections\r\n this._polytope = new Polytope();\r\n this._iPolytope = new Polytope();\r\n this._referencePlane = vec4.create();\r\n this._iReferencePlane = vec4.create();\r\n};\r\n\r\nvar transformVec4PostMult = function(out, p, m) {\r\n var x = p[0];\r\n var y = p[1];\r\n var z = p[2];\r\n var w = p[3];\r\n\r\n out[0] = m[0] * x + m[1] * y + m[2] * z + m[3] * w;\r\n out[1] = m[4] * x + m[5] * y + m[6] * z + m[7] * w;\r\n out[2] = m[8] * x + m[9] * y + m[10] * z + m[11] * w;\r\n out[3] = m[12] * x + m[13] * y + m[14] * z + m[15] * w;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n PolytopeIntersector,\r\n utils.objectInherit(Intersector.prototype, {\r\n setPolytope: function(polytope) {\r\n this._polytope.setPlanes(polytope);\r\n var iPlanes = [];\r\n for (var i = 0; i < polytope.length; ++i) {\r\n var plane = polytope[i];\r\n iPlanes[i] = vec4.copy(this._iPolytope.getPlanes()[i] || Plane.create(), plane);\r\n }\r\n this._iPolytope.setPlanes(iPlanes);\r\n vec4.copy(this._referencePlane, polytope[polytope.length - 1]);\r\n vec4.copy(this._iReferencePlane, this._referencePlane);\r\n },\r\n\r\n getPolytope: function() {\r\n return this._iPolytope;\r\n },\r\n\r\n setPolytopeFromWindowCoordinates: function(xMin, yMin, xMax, yMax) {\r\n // Note: last polytope value depends on the Coordinate frame\r\n // Now we are only supporting WINDOW coordinate frame, so must change this if we decide to support\r\n // other types of Coordinate Frame\r\n this.setPolytope([\r\n vec4.fromValues(1.0, 0.0, 0.0, -xMin),\r\n vec4.fromValues(-1.0, 0.0, 0.0, xMax),\r\n vec4.fromValues(0.0, 1.0, 0.0, -yMin),\r\n vec4.fromValues(0.0, -1.0, 0.0, yMax),\r\n vec4.fromValues(0.0, 0.0, 1.0, 0.0)\r\n ]);\r\n },\r\n\r\n intersectBoundingBox: function(bbox) {\r\n return this._iPolytope.containsBoundingBox(bbox);\r\n },\r\n\r\n intersectBoundingSphere: function(bsphere) {\r\n return this._iPolytope.containsBoundingSphere(bsphere);\r\n },\r\n\r\n intersect: (function() {\r\n var functor = new PolytopeIntersectFunctor();\r\n\r\n return function(iv, node) {\r\n functor.setGeometry(node);\r\n functor.setIntersectionVisitor(iv);\r\n functor.setIntersector(this);\r\n\r\n var kdtree = node.getShape();\r\n if (kdtree) {\r\n kdtree.intersect(functor, kdtree.getNodes()[0]);\r\n } else {\r\n // handle rig transformed vertices\r\n if (node.computeTransformedVertices) {\r\n functor.setVertices(node.computeTransformedVertices());\r\n }\r\n\r\n functor.apply(node);\r\n }\r\n functor.reset();\r\n };\r\n })(),\r\n\r\n setCurrentTransformation: function(matrix) {\r\n // Transform the polytope and the referencePlane to the current Model local coordinate frame\r\n var planeList = this._polytope.getPlanes();\r\n var iPlaneList = this._iPolytope.getPlanes();\r\n for (var i = 0, j = planeList.length; i < j; i++) {\r\n var iplane = (iPlaneList[i] = iPlaneList[i] || vec4.create());\r\n // PostMult\r\n transformVec4PostMult(iplane, planeList[i], matrix);\r\n // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.\r\n vec4.scale(iplane, iplane, 1.0 / vec3.len(iplane));\r\n }\r\n\r\n //Post Mult\r\n transformVec4PostMult(this._iReferencePlane, this._referencePlane, matrix);\r\n\r\n // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.\r\n vec4.scale(\r\n this._iReferencePlane,\r\n this._iReferencePlane,\r\n 1.0 / vec3.len(this._iReferencePlane)\r\n );\r\n }\r\n }),\r\n 'osgUtil',\r\n 'PolytopeIntersector'\r\n);\r\n\r\nexport default PolytopeIntersector;\r\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport IntersectFunctor from './IntersectFunctor';\r\n\r\nvar SphereIntersection = function() {\r\n IntersectFunctor.Intersection.call(this);\r\n\r\n this._localIntersectionNormal = vec3.clone(vec3.ONE);\r\n\r\n // index of vertex\r\n this._i1 = -1;\r\n this._i2 = -1;\r\n this._i3 = -1;\r\n\r\n // barycentric coordinates\r\n this._r1 = 0.0;\r\n this._r2 = 0.0;\r\n this._r3 = 0.0;\r\n};\r\n\r\nvar SphereIntersectFunctor = function() {\r\n IntersectFunctor.apply(this);\r\n\r\n this._center = undefined;\r\n this._radius = 0.0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n SphereIntersectFunctor,\r\n utils.objectInherit(IntersectFunctor.prototype, {\r\n set: function(center, radius) {\r\n this._center = center;\r\n this._radius = radius;\r\n },\r\n\r\n enter: function(bbox) {\r\n // Intersection sphere box, from graphic gems 2\r\n // https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c\r\n var r2 = this._radius * this._radius;\r\n var dmin = 0;\r\n var bmin = bbox.getMin();\r\n var bmax = bbox.getMax();\r\n var d = 0;\r\n for (var i = 0; i < 3; i++) {\r\n if (this._center[i] < bmin[i]) {\r\n d = this._center[i] - bmin[i];\r\n dmin += d * d;\r\n } else if (this._center[i] > bmax[i]) {\r\n d = this._center[i] - bmax[i];\r\n dmin += d * d;\r\n }\r\n }\r\n return dmin <= r2;\r\n },\r\n\r\n intersectPoint: function(v0, i0) {\r\n var sqrDistance = vec3.sqrDist(v0, this._center);\r\n if (sqrDistance > this._radius * this._radius) return;\r\n\r\n var intersection = this.initIntersection(new SphereIntersection());\r\n intersection._i1 = i0;\r\n intersection._r1 = 1.0;\r\n vec3.copy(intersection._localIntersectionPoint, v0);\r\n intersection._ratio = Math.sqrt(sqrDistance) / this._radius;\r\n },\r\n\r\n intersectLine: (function() {\r\n var tmp = vec3.create();\r\n var dir = vec3.create();\r\n\r\n return function(v0, v1, p0, p1) {\r\n // https://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistPointSegment.h\r\n vec3.sub(tmp, this._center, v0);\r\n vec3.sub(dir, v1, v0);\r\n // compute ratio (projection on line)\r\n var r = vec3.dot(tmp, dir) / vec3.sqrLen(dir);\r\n\r\n // compute distance to segment\r\n var distToSegmentSqr = 1.0;\r\n if (r < 0.0) distToSegmentSqr = vec3.sqrLen(tmp);\r\n else if (r > 1.0) distToSegmentSqr = vec3.sqrDist(this._center, v1);\r\n else distToSegmentSqr = vec3.sqrLen(vec3.scaleAndAdd(tmp, tmp, dir, -r));\r\n\r\n if (distToSegmentSqr > this._radius * this._radius) {\r\n return;\r\n }\r\n\r\n var intersection = this.initIntersection(new SphereIntersection());\r\n intersection._i1 = p0;\r\n intersection._i2 = p1;\r\n\r\n intersection._r1 = 1.0 - r;\r\n intersection._r2 = r;\r\n\r\n vec3.scaleAndAdd(intersection._localIntersectionPoint, v0, dir, r);\r\n intersection._ratio = Math.sqrt(distToSegmentSqr) / this._radius;\r\n };\r\n })(),\r\n\r\n //\r\n // \\2|\r\n // \\|\r\n // \\\r\n // 3 |\\ 1\r\n // |0\\\r\n // __|__\\___\r\n // 4 | 5 \\ 6\r\n //\r\n // from http://www.geometrictools.com/Source/Distance3D.html#PointPlanar\r\n // js : https://github.com/stephomi/sculptgl/blob/master/src/math3d/Geometry.js#L89\r\n intersectTriangle: (function() {\r\n var edge1 = vec3.create();\r\n var edge2 = vec3.create();\r\n var diff = vec3.create();\r\n return function(v0, v1, v2, i0, i1, i2) {\r\n if (this._limitOneIntersection && this._hit) return;\r\n // sphere is a 'volume' here (so if the triangle is inside the ball it will intersects)\r\n\r\n vec3.sub(edge1, v1, v0);\r\n vec3.sub(edge2, v2, v0);\r\n var a00 = vec3.sqrLen(edge1);\r\n var a01 = vec3.dot(edge1, edge2);\r\n var a11 = vec3.sqrLen(edge2);\r\n\r\n vec3.sub(diff, v0, this._center);\r\n var b0 = vec3.dot(diff, edge1);\r\n var b1 = vec3.dot(diff, edge2);\r\n var c = vec3.sqrLen(diff);\r\n var det = Math.abs(a00 * a11 - a01 * a01);\r\n if (det < 1e-10) return;\r\n\r\n var s = a01 * b1 - a11 * b0;\r\n var t = a01 * b0 - a00 * b1;\r\n var sqrDistance;\r\n var zone = 4;\r\n\r\n if (s + t <= det) {\r\n if (s < 0.0) {\r\n if (t < 0.0) {\r\n // region 4\r\n zone = 4;\r\n if (b0 < 0.0) {\r\n t = 0.0;\r\n if (-b0 >= a00) {\r\n s = 1.0;\r\n sqrDistance = a00 + 2.0 * b0 + c;\r\n } else {\r\n s = -b0 / a00;\r\n sqrDistance = b0 * s + c;\r\n }\r\n } else {\r\n s = 0.0;\r\n if (b1 >= 0.0) {\r\n t = 0.0;\r\n sqrDistance = c;\r\n } else if (-b1 >= a11) {\r\n t = 1.0;\r\n sqrDistance = a11 + 2.0 * b1 + c;\r\n } else {\r\n t = -b1 / a11;\r\n sqrDistance = b1 * t + c;\r\n }\r\n }\r\n } else {\r\n // region 3\r\n zone = 3;\r\n s = 0.0;\r\n if (b1 >= 0.0) {\r\n t = 0.0;\r\n sqrDistance = c;\r\n } else if (-b1 >= a11) {\r\n t = 1.0;\r\n sqrDistance = a11 + 2.0 * b1 + c;\r\n } else {\r\n t = -b1 / a11;\r\n sqrDistance = b1 * t + c;\r\n }\r\n }\r\n } else if (t < 0.0) {\r\n // region 5\r\n zone = 5;\r\n t = 0.0;\r\n if (b0 >= 0.0) {\r\n s = 0.0;\r\n sqrDistance = c;\r\n } else if (-b0 >= a00) {\r\n s = 1.0;\r\n sqrDistance = a00 + 2.0 * b0 + c;\r\n } else {\r\n s = -b0 / a00;\r\n sqrDistance = b0 * s + c;\r\n }\r\n } else {\r\n // region 0\r\n zone = 0;\r\n // minimum at interior point\r\n var invDet = 1.0 / det;\r\n s *= invDet;\r\n t *= invDet;\r\n sqrDistance =\r\n s * (a00 * s + a01 * t + 2.0 * b0) +\r\n t * (a01 * s + a11 * t + 2.0 * b1) +\r\n c;\r\n }\r\n } else {\r\n var tmp0, tmp1, numer, denom;\r\n\r\n if (s < 0.0) {\r\n // region 2\r\n zone = 2;\r\n tmp0 = a01 + b0;\r\n tmp1 = a11 + b1;\r\n if (tmp1 > tmp0) {\r\n numer = tmp1 - tmp0;\r\n denom = a00 - 2.0 * a01 + a11;\r\n if (numer >= denom) {\r\n s = 1.0;\r\n t = 0.0;\r\n sqrDistance = a00 + 2.0 * b0 + c;\r\n } else {\r\n s = numer / denom;\r\n t = 1.0 - s;\r\n sqrDistance =\r\n s * (a00 * s + a01 * t + 2.0 * b0) +\r\n t * (a01 * s + a11 * t + 2.0 * b1) +\r\n c;\r\n }\r\n } else {\r\n s = 0.0;\r\n if (tmp1 <= 0.0) {\r\n t = 1.0;\r\n sqrDistance = a11 + 2.0 * b1 + c;\r\n } else if (b1 >= 0.0) {\r\n t = 0.0;\r\n sqrDistance = c;\r\n } else {\r\n t = -b1 / a11;\r\n sqrDistance = b1 * t + c;\r\n }\r\n }\r\n } else if (t < 0.0) {\r\n // region 6\r\n zone = 6;\r\n tmp0 = a01 + b1;\r\n tmp1 = a00 + b0;\r\n if (tmp1 > tmp0) {\r\n numer = tmp1 - tmp0;\r\n denom = a00 - 2.0 * a01 + a11;\r\n if (numer >= denom) {\r\n t = 1.0;\r\n s = 0.0;\r\n sqrDistance = a11 + 2.0 * b1 + c;\r\n } else {\r\n t = numer / denom;\r\n s = 1.0 - t;\r\n sqrDistance =\r\n s * (a00 * s + a01 * t + 2.0 * b0) +\r\n t * (a01 * s + a11 * t + 2.0 * b1) +\r\n c;\r\n }\r\n } else {\r\n t = 0.0;\r\n if (tmp1 <= 0.0) {\r\n s = 1.0;\r\n sqrDistance = a00 + 2.0 * b0 + c;\r\n } else if (b0 >= 0.0) {\r\n s = 0.0;\r\n sqrDistance = c;\r\n } else {\r\n s = -b0 / a00;\r\n sqrDistance = b0 * s + c;\r\n }\r\n }\r\n } else {\r\n // region 1\r\n zone = 1;\r\n numer = a11 + b1 - a01 - b0;\r\n if (numer <= 0.0) {\r\n s = 0.0;\r\n t = 1.0;\r\n sqrDistance = a11 + 2.0 * b1 + c;\r\n } else {\r\n denom = a00 - 2.0 * a01 + a11;\r\n if (numer >= denom) {\r\n s = 1.0;\r\n t = 0.0;\r\n sqrDistance = a00 + 2.0 * b0 + c;\r\n } else {\r\n s = numer / denom;\r\n t = 1.0 - s;\r\n sqrDistance =\r\n s * (a00 * s + a01 * t + 2.0 * b0) +\r\n t * (a01 * s + a11 * t + 2.0 * b1) +\r\n c;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (sqrDistance > this._radius * this._radius) return;\r\n\r\n var normal = vec3.create();\r\n\r\n var intersection = this.initIntersection(new SphereIntersection());\r\n intersection._i1 = i0;\r\n intersection._i2 = i1;\r\n intersection._i3 = i2;\r\n\r\n intersection._r1 = 1 - s - t;\r\n intersection._r2 = s;\r\n intersection._r3 = t;\r\n\r\n // inter = v0 + edge1 * s + edge2 * t\r\n var inter = intersection._localIntersectionPoint;\r\n vec3.scaleAndAdd(inter, vec3.scaleAndAdd(inter, v0, edge1, s), edge2, t);\r\n\r\n // normal\r\n vec3.cross(intersection._localIntersectionNormal, edge1, edge2);\r\n vec3.normalize(normal, intersection._localIntersectionNormal);\r\n\r\n intersection._ratio = Math.sqrt(sqrDistance) / this._radius;\r\n intersection._zone = zone;\r\n };\r\n })()\r\n }),\r\n 'osgUtil',\r\n 'SphereIntersectFunctor'\r\n);\r\n\r\nexport default SphereIntersectFunctor;","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Intersector from './Intersector';\r\nimport SphereIntersectFunctor from './SphereIntersectFunctor';\r\n\r\nvar SphereIntersector = function() {\r\n Intersector.call(this);\r\n\r\n this._center = vec3.create();\r\n this._iCenter = vec3.create();\r\n this._radius = 1.0;\r\n this._iRadius = 1.0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n SphereIntersector,\r\n utils.objectInherit(Intersector.prototype, {\r\n set: function(center, radius) {\r\n // we copy iCenter and iRadius in case setCurrentTransformation is never called\r\n vec3.copy(this._center, center);\r\n vec3.copy(this._iCenter, center);\r\n this._radius = this._iRadius = radius;\r\n this.reset();\r\n },\r\n\r\n setCenter: function(center) {\r\n vec3.copy(this._center, center);\r\n vec3.copy(this._iCenter, center);\r\n },\r\n\r\n setRadius: function(radius) {\r\n this._radius = this._iRadius = radius;\r\n },\r\n\r\n intersectNode: function(node) {\r\n // TODO implement intersectBoundingBox?\r\n return this.intersectBoundingSphere(node.getBoundingSphere());\r\n },\r\n\r\n intersectBoundingSphere: function(bsphere) {\r\n if (!bsphere.valid()) return false;\r\n var r = this._iRadius + bsphere.radius();\r\n return vec3.sqrDist(bsphere.center(), this._iCenter) <= r * r;\r\n },\r\n\r\n intersect: (function() {\r\n var functor = new SphereIntersectFunctor();\r\n\r\n return function(iv, node) {\r\n functor.setGeometry(node);\r\n functor.setIntersectionVisitor(iv);\r\n functor.setIntersector(this);\r\n\r\n functor.set(this._iCenter, this._iRadius);\r\n\r\n var kdtree = node.getShape();\r\n if (kdtree) {\r\n kdtree.intersect(functor, kdtree.getNodes()[0]);\r\n } else {\r\n // handle rig transformed vertices\r\n if (node.computeTransformedVertices) {\r\n functor.setVertices(node.computeTransformedVertices());\r\n }\r\n\r\n functor.apply(node);\r\n }\r\n\r\n functor.reset();\r\n };\r\n })(),\r\n\r\n setCurrentTransformation: (function() {\r\n var tmp = vec3.create();\r\n\r\n return function(matrix) {\r\n mat4.invert(matrix, matrix);\r\n vec3.transformMat4(this._iCenter, this._center, matrix);\r\n // Only handling analitically uniform scales.\r\n // For non uniform we use an approximation to avoid complexity\r\n mat4.getScale(tmp, matrix);\r\n var x = tmp[0];\r\n var y = tmp[1];\r\n var z = tmp[2];\r\n var maxScale = x > y ? (x > z ? x : z) : y > z ? y : z;\r\n this._iRadius = this._radius * maxScale;\r\n };\r\n })()\r\n }),\r\n 'osgUtil',\r\n 'SphereIntersector'\r\n);\r\n\r\nexport default SphereIntersector;","import utils from '../osg/utils';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport Geometry from '../osg/Geometry';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport { vec3 } from '../osg/glMatrix';\r\n\r\nvar TangentSpaceGenerator = function() {\r\n NodeVisitor.call(this);\r\n this._T = undefined;\r\n this._B = undefined;\r\n this._N = undefined;\r\n this._texCoordUnit = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n TangentSpaceGenerator,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getTypeID() === Geometry.getTypeID()) this.generate(node, this._texCoordUnit);\r\n else this.traverse(node);\r\n },\r\n\r\n setTexCoordUnit: function(texCoordUnit) {\r\n this._texCoordUnit = texCoordUnit;\r\n },\r\n\r\n computePrimitiveSet: function(geometry, primitive) {\r\n // no indices -> exit\r\n if (!primitive.getIndices) return;\r\n\r\n var numIndices = primitive.getNumIndices();\r\n\r\n var vx = geometry.getAttributes().Vertex;\r\n var nx = geometry.getAttributes().Normal;\r\n var tx = geometry.getAttributes()['TexCoord' + this._texCoordUnit];\r\n\r\n var i;\r\n\r\n if (primitive.getMode() === primitiveSet.TRIANGLES) {\r\n for (i = 0; i < numIndices; i += 3) {\r\n this.compute(primitive, vx, nx, tx, i, i + 1, i + 2);\r\n }\r\n } else if (primitive.getMode() === primitiveSet.TRIANGLE_STRIP) {\r\n for (i = 0; i < numIndices - 2; ++i) {\r\n if (i % 2 === 0) {\r\n this.compute(primitive, vx, nx, tx, i, i + 1, i + 2);\r\n } else {\r\n this.compute(primitive, vx, nx, tx, i + 1, i, i + 2);\r\n }\r\n }\r\n }\r\n },\r\n\r\n generate: function(geometry, texCoordUnit) {\r\n this._texCoordUnit = texCoordUnit;\r\n\r\n if (this._texCoordUnit === undefined) this._texCoordUnit = 0;\r\n if (!geometry.getAttributes()['TexCoord' + this._texCoordUnit]) return;\r\n\r\n var size = geometry.getAttributes().Vertex.getElements().length;\r\n this._T = new utils.Float32Array(size);\r\n this._B = new utils.Float32Array(size);\r\n this._N = new utils.Float32Array(size);\r\n\r\n geometry.getPrimitiveSetList().forEach(function(primitive) {\r\n this.computePrimitiveSet(geometry, primitive);\r\n }, this);\r\n\r\n var nbElements = size / 3;\r\n var tangents = new utils.Float32Array(nbElements * 4);\r\n\r\n var tmp0 = vec3.create();\r\n var tmp1 = vec3.create();\r\n var t3 = vec3.create();\r\n\r\n for (var i = 0; i < nbElements; i++) {\r\n var t = this._T.subarray(i * 3, i * 3 + 3);\r\n var n = this._N.subarray(i * 3, i * 3 + 3);\r\n var b = this._B.subarray(i * 3, i * 3 + 3);\r\n\r\n vec3.normalize(n, n);\r\n\r\n // Gram-Schmidt orthogonalize\r\n // vec3 t3 = (t - n * (n * t));\r\n // t3.normalize();\r\n // finalTangent = Vec4(t3, 0.0);\r\n // Calculate handedness\r\n // finalTangent[3] = (((n ^ t) * b) < 0.0) ? -1.0 : 1.0;\r\n // The bitangent vector B is then given by B = (N × T) · Tw\r\n\r\n var nt = vec3.dot(n, t);\r\n vec3.scale(tmp1, n, nt);\r\n vec3.sub(tmp0, t, tmp1);\r\n vec3.normalize(t3, tmp0);\r\n\r\n vec3.cross(tmp0, n, t);\r\n var sign = vec3.dot(tmp0, b);\r\n sign = sign < 0.0 ? -1.0 : 0.0;\r\n\r\n // TODO perf : cache index var id = i * 4;\r\n tangents[i * 4] = t3[0];\r\n tangents[i * 4 + 1] = t3[1];\r\n tangents[i * 4 + 2] = t3[2];\r\n tangents[i * 4 + 3] = sign;\r\n }\r\n\r\n geometry.getAttributes().Normal.setElements(this._N);\r\n geometry.getAttributes().Tangent = new BufferArray('ARRAY_BUFFER', tangents, 4);\r\n },\r\n\r\n compute: function(primitive, vx, nx, tx, ia, ib, ic) {\r\n var i0 = primitive.index(ia);\r\n var i1 = primitive.index(ib);\r\n var i2 = primitive.index(ic);\r\n\r\n // TODO perf : cache xx.getElements() but more importantly\r\n // subarray call have very high overhead, it's super useful\r\n // when you call it a few times for big array chunk, but for\r\n // small array extraction (each vertex) it's better to use a temporary\r\n // pre allocated array and simply fill it\r\n // then, you'll have to write in the big arrays at the end\r\n var P1 = vx.getElements().subarray(i0 * 3, i0 * 3 + 3);\r\n var P2 = vx.getElements().subarray(i1 * 3, i1 * 3 + 3);\r\n var P3 = vx.getElements().subarray(i2 * 3, i2 * 3 + 3);\r\n\r\n var N1 = nx.getElements().subarray(i0 * 3, i0 * 3 + 3);\r\n var N2 = nx.getElements().subarray(i1 * 3, i1 * 3 + 3);\r\n var N3 = nx.getElements().subarray(i2 * 3, i2 * 3 + 3);\r\n\r\n var uv1 = tx.getElements().subarray(i0 * 2, i0 * 2 + 2);\r\n var uv2 = tx.getElements().subarray(i1 * 2, i1 * 2 + 2);\r\n var uv3 = tx.getElements().subarray(i2 * 2, i2 * 2 + 2);\r\n\r\n var vz, vy;\r\n // TODO perf : use temporary vec\r\n var V = vec3.create();\r\n\r\n var B1 = vec3.create();\r\n var B2 = vec3.create();\r\n var B3 = vec3.create();\r\n\r\n var T1 = vec3.create();\r\n var T2 = vec3.create();\r\n var T3 = vec3.create();\r\n\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n\r\n vec3.set(v1, P2[0] - P1[0], uv2[0] - uv1[0], uv2[1] - uv1[1]);\r\n vec3.set(v2, P3[0] - P1[0], uv3[0] - uv1[0], uv3[1] - uv1[1]);\r\n\r\n vec3.cross(V, v1, v2);\r\n\r\n if (V[0] !== 0.0) {\r\n vec3.normalize(V, V);\r\n vy = -V[1] / V[0];\r\n vz = -V[2] / V[0];\r\n T1[0] += vy;\r\n B1[0] += vz;\r\n T2[0] += vy;\r\n B2[0] += vz;\r\n T3[0] += vy;\r\n B3[0] += vz;\r\n }\r\n\r\n vec3.set(v1, P2[1] - P1[1], uv2[0] - uv1[0], uv2[1] - uv1[1]);\r\n vec3.set(v2, P3[1] - P1[1], uv3[0] - uv1[0], uv3[1] - uv1[1]);\r\n\r\n vec3.cross(V, v1, v2);\r\n\r\n if (V[0] !== 0.0) {\r\n vec3.normalize(V, V);\r\n vy = -V[1] / V[0];\r\n vz = -V[2] / V[0];\r\n T1[1] += vy;\r\n B1[1] += vz;\r\n T2[1] += vy;\r\n B2[1] += vz;\r\n T3[1] += vy;\r\n B3[1] += vz;\r\n }\r\n\r\n vec3.set(v1, P2[2] - P1[2], uv2[0] - uv1[0], uv2[1] - uv1[1]);\r\n vec3.set(v2, P3[2] - P1[2], uv3[0] - uv1[0], uv3[1] - uv1[1]);\r\n\r\n vec3.cross(V, v1, v2);\r\n\r\n if (V[0] !== 0.0) {\r\n vec3.normalize(V, V);\r\n vy = -V[1] / V[0];\r\n vz = -V[2] / V[0];\r\n T1[2] += vy;\r\n B1[2] += vz;\r\n T2[2] += vy;\r\n B2[2] += vz;\r\n T3[2] += vy;\r\n B3[2] += vz;\r\n }\r\n\r\n var tempVec = vec3.create();\r\n var tempVec2 = vec3.create();\r\n\r\n var Tdst, Bdst, Ndst;\r\n\r\n vec3.cross(tempVec, N1, T1);\r\n vec3.cross(tempVec2, tempVec, N1);\r\n Tdst = this._T.subarray(i0 * 3, i0 * 3 + 3);\r\n vec3.add(Tdst, tempVec2, Tdst);\r\n\r\n vec3.cross(tempVec, B1, N1);\r\n vec3.cross(tempVec2, N1, tempVec);\r\n Bdst = this._B.subarray(i0 * 3, i0 * 3 + 3);\r\n vec3.add(Bdst, tempVec2, Bdst);\r\n\r\n vec3.cross(tempVec, N2, T2);\r\n vec3.cross(tempVec2, tempVec, N2);\r\n Tdst = this._T.subarray(i1 * 3, i1 * 3 + 3);\r\n vec3.add(Tdst, tempVec2, Tdst);\r\n\r\n vec3.cross(tempVec, B2, N2);\r\n vec3.cross(tempVec2, N2, tempVec);\r\n Bdst = this._B.subarray(i1 * 3, i1 * 3 + 3);\r\n vec3.add(Bdst, tempVec2, Bdst);\r\n\r\n vec3.cross(tempVec, N3, T3);\r\n vec3.cross(tempVec2, tempVec, N3);\r\n Tdst = this._T.subarray(i2 * 3, i2 * 3 + 3);\r\n vec3.add(Tdst, tempVec2, Tdst);\r\n\r\n vec3.cross(tempVec, B3, N3);\r\n vec3.cross(tempVec2, N3, tempVec);\r\n Bdst = this._B.subarray(i2 * 3, i2 * 3 + 3);\r\n vec3.add(Bdst, tempVec2, Bdst);\r\n\r\n Ndst = this._N.subarray(i0 * 3, i0 * 3 + 3);\r\n vec3.add(Ndst, N1, Ndst);\r\n\r\n Ndst = this._N.subarray(i1 * 3, i1 * 3 + 3);\r\n vec3.add(Ndst, N2, Ndst);\r\n\r\n Ndst = this._N.subarray(i2 * 3, i2 * 3 + 3);\r\n vec3.add(Ndst, N3, Ndst);\r\n }\r\n }),\r\n 'osgUtil',\r\n 'TangentSpaceGenerator'\r\n);\r\n\r\nexport default TangentSpaceGenerator;\r\n","import Camera from '../osg/Camera';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Node from '../osg/Node';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Shape from '../osg/shape';\r\nimport Texture from '../osg/Texture';\r\nimport Transform from '../osg/Transform';\r\nimport Uniform from '../osg/Uniform';\r\nimport { vec2 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport Viewport from '../osg/Viewport';\r\n\r\nvar WebVRCustom = {};\r\n\r\n// no smart resize, we just recreate everything\r\nvar UpdateRecreateOnResize = function(viewer, rttScene, hmdConfig, root, canvas) {\r\n this._viewer = viewer;\r\n this._rttScene = rttScene;\r\n this._hmdConfig = hmdConfig;\r\n this._root = root;\r\n this._canvas = canvas;\r\n this._width = canvas.width;\r\n this._height = canvas.height;\r\n};\r\n\r\nUpdateRecreateOnResize.prototype = {\r\n update: function() {\r\n var canvas = this._canvas;\r\n var width = canvas.width;\r\n var height = canvas.height;\r\n\r\n if (width !== this._width || height !== this._height) {\r\n this._root.removeChildren();\r\n\r\n var hmdConfig = this._hmdConfig;\r\n if (hmdConfig && hmdConfig.isCardboard) {\r\n hmdConfig.hResolution = width;\r\n hmdConfig.vResolution = height;\r\n }\r\n this._width = width;\r\n this._height = height;\r\n\r\n WebVRCustom.createScene(this._viewer, this._rttScene, hmdConfig, this._root);\r\n }\r\n return true;\r\n }\r\n};\r\n\r\nvar UpdateOffsetCamera = function(rootView, offsetView) {\r\n this._rootView = rootView;\r\n this._offsetView = offsetView;\r\n};\r\n\r\nUpdateOffsetCamera.prototype = {\r\n update: function(node) {\r\n var nodeView = node.getViewMatrix();\r\n mat4.mul(nodeView, this._offsetView, this._rootView);\r\n return true;\r\n }\r\n};\r\n\r\nvar setupWebVR = function(worldFactor, HMD, webVRUniforms, webVRMatrices) {\r\n var aspect = HMD.hResolution / (2.0 * HMD.vResolution);\r\n var r =\r\n -1.0 - 4.0 * (HMD.hScreenSize * 0.25 - HMD.lensSeparationDistance * 0.5) / HMD.hScreenSize;\r\n var distScale =\r\n HMD.distortionK[0] +\r\n HMD.distortionK[1] * Math.pow(r, 2) +\r\n HMD.distortionK[2] * Math.pow(r, 4) +\r\n HMD.distortionK[3] * Math.pow(r, 6);\r\n var fov =\r\n 180.0 /\r\n Math.PI *\r\n 2.0 *\r\n Math.atan2(HMD.vScreenSize * distScale, 2.0 * HMD.eyeToScreenDistance);\r\n\r\n var proj = mat4.perspective(mat4.create(), Math.PI / 180 * fov, aspect, 0.3, 10000.0);\r\n\r\n var hOffset =\r\n 4.0 * (HMD.hScreenSize * 0.25 - HMD.interpupillaryDistance * 0.5) / HMD.hScreenSize;\r\n var lensShift =\r\n 4.0 * (HMD.hScreenSize * 0.25 - HMD.lensSeparationDistance * 0.5) / HMD.hScreenSize;\r\n\r\n var leftMat = mat4.create();\r\n var rightMat = mat4.create();\r\n webVRMatrices.projectionLeft = mat4.mul(\r\n leftMat,\r\n mat4.fromTranslation(leftMat, vec3.fromValues(hOffset, 0.0, 0.0)),\r\n proj\r\n );\r\n webVRMatrices.projectionRight = mat4.mul(\r\n rightMat,\r\n mat4.fromTranslation(rightMat, vec3.fromValues(-hOffset, 0.0, 0.0)),\r\n proj\r\n );\r\n webVRMatrices.viewLeft = mat4.fromTranslation(\r\n mat4.create(),\r\n vec3.fromValues(worldFactor * HMD.interpupillaryDistance * 0.5, 0.0, 0.0)\r\n );\r\n webVRMatrices.viewRight = mat4.fromTranslation(\r\n mat4.create(),\r\n vec3.fromValues(-worldFactor * HMD.interpupillaryDistance * 0.5, 0.0, 0.0)\r\n );\r\n\r\n webVRUniforms.lensCenterLeft = vec2.fromValues(lensShift, 0.0);\r\n webVRUniforms.lensCenterRight = vec2.fromValues(-lensShift, 0.0);\r\n webVRUniforms.hmdWarpParam = HMD.distortionK;\r\n webVRUniforms.chromAbParam = HMD.chromaAbParameter;\r\n webVRUniforms.scaleIn = vec2.fromValues(1.0, 1.0 / aspect);\r\n webVRUniforms.scale = vec2.fromValues(1.0 / distScale, 1.0 * aspect / distScale);\r\n};\r\n\r\nvar getWebVRShader = function() {\r\n var fragmentshader = [\r\n '',\r\n '#ifdef GL_ES',\r\n 'precision highp float;',\r\n '#endif',\r\n\r\n 'uniform vec2 uScale;',\r\n 'uniform vec2 uScaleIn;',\r\n 'uniform vec2 uLensCenter;',\r\n 'uniform vec4 uHmdWarpParam;',\r\n 'uniform vec4 uChromAbParam;',\r\n 'uniform sampler2D Texture0;',\r\n\r\n 'varying vec2 vTexCoord0;',\r\n\r\n // from http://paradise.untergrund.net/tmp/demoshit/examples/js/effects/OculusRiftEffect.js\r\n 'void main(void) {',\r\n ' vec2 uv = (vTexCoord0 * 2.0) - 1.0;', // range from [0,1] to [-1,1]\r\n ' vec2 theta = (uv - uLensCenter) * uScaleIn;',\r\n ' float rSq = theta.x * theta.x + theta.y * theta.y;',\r\n ' vec2 rvector = theta * (uHmdWarpParam.x + uHmdWarpParam.y * rSq + uHmdWarpParam.z * rSq * rSq + uHmdWarpParam.w * rSq * rSq * rSq);',\r\n ' vec2 rBlue = rvector * (uChromAbParam.z + uChromAbParam.w * rSq);',\r\n ' vec2 tcBlue = (uLensCenter + uScale * rBlue);',\r\n ' tcBlue = (tcBlue + 1.0) * 0.5;', // range from [-1,1] to [0,1]\r\n ' if (any(bvec2(clamp(tcBlue, vec2(0.0, 0.0), vec2(1.0, 1.0)) - tcBlue))) {',\r\n ' gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);',\r\n ' return;',\r\n ' }',\r\n ' vec2 tcGreen = uLensCenter + uScale * rvector;',\r\n ' tcGreen = (tcGreen + 1.0) * 0.5;', // range from [-1,1] to [0,1]\r\n ' vec2 rRed = rvector * (uChromAbParam.x + uChromAbParam.y * rSq);',\r\n ' vec2 tcRed = uLensCenter + uScale * rRed;',\r\n ' tcRed = (tcRed + 1.0) * 0.5;', // range from [-1,1] to [0,1]\r\n ' gl_FragColor = vec4(texture2D(Texture0, tcRed).r, texture2D(Texture0, tcGreen).g, texture2D(Texture0, tcBlue).b, 1);',\r\n '}',\r\n ''\r\n ].join('\\n');\r\n\r\n return new Program(\r\n new Shader(\r\n Shader.VERTEX_SHADER,\r\n [\r\n 'attribute vec3 Vertex;',\r\n 'varying vec2 vTexCoord0;',\r\n 'void main(void) {',\r\n ' gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);',\r\n ' vTexCoord0 = Vertex.xy;',\r\n '}',\r\n '',\r\n '#define SHADER_NAME VRpostProcessing',\r\n ''\r\n ].join('\\n')\r\n ),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentshader)\r\n );\r\n};\r\n\r\nvar createTextureRtt = function(rttSize) {\r\n var rttTexture = new Texture();\r\n rttTexture.setTextureSize(rttSize[0], rttSize[1]);\r\n rttTexture.setMinFilter('LINEAR');\r\n rttTexture.setMagFilter('LINEAR');\r\n return rttTexture;\r\n};\r\n\r\nvar createOrthoRtt = function(left, viewportSize, canvasSize, cardboard, texture, webVRUniforms) {\r\n var orthoCamera = new Camera();\r\n var vw = viewportSize[0];\r\n var vh = viewportSize[1];\r\n var cw = canvasSize[0];\r\n var ch = canvasSize[1];\r\n if (cardboard === true) {\r\n if (left) orthoCamera.setViewport(new Viewport(0.0, 0.0, cw / 2.0, ch));\r\n else orthoCamera.setViewport(new Viewport(cw / 2.0, 0.0, cw / 2.0, ch));\r\n } else {\r\n if (left) orthoCamera.setViewport(new Viewport(0.5 * cw - vw, 0.5 * (ch - vh), vw, vh));\r\n else orthoCamera.setViewport(new Viewport(0.5 * cw, 0.5 * (ch - vh), vw, vh));\r\n }\r\n mat4.ortho(orthoCamera.getProjectionMatrix(), -0.5, 0.5, -0.5, 0.5, -5, 5);\r\n orthoCamera.setRenderOrder(Camera.NESTED_RENDER, 0);\r\n orthoCamera.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n\r\n var stateSet = orthoCamera.getOrCreateStateSet();\r\n stateSet.setTextureAttributeAndModes(0, texture);\r\n stateSet.setAttributeAndModes(getWebVRShader());\r\n stateSet.addUniform(Uniform.createFloat2(webVRUniforms.scale, 'uScale'));\r\n stateSet.addUniform(Uniform.createFloat2(webVRUniforms.scaleIn, 'uScaleIn'));\r\n stateSet.addUniform(\r\n Uniform.createFloat2(\r\n left ? webVRUniforms.lensCenterLeft : webVRUniforms.lensCenterRight,\r\n 'uLensCenter'\r\n )\r\n );\r\n stateSet.addUniform(Uniform.createFloat4(webVRUniforms.hmdWarpParam, 'uHmdWarpParam'));\r\n stateSet.addUniform(Uniform.createFloat4(webVRUniforms.chromAbParam, 'uChromAbParam'));\r\n\r\n return orthoCamera;\r\n};\r\n\r\nvar createCameraRtt = function(texture, projMatrix) {\r\n var camera = new Camera();\r\n camera.setName('rtt camera');\r\n camera.setViewport(new Viewport(0, 0, texture.getWidth(), texture.getHeight()));\r\n camera.setProjectionMatrix(projMatrix);\r\n camera.setClearColor(vec4.fromValues(0.3, 0.3, 0.3, 0.0));\r\n camera.setRenderOrder(Camera.POST_RENDER, 0);\r\n camera.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, texture);\r\n camera.attachRenderBuffer(\r\n FrameBufferObject.DEPTH_ATTACHMENT,\r\n FrameBufferObject.DEPTH_COMPONENT16\r\n );\r\n camera.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n return camera;\r\n};\r\n\r\nWebVRCustom.createScene = function(viewer, rttScene, HMDconfig, rootOverride, worldFactorOverride) {\r\n var HMD = WebVRCustom.getDefaultConfig(HMDconfig);\r\n var rttSize = vec2.fromValues(HMD.hResolution * 0.5, HMD.vResolution);\r\n var viewportSize = vec2.fromValues(HMD.hResolution * 0.5, HMD.vResolution);\r\n var vp = viewer.getCamera().getViewport();\r\n var canvasSize = vec2.fromValues(vp.width(), vp.height());\r\n\r\n var canvas = viewer.getGraphicContext().canvas;\r\n if (HMD.isCardboard) {\r\n canvasSize[0] = canvas.width;\r\n canvasSize[1] = canvas.height;\r\n }\r\n\r\n var worldFactor = worldFactorOverride !== undefined ? worldFactorOverride : 1.0;\r\n var webVRUniforms = {};\r\n var webVRMatrices = {};\r\n setupWebVR(worldFactor, HMD, webVRUniforms, webVRMatrices);\r\n\r\n var rootViewMatrix = viewer.getCamera().getViewMatrix();\r\n\r\n var root = rootOverride || new Node();\r\n root.addUpdateCallback(new UpdateRecreateOnResize(viewer, rttScene, HMDconfig, root, canvas));\r\n\r\n var rttTextureLeft = createTextureRtt(rttSize);\r\n var rttCamLeft = createCameraRtt(rttTextureLeft, webVRMatrices.projectionLeft);\r\n var orthoCameraLeft = createOrthoRtt(\r\n true,\r\n viewportSize,\r\n canvasSize,\r\n HMD.isCardboard,\r\n rttTextureLeft,\r\n webVRUniforms\r\n );\r\n rttCamLeft.addUpdateCallback(new UpdateOffsetCamera(rootViewMatrix, webVRMatrices.viewLeft));\r\n\r\n var rttTextureRight = createTextureRtt(rttSize);\r\n var rttCamRight = createCameraRtt(rttTextureRight, webVRMatrices.projectionRight);\r\n var orthoCameraRight = createOrthoRtt(\r\n false,\r\n viewportSize,\r\n canvasSize,\r\n HMD.isCardboard,\r\n rttTextureRight,\r\n webVRUniforms\r\n );\r\n rttCamRight.addUpdateCallback(new UpdateOffsetCamera(rootViewMatrix, webVRMatrices.viewRight));\r\n\r\n rttCamLeft.addChild(rttScene);\r\n rttCamRight.addChild(rttScene);\r\n\r\n orthoCameraLeft.addChild(Shape.createTexturedFullScreenFakeQuadGeometry());\r\n orthoCameraRight.addChild(Shape.createTexturedFullScreenFakeQuadGeometry());\r\n\r\n root.addChild(rttCamLeft);\r\n root.addChild(rttCamRight);\r\n\r\n root.addChild(orthoCameraLeft);\r\n root.addChild(orthoCameraRight);\r\n\r\n return root;\r\n};\r\n\r\nWebVRCustom.getDefaultConfig = function(hmdConfig) {\r\n // FOV: 103.506416\r\n // vScreenCenter: 0.03645\r\n\r\n // Oculus Rift DK2\r\n var hmd = {\r\n hResolution: 1920,\r\n vResolution: 1080,\r\n hScreenSize: 0.1296,\r\n vScreenSize: 0.0729,\r\n interpupillaryDistance: 0.064,\r\n lensSeparationDistance: 0.0635,\r\n eyeToScreenDistance: 0.04,\r\n distortionK: vec4.fromValues(1.0, 0.22, 0.13, 0.02),\r\n chromaAbParameter: vec4.fromValues(0.996, -0.004, 1.014, 0.0),\r\n isCardboard: false\r\n };\r\n\r\n if (hmdConfig === 2 || hmdConfig === undefined) return hmd;\r\n\r\n if (hmdConfig === 1) {\r\n // Oculus Rift DK1\r\n hmd.hResolution = 1280;\r\n hmd.vResolution = 800;\r\n hmd.hScreenSize = 0.14976;\r\n hmd.vScreenSize = 0.0936;\r\n hmd.lensSeparationDistance = 0.064;\r\n hmd.eyeToScreenDistance = 0.041;\r\n hmd.distortionK = vec4.fromValues(1.0, 0.22, 0.24, 0.0);\r\n return hmd;\r\n }\r\n\r\n // custom param\r\n if (hmdConfig.hResolution !== undefined) hmd.hResolution = hmdConfig.hResolution;\r\n if (hmdConfig.vResolution !== undefined) hmd.vResolution = hmdConfig.vResolution;\r\n if (hmdConfig.hScreenSize !== undefined) hmd.hScreenSize = hmdConfig.hScreenSize;\r\n if (hmdConfig.vScreenSize !== undefined) hmd.vScreenSize = hmdConfig.vScreenSize;\r\n if (hmdConfig.interpupillaryDistance !== undefined)\r\n hmd.interpupillaryDistance = hmdConfig.interpupillaryDistance;\r\n if (hmdConfig.lensSeparationDistance !== undefined)\r\n hmd.lensSeparationDistance = hmdConfig.lensSeparationDistance;\r\n if (hmdConfig.eyeToScreenDistance !== undefined)\r\n hmd.eyeToScreenDistance = hmdConfig.eyeToScreenDistance;\r\n if (hmdConfig.distortionK !== undefined) hmd.distortionK = hmdConfig.distortionK;\r\n if (hmdConfig.chromaAbParameter !== undefined)\r\n hmd.chromaAbParameter = hmdConfig.chromaAbParameter;\r\n if (hmdConfig.isCardboard !== undefined) hmd.isCardboard = hmdConfig.isCardboard;\r\n\r\n return hmd;\r\n};\r\n\r\nexport default WebVRCustom;\r\n","import Camera from '../osg/Camera';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Node from '../osg/Node';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Shape from '../osg/shape';\r\nimport Texture from '../osg/Texture';\r\nimport Transform from '../osg/Transform';\r\nimport Uniform from '../osg/Uniform';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport Viewport from '../osg/Viewport';\r\n\r\nvar UpdateRttCameraCallback = function(rootView, offsetView) {\r\n this._rootView = rootView;\r\n this._offsetView = offsetView;\r\n};\r\n\r\nUpdateRttCameraCallback.prototype = {\r\n update: function(node /*, nv */) {\r\n var nodeView = node.getViewMatrix();\r\n mat4.mul(nodeView, this._offsetView, this._rootView);\r\n return true;\r\n }\r\n};\r\n\r\nvar createTexture = function(size) {\r\n var texture = new Texture();\r\n texture.setTextureSize(size.width, size.height);\r\n texture.setMinFilter('LINEAR');\r\n texture.setMagFilter('LINEAR');\r\n return texture;\r\n};\r\n\r\nvar getAssembleShader = function() {\r\n var fragmentShader = [\r\n '#ifdef GL_ES',\r\n ' precision highp float;',\r\n '#endif',\r\n 'varying vec2 vTexCoord0;',\r\n 'uniform sampler2D TextureLeft;',\r\n 'uniform sampler2D TextureRight;',\r\n\r\n 'void main() {',\r\n ' if (vTexCoord0.x < 0.5)',\r\n ' gl_FragColor = texture2D(TextureLeft, vec2(vTexCoord0.x * 2.0, vTexCoord0.y));',\r\n ' else',\r\n ' gl_FragColor = texture2D(TextureRight, vec2(vTexCoord0.x * 2.0 - 1.0, vTexCoord0.y));',\r\n '}'\r\n ].join('\\n');\r\n\r\n return new Program(\r\n new Shader(\r\n Shader.VERTEX_SHADER,\r\n [\r\n 'attribute vec3 Vertex;',\r\n 'varying vec2 vTexCoord0;',\r\n 'void main(void) {',\r\n ' gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);',\r\n ' vTexCoord0 = Vertex.xy;',\r\n '}',\r\n '',\r\n '#define SHADER_NAME VRpostProcessing',\r\n ''\r\n ].join('\\n')\r\n ),\r\n new Shader(Shader.FRAGMENT_SHADER, fragmentShader)\r\n );\r\n};\r\n\r\n// This camera will render both textures on the canvas in a single pass\r\nvar createCameraCanvas = function(leftEyeTexture, rightEyeTexture, viewport) {\r\n var orthoCamera = new Camera();\r\n orthoCamera.setViewport(viewport);\r\n orthoCamera.setRenderOrder(Camera.NESTED_RENDER, 0);\r\n orthoCamera.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n mat4.ortho(orthoCamera.getProjectionMatrix(), 0.0, 1.0, 0.0, 1.0, -5.0, 5.0);\r\n\r\n var stateSet = orthoCamera.getOrCreateStateSet();\r\n stateSet.addUniform(Uniform.createInt(0, 'TextureLeft'));\r\n stateSet.addUniform(Uniform.createInt(1, 'TextureRight'));\r\n stateSet.setTextureAttributeAndModes(0, leftEyeTexture);\r\n stateSet.setTextureAttributeAndModes(1, rightEyeTexture);\r\n stateSet.setAttributeAndModes(getAssembleShader());\r\n\r\n orthoCamera.addChild(Shape.createTexturedFullScreenFakeQuadGeometry());\r\n\r\n return orthoCamera;\r\n};\r\n\r\n// This camera will render the scene on a texture for an eye\r\nvar createCameraRtt = function(texture, projection) {\r\n var camera = new Camera();\r\n camera.setName('rtt camera');\r\n camera.setViewport(new Viewport(0.0, 0.0, texture.getWidth(), texture.getHeight()));\r\n camera.setProjectionMatrix(projection);\r\n camera.setClearColor(vec4.fromValues(0.3, 0.3, 0.3, 0.0));\r\n camera.setRenderOrder(Camera.POST_RENDER, 0);\r\n camera.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, texture);\r\n camera.attachRenderBuffer(\r\n FrameBufferObject.DEPTH_ATTACHMENT,\r\n FrameBufferObject.DEPTH_COMPONENT16\r\n );\r\n camera.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n return camera;\r\n};\r\n\r\nvar WebVR = {};\r\n\r\nWebVR.createScene = function(viewer, rttScene, HMDdevice, rootOverride, worldFactorOverride) {\r\n var root = rootOverride || new Node();\r\n HMDdevice.requestAnimationFrame(function() {\r\n var worldFactor = worldFactorOverride !== undefined ? worldFactorOverride : 1.0;\r\n\r\n var left = HMDdevice.getEyeParameters('left');\r\n var right = HMDdevice.getEyeParameters('right');\r\n\r\n var frameData = new window.VRFrameData();\r\n HMDdevice.getFrameData(frameData);\r\n\r\n // Compute projections and view matrices for both eyes\r\n var viewLeft = mat4.fromTranslation(\r\n mat4.create(),\r\n vec3.fromValues(-worldFactor * left.offset[0], left.offset[1], left.offset[2])\r\n );\r\n var viewRight = mat4.fromTranslation(\r\n mat4.create(),\r\n vec3.fromValues(-worldFactor * right.offset[0], right.offset[1], right.offset[2])\r\n );\r\n\r\n // Each eye is rendered on a texture whose width is half of the final combined texture\r\n var eyeTextureSize = {\r\n width: Math.max(left.renderWidth, right.renderWidth),\r\n height: Math.max(left.renderHeight, right.renderHeight)\r\n };\r\n\r\n var leftEyeTexture = createTexture(eyeTextureSize);\r\n var rightEyeTexture = createTexture(eyeTextureSize);\r\n\r\n // Setup the render cameras for both eyes\r\n var camRttLeft = createCameraRtt(leftEyeTexture, frameData.leftProjectionMatrix);\r\n var camRttRight = createCameraRtt(rightEyeTexture, frameData.rightProjectionMatrix);\r\n\r\n // The viewMatrix of each eye is updated with the current viewer's camera viewMatrix\r\n var rootViewMatrix = viewer.getCamera().getViewMatrix();\r\n camRttLeft.addUpdateCallback(new UpdateRttCameraCallback(rootViewMatrix, viewLeft));\r\n camRttRight.addUpdateCallback(new UpdateRttCameraCallback(rootViewMatrix, viewRight));\r\n\r\n // Render both textures on the canvas, using the viewer's camera viewport to render on the fullscreen canvas\r\n var camCanvas = createCameraCanvas(\r\n leftEyeTexture,\r\n rightEyeTexture,\r\n viewer.getCamera().getViewport()\r\n );\r\n\r\n camRttLeft.addChild(rttScene);\r\n camRttRight.addChild(rttScene);\r\n\r\n root.addChild(camRttLeft);\r\n root.addChild(camRttRight);\r\n root.addChild(camCanvas);\r\n });\r\n return root;\r\n};\r\n\r\nexport default WebVR;\r\n","import ComposerPostProcess from './ComposerPostProcess';\r\nimport debug from './debug';\r\nimport DelayInterpolator from './DelayInterpolator';\r\nimport DisplayNormalVisitor from './DisplayNormalVisitor';\r\nimport DisplayGeometryVisitor from './DisplayGeometryVisitor';\r\nimport DisplayGraph from './DisplayGraph';\r\nimport IntersectFunctor from './IntersectFunctor';\r\nimport Intersector from './Intersector';\r\nimport IntersectionVisitor from './IntersectionVisitor';\r\nimport LineSegmentIntersector from './LineSegmentIntersector';\r\nimport LineSegmentIntersectFunctor from './LineSegmentIntersectFunctor';\r\nimport utils from '../osg/utils';\r\nimport NodeGizmo from './NodeGizmo';\r\nimport GizmoGeometry from './gizmoGeometry';\r\nimport PolytopeIntersector from './PolytopeIntersector';\r\nimport PolytopeIntersectFunctor from './PolytopeIntersectFunctor';\r\nimport SphereIntersector from './SphereIntersector';\r\nimport TangentSpaceGenerator from './TangentSpaceGenerator';\r\nimport WebVRCustom from './WebVRCustom';\r\nimport WebVR from './WebVR';\r\nimport intersectionEnums from './intersectionEnums';\r\n\r\nvar osgUtil = {};\r\n\r\nosgUtil.ComposerPostProcess = ComposerPostProcess;\r\nutils.objectMix(osgUtil, debug);\r\nosgUtil.DelayInterpolator = DelayInterpolator;\r\nosgUtil.DisplayNormalVisitor = DisplayNormalVisitor;\r\nosgUtil.DisplayGeometryVisitor = DisplayGeometryVisitor;\r\nosgUtil.DisplayGraph = DisplayGraph;\r\nosgUtil.IntersectFunctor = IntersectFunctor;\r\nosgUtil.Intersector = Intersector;\r\nosgUtil.IntersectionVisitor = IntersectionVisitor;\r\nosgUtil.LineSegmentIntersector = LineSegmentIntersector;\r\nosgUtil.LineSegmentIntersectFunctor = LineSegmentIntersectFunctor;\r\nosgUtil.NodeGizmo = NodeGizmo;\r\nosgUtil.GizmoGeometry = GizmoGeometry;\r\nosgUtil.WebVRCustom = WebVRCustom;\r\nosgUtil.PolytopeIntersector = PolytopeIntersector;\r\nosgUtil.PolytopeIntersectFunctor = PolytopeIntersectFunctor;\r\nosgUtil.SphereIntersector = SphereIntersector;\r\nosgUtil.TangentSpaceGenerator = TangentSpaceGenerator;\r\nosgUtil.WebVR = WebVR;\r\n\r\nosgUtil.NO_LIMIT = intersectionEnums.NO_LIMIT;\r\nosgUtil.LIMIT_ONE_PER_DRAWABLE = intersectionEnums.LIMIT_ONE_PER_DRAWABLE;\r\nosgUtil.LIMIT_ONE = intersectionEnums.LIMIT_ONE;\r\n\r\nosgUtil.POINT_PRIMITIVES = intersectionEnums.POINT_PRIMITIVES;\r\nosgUtil.LINE_PRIMITIVES = intersectionEnums.LINE_PRIMITIVES;\r\nosgUtil.TRIANGLE_PRIMITIVES = intersectionEnums.TRIANGLE_PRIMITIVES;\r\nosgUtil.ALL_PRIMITIVES = intersectionEnums.ALL_PRIMITIVES;\r\n\r\nexport default osgUtil;\r\n","// import GlobalSetter from './FrameManager.js'\r\n\r\nimport osgUtil from '../osgUtil/osgUtil'\r\nimport utils from '../osg/utils'\r\n\r\nexport default class NodeGizmo extends osgUtil.NodeGizmo {\r\n constructor(appviewer) {\r\n super(appviewer.getViewerOSGJS()) \r\n this._appviewer = appviewer\r\n this._forcePicking = false\r\n this._event = {}\r\n //this._autoInsertMT = false\r\n }\r\n setForcePicking(value) {\r\n this._forcePicking = value\r\n }\r\n clearEvent() {\r\n this._event = {}\r\n }\r\n onMouseUp(event) {\r\n if (this.isEditing()) {\r\n this._appviewer._frameManager.draw() // && GlobalSetter.draw()\r\n this._event.onFinished && this._event.onFinished(attachNode)\r\n }\r\n const attachNode = this._attachedNode\r\n osgUtil.NodeGizmo.prototype.onMouseUp.call(this, event)\r\n attachNode !== this._attachedNode && (this._appviewer._frameManager.draw())\r\n this._forcePicking &&\r\n !this._attachedNode &&\r\n (this._attachedNode = attachNode)\r\n }\r\n\r\n onMouseMove(event) {\r\n var hoverNode = this._hoverNode\r\n osgUtil.NodeGizmo.prototype.onMouseMove.call(this, event)\r\n if (this.isEditing()) {\r\n this._appviewer._frameManager.redrawShadow() \r\n this._event.onChanged && this._event.onChanged(this._attachedNode)\r\n }\r\n if (hoverNode !== this._hoverNode) {\r\n this._appviewer._frameManager.draw() \r\n }\r\n }\r\n\r\n attachToNode(node) { \r\n super.attachToNode.call(this, node) \r\n this._event = {onChanged: null, onFinished: null, clear: this.clearEvent.bind(this)} \r\n return this._event\r\n }\r\n}\r\n\r\nutils.createPrototypeNode(\r\n NodeGizmo,\r\n NodeGizmo.prototype,\r\n 'Editor',\r\n 'NodeGizmo',\r\n)\r\n","import osg from '../osg/osg'\r\n\r\nclass ComputeBoundsVisitor extends osg.ComputeBoundsVisitor {\r\n constructor() {\r\n super()\r\n this._minBox = new osg.BoundingBox()\r\n this._visitedBuffers = {}\r\n }\r\n\r\n getPreciseBox() {\r\n return this._minBox\r\n }\r\n\r\n apply(node) {\r\n if (node instanceof osg.Transform) this.applyTransform(node)\r\n else {\r\n if (node instanceof osg.Geometry) {\r\n const localMatrix =\r\n this._matrixStack.getLength() > 0 ? this._matrixStack.back() : osg.mat4.IDENTITY\r\n const vertex = node.getVertexAttributeList().Vertex\r\n const visitedBuffer = this._visitedBuffers[vertex.getInstanceID()]\r\n if (visitedBuffer && osg.mat4.exactEquals(visitedBuffer.matrix, localMatrix)) return\r\n var transformedVertices = node.computeTransformedVertices\r\n ? node.computeTransformedVertices()\r\n : vertex.getElements()\r\n this._visitedBuffers[vertex.getInstanceID()] = {\r\n buffer: transformedVertices,\r\n matrix: osg.mat4.copy(osg.mat4.create(), localMatrix)\r\n }\r\n const m00 = localMatrix[0]\r\n const m10 = localMatrix[1]\r\n const m20 = localMatrix[2]\r\n const m30 = localMatrix[3]\r\n const m01 = localMatrix[4]\r\n const m11 = localMatrix[5]\r\n const m21 = localMatrix[6]\r\n const m31 = localMatrix[7]\r\n const m02 = localMatrix[8]\r\n const m12 = localMatrix[9]\r\n const m22 = localMatrix[10]\r\n const m32 = localMatrix[11]\r\n const m03 = localMatrix[12]\r\n const m13 = localMatrix[13]\r\n const m23 = localMatrix[14]\r\n const m33 = localMatrix[15]\r\n var boxMin = this._minBox.getMin()\r\n var boxMax = this._minBox.getMax()\r\n let curMinX = boxMin[0]\r\n let curMinY = boxMin[1]\r\n let curMinZ = boxMin[2]\r\n let curMaxX = boxMax[0]\r\n let curMaxY = boxMax[1]\r\n let curMaxZ = boxMax[2]\r\n for (let index = 0, vertexCount = transformedVertices.length; index < vertexCount; index += 3) {\r\n const px = transformedVertices[index]\r\n const py = transformedVertices[index + 1]\r\n const pz = transformedVertices[index + 2]\r\n const m3_X_P = m30 * px + m31 * py + m32 * pz + m33 || 1 // w\r\n const m0_X_P = (m00 * px + m01 * py + m02 * pz + m03) / m3_X_P\r\n const m1_X_P = (m10 * px + m11 * py + m12 * pz + m13) / m3_X_P\r\n const m2_X_P = (m20 * px + m21 * py + m22 * pz + m23) / m3_X_P\r\n m0_X_P < curMinX && (curMinX = m0_X_P)\r\n m1_X_P < curMinY && (curMinY = m1_X_P)\r\n m2_X_P < curMinZ && (curMinZ = m2_X_P)\r\n m0_X_P > curMaxX && (curMaxX = m0_X_P)\r\n m1_X_P > curMaxY && (curMaxY = m1_X_P)\r\n m2_X_P > curMaxZ && (curMaxZ = m2_X_P)\r\n }\r\n\r\n boxMin[0] = curMinX\r\n boxMin[1] = curMinY\r\n boxMin[2] = curMinZ\r\n boxMax[0] = curMaxX\r\n boxMax[1] = curMaxY\r\n boxMax[2] = curMaxZ \r\n }\r\n this.traverse(node)\r\n }\r\n }\r\n}\r\n\r\nexport default ComputeBoundsVisitor\r\n","\r\nimport osg from '../osg/osg';\r\nimport ComputeBoundsVisitor from './ComputeBoundsVisitor';\r\n\r\nclass BoundingComputer {\r\n constructor(){\r\n this.modelboxWidthDisplacement= null\r\n this.modelboxWithoutDisplacement= null\r\n this._maxWorldDisplacement= 0\r\n this.BIAS_MIN= 0.9\r\n this.BIAS_MAX= 1.1\r\n }\r\n\r\n updateMaxWorldDisplacement (maxWorldDisp) {\r\n if (maxWorldDisp <= this._maxWorldDisplacement) return \r\n this._maxWorldDisplacement = maxWorldDisp\r\n this._updateModelBoxes()\r\n }\r\n getModelBoxWithDisplacement () {\r\n return this.modelboxWidthDisplacement\r\n }\r\n getModelBoxWithoutDisplacement () {\r\n return this.modelboxWithoutDisplacement\r\n }\r\n _updateModelBoxes () {\r\n if (this.modelboxWidthDisplacement) {\r\n const min_disp = this.modelboxWidthDisplacement.getMin()\r\n const max_disp = this.modelboxWidthDisplacement.getMax()\r\n const worldDisp = osg.vec3.fromValues(this._maxWorldDisplacement, this._maxWorldDisplacement, this._maxWorldDisplacement)\r\n osg.vec3.add(max_disp, max_disp, worldDisp)\r\n osg.vec3.sub(min_disp, min_disp, worldDisp)\r\n }\r\n }\r\n computePreciseBox (node) {\r\n var visitor = new ComputeBoundsVisitor()\r\n node.accept(visitor)\r\n this.modelboxWidthDisplacement = visitor.getPreciseBox()\r\n this.modelboxWithoutDisplacement = new osg.BoundingBox().copy(this.modelboxWidthDisplacement)\r\n this._updateModelBoxes()\r\n }\r\n getMaxDistanceFromOrigin () {\r\n const min_l = osg.vec3.length(this.modelboxWithoutDisplacement.getMin())\r\n const max_l = osg.vec3.length(this.modelboxWithoutDisplacement.getMax())\r\n return Math.max(min_l, max_l)\r\n }\r\n}\r\n\r\nexport default BoundingComputer","import osg from '../osg/osg';\r\nimport NextShaderProcessor from '../osgShader/NextShaderProcessor';\r\n\r\nclass ShaderMaker {\r\n constructor() {\r\n this._shaderCache = {}\r\n }\r\n getOrCreateShader (vert, farg, shaderId, shaderName, defines) {\r\n let defineStrings = ''\r\n defines && (defineStrings = defines.toString())\r\n const shaderHash = shaderId + defineStrings\r\n let shaderCache = this._shaderCache[shaderHash]\r\n if (!shaderCache) {\r\n shaderCache = this._createShader(vert, farg, shaderId, shaderName, defines)\r\n this._shaderCache[shaderHash] = shaderCache\r\n }\r\n return shaderCache\r\n } \r\n \r\n _createShader (vert, frag, shaderid, shadername, defines) {\r\n shadername = '#define SHADER_NAME ' + shadername + '\\n'\r\n if (defines)\r\n if (Array.isArray(defines))\r\n for (var u = 0; u < defines.length; u++) shadername += '#define ' + defines[u] + '\\n'\r\n else shadername += '#define ' + defines + '\\n'\r\n const shaderChunk = {}\r\n shaderChunk[shaderid + '-vert'] = shadername + vert\r\n shaderChunk[shaderid + '-frag'] = shadername + frag\r\n NextShaderProcessor.addShaders(shaderChunk)\r\n return new osg.Program(\r\n new osg.Shader(osg.Shader.VERTEX_SHADER, NextShaderProcessor.getShader(shaderid + '-vert')),\r\n new osg.Shader(osg.Shader.FRAGMENT_SHADER, NextShaderProcessor.getShader(shaderid + '-frag'))\r\n )\r\n }\r\n\r\n clearCache(){\r\n this._shaderCache = {}\r\n }\r\n}\r\n\r\nconst SHADER_MAKER = new ShaderMaker()\r\nexport default SHADER_MAKER","import osg from '../osg/osg';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport GLState from './GLState';\r\nimport RenderDetail from './RenderDetail';\r\nimport ShaderMaker from './ShaderMaker';\r\nimport PickMask from './PickMask';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport BlendColor from '../osg/BlendColor';\r\nimport GridImage from './assets/grid.png'\r\n\r\nconst GridVertexShader = 'attribute vec3 Vertex;\\nuniform mat4 uModelViewMatrix;\\nuniform mat4 uProjectionMatrix;\\n\\nvoid main(void) {\\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\\n}\\n';\r\n\r\nconst GridFragShader = 'uniform vec4 uColor;void main(void) {gl_FragColor = vec4(uColor.xyz * uColor.a, uColor.a);}'\r\n\r\nconst AxisVertexShader =\r\n \"attribute vec3 Vertex;\\nattribute vec4 Color;\\nvarying vec4 vColor;\\nuniform mat4 uModelViewMatrix;\\nuniform mat4 uProjectionMatrix;\\n\\nvoid main(void) {\\n vColor = Color;\\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\\n}\\n\"\r\n\r\nconst AxisFragShader =\r\n \"uniform vec4 uColor;\\nvarying vec4 vColor;\\n\\nvoid main(void) {\\n gl_FragColor = vec4( vec3(vColor) * uColor.a, uColor.a);\\n}\\n\"\r\n\r\nconst TextureVertexShader = `\r\n attribute vec3 Vertex;\r\n attribute vec2 TexCoord0; \r\n varying vec2 vTexCoord0;\r\n uniform mat4 uModelViewMatrix;\r\n uniform mat4 uProjectionMatrix;\r\n void main(void) {\r\n vTexCoord0 = TexCoord0;\r\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\r\n }\r\n`\r\n\r\nconst TextureFragSHader = `\r\n varying vec2 vTexCoord0;\r\n uniform sampler2D uTexture;\r\n void main(void) {\r\n vec4 tex = texture2D(uTexture, vTexCoord0);\r\n gl_FragColor = tex;\r\n }\r\n`\r\n\r\nexport default class WorldGrid extends MatrixTransform {\r\n constructor() {\r\n super()\r\n this._timeGrid = 0\r\n const color = osg.Uniform.createFloat4(osg.vec4.fromValues(0.5, 0.5, 0.5, 1), 'uColor')\r\n //this._callbackColor = new DelayInterpolator(color.getInternalArray(), 1)\r\n //this._callbackColor.setFinishCallback(this._makeDisable.bind(this))\r\n //this.addUpdateCallback(this._callbackColor)\r\n const stateset = this.getOrCreateStateSet()\r\n stateset.setAttributeAndModes(GLState.DEPTH_LEQUAL_WRITE)\r\n stateset.setAttributeAndModes(GLState.BLEND_SUBSTRACTIVE)\r\n stateset.setRenderBinDetails(RenderDetail.GRID, 'RenderBin')\r\n stateset.addUniform(color)\r\n this._grid = osg.createGridGeometry(-1000, -1000, -5, 2000, 0, 0, 0, 2000, 0, 19, 19)\r\n //this._grid = osg.createGridGeometry(0, 0, -2, 600, 0, 0, 0, 600, 0, 60, 60)\r\n //this._grid = osg.createGridGeometry(-600, -600, -2, 1200, 0, 0, 0, 1200, 0, 119, 119)\r\n this._axis = osg.createAxisGeometry(100)\r\n this._plane = osg.createTexturedQuadGeometry(-600, -600, -1, 1200, 0, 0, 0, 1200, 0)\r\n this.addChild(this._grid)\r\n this.addChild(this._axis)\r\n this.addChild(this._plane)\r\n\r\n\r\n /*\r\n e.setRenderBinDetails(TRANSPARENT_NO_EARLYZ_PRE, 'RenderBin')\r\n e.setAttributeAndModes(DEPTH_DISABLE)\r\n e.setAttributeAndModes(CULL_BACK)\r\n */\r\n\r\n\r\n this._grid\r\n .getOrCreateStateSet()\r\n .setAttributeAndModes(ShaderMaker.getOrCreateShader(GridVertexShader, GridFragShader, 'orientation-grid', 'Grid'))\r\n this._axis\r\n .getOrCreateStateSet()\r\n .setAttributeAndModes(\r\n ShaderMaker.getOrCreateShader(AxisVertexShader, AxisFragShader, 'orientation-axis', 'OrientationAxis')\r\n )\r\n\r\n this._invalidateNodeBound(this._grid)\r\n this._invalidateNodeBound(this._axis)\r\n this._invalidateNodeBound(this)\r\n this.setEnable(false)\r\n }\r\n\r\n \r\n\r\n setEnable(value) {\r\n if (value) {\r\n\r\n if(!this._texture) {\r\n this._texture = new osg.Texture()\r\n this._texture.setName('TextureGrid')\r\n const GridTextureImage = new Image();\r\n GridTextureImage.crossOrigin = \"Anonymous\";\r\n GridTextureImage.src = GridImage\r\n \r\n GridTextureImage.onload = function() {\r\n this._texture.setImage(GridTextureImage);\r\n this._texture.setTextureSize(GridTextureImage.width, GridTextureImage.height)\r\n this._texture.setMinFilter(osg.Texture.LINEAR_MIPMAP_LINEAR)\r\n this._texture.setMagFilter(osg.Texture.LINEAR)\r\n //this._texture.dirtyMipmap()\r\n }.bind(this)\r\n \r\n \r\n const texturePlaneSS = this._plane.getOrCreateStateSet();\r\n texturePlaneSS.addUniform(osg.Uniform.createInt(1, \"uTexture\"))\r\n texturePlaneSS.setTextureAttributeAndModes(1, this._texture);\r\n //texturePlaneSS.setRenderingHint('TRANSPARENT_BIN');\r\n texturePlaneSS.setAttributeAndModes(ShaderMaker.getOrCreateShader(TextureVertexShader, TextureFragSHader, 'textured-plane', 'TexturePLane'))\r\n }\r\n \r\n this.setNodeMask(PickMask.NO_PICK_NO_SHADOW)\r\n } else {\r\n this.setNodeMask(0)\r\n //this._invalidateNodeBound(this._grid)\r\n //this._invalidateNodeBound(this._axis)\r\n //this._invalidateNodeBound(this) \r\n }\r\n\r\n }\r\n\r\n _invalidateNodeBound(node) {\r\n node.dirtyBound()\r\n node.getBoundingBox().init()\r\n node.getBoundingSphere().init()\r\n }\r\n\r\n}","import RenderDetail from './RenderDetail';\r\nimport GLState from './GLState';\r\nimport osg from '../osg/osg';\r\nimport PickMask from './PickMask';\r\nimport NodeGizmo from './NodeGizmo';\r\nimport BoundingComputer from './BoundingComputer';\r\nimport WorldGrid from './WorldGrid';\r\nimport Config from './Config'\r\nexport default class FeatureManager {\r\n constructor(app) {\r\n this._app = app;\r\n this._viewerOSGJS = app.getViewerOSGJS();\r\n this._urlOptions = app.options || {};\r\n this._features = app.getFeatures();\r\n // this._context = context;\r\n this._canvas = app.getCanvas();\r\n this._nodeGizmo = null;\r\n this._nodeGrid = null;\r\n //(0,Ze.gN)(this)\r\n }\r\n\r\n getFeatures() {\r\n return this._features;\r\n }\r\n\r\n getCanvas() {\r\n return this._canvas;\r\n }\r\n\r\n getApp() {\r\n return this._app;\r\n }\r\n\r\n getViewerOSGJS() {\r\n return this._viewerOSGJS;\r\n }\r\n\r\n getRootModel() {\r\n return this._app.getRootModel();\r\n }\r\n\r\n getWorldNode() {\r\n return this._features.autospin.getNode();\r\n }\r\n\r\n getTextureDepth() {\r\n return this._features.postProcess.getCamera()._textureDepth;\r\n }\r\n\r\n getViewport3d() {\r\n return this._features.postProcess.getCamera().getViewport();\r\n }\r\n\r\n getPixelRatio() {\r\n var canvas = this._app._canvas;\r\n var ratioX = canvas.width / canvas.clientWidth;\r\n var ratioY = canvas.height / canvas.clientHeight;\r\n return [ratioX, ratioY]\r\n }\r\n\r\n getIconScaleFov(projection) {\r\n projection || (projection = this._viewerOSGJS.getCamera().getProjectionMatrix());\r\n const projectioN = Math.sqrt(\r\n projection[0] * projection[0] + projection[4] * projection[4] + projection[8] * projection[8],\r\n );\r\n return (0.02 * this.getViewport3d().width() * projectioN) / this.getPixelRatio()[0];\r\n }\r\n\r\n getResourceManager() {\r\n return this._resourceManager || ResourceManager.instance;\r\n }\r\n\r\n getCurrentTabName() {\r\n if (this._urlOptions.widgetAPI) return this._urlOptions.widgetAPI.getTabbedWidget().get();\r\n }\r\n\r\n getTargetAndEyeFocusFromBound() { }\r\n\r\n focusOnBound() { }\r\n\r\n focusOnTargetAndEye() { }\r\n\r\n focusOnHomePosition(duration) {\r\n var cameraFeature = this._features.camera;\r\n if (cameraFeature && cameraFeature.getModel()) {\r\n var manipulator = cameraFeature.getManipulator().getCurrentManipulator(),\r\n boundingSphere = manipulator.getHomeBoundingSphere(),\r\n center = boundingSphere.center(),\r\n eyePos = manipulator.getEyePosition(osg.vec3.create());\r\n osg.vec3.sub(eyePos, center, eyePos),\r\n osg.vec3.normalize(eyePos, eyePos),\r\n osg.vec3.scale(eyePos, eyePos, manipulator.getHomeDistance(boundingSphere)),\r\n osg.vec3.sub(eyePos, center, eyePos),\r\n this.focusOnTargetAndEye(center, eyePos, duration);\r\n }\r\n }\r\n\r\n focusOnSavedCamera(e) { }\r\n\r\n updateFocusOnAutoHit() { }\r\n\r\n setInitialAnimation() { }\r\n\r\n focusOnHit(e, t, i) { }\r\n\r\n _focusDof(e, t) { }\r\n\r\n onSingleClick(e) { }\r\n\r\n _singleClickOnInspector(e) { }\r\n\r\n onDoubleClick(e) { }\r\n\r\n preloadMaxBackground() { }\r\n\r\n applyAutospinToCamera(e, t) { }\r\n\r\n getCameraWithoutAutospin(e, t) { }\r\n\r\n enableGizmo(value) {\r\n if (this._nodeGizmo) {\r\n this._nodeGizmo.setTraversalMask(value ? PickMask.PICK : 0);\r\n }\r\n }\r\n\r\n enableGrid(value) {\r\n if (this._nodeGrid) {\r\n this._nodeGrid.setEnable(value)\r\n }\r\n }\r\n\r\n createWorldGrid() {\r\n this._nodeGrid = new WorldGrid();\r\n this._nodeGrid.setName('WorldGrid');\r\n return this._nodeGrid;\r\n }\r\n\r\n createGizmoNode() {\r\n var camera = new osg.Camera();\r\n camera.setName('Camera-Gizmo');\r\n camera.getOrCreateStateSet().setRenderBinDetails(RenderDetail.EDITOR_GIZMO, 'RenderBin');\r\n let nodeGizmo = (this._nodeGizmo = new NodeGizmo(this._app));\r\n nodeGizmo.setTraversalMask(PickMask.PICK_GIZMO_LIGHT);\r\n camera.addChild(nodeGizmo);\r\n //nodeGizmo.setNodeMask(1)\r\n nodeGizmo.attachToNode(null);\r\n // nodeGizmo.setAutoMatrixTransformInsertion(true);\r\n // nodeGizmo.setCorrectPivotOnAutoInsert(true);\r\n // nodeGizmo.setTraversalMask(0);\r\n return camera;\r\n }\r\n\r\n setManipulatorNode(node) {\r\n this._features.camera\r\n ? this._features.camera.getModel().set('node', node)\r\n : this._viewerOSGJS.getManipulator().setNode(node);\r\n }\r\n\r\n getNodeGizmo() {\r\n return this._nodeGizmo;\r\n }\r\n\r\n getNodeGrid() {\r\n return this._nodeGrid;\r\n }\r\n\r\n getBoundingSphere() {\r\n return this._boundingSphere\r\n }\r\n\r\n initializePreciseBoundManager(rootModel) {\r\n let bc = new BoundingComputer();\r\n bc.computePreciseBox(rootModel);\r\n var modelBoxWithDisp = bc.getModelBoxWithDisplacement();\r\n rootModel.getBoundingBox().copy(modelBoxWithDisp);\r\n var boundingSphere = rootModel.getBoundingSphere();\r\n boundingSphere.set(modelBoxWithDisp.center(boundingSphere.center()), modelBoxWithDisp.radius());\r\n this._boundingSphere = boundingSphere\r\n //ne.Z.init(this._context, this.getRootModel())\r\n return;\r\n }\r\n\r\n initGraph(modelroot) {\r\n let features = this._features;\r\n let node = new osg.Node();\r\n node.getOrCreateStateSet().setAttributeAndModes(GLState.CULL_DISABLE),\r\n node.setName('FeatureManager - Root');\r\n //i.addChild(MaterialPacker), MaterialPacker\r\n //initReadyForHighResBound();\r\n let orientation = features.orientation,\r\n autospin = features.autospin,\r\n outline = features.outline,\r\n ground = features.ground,\r\n environment = features.environment,\r\n lighting = features.lighting,\r\n camera = features.camera,\r\n sound = features.sound,\r\n hotspot = features.hotspot,\r\n postprocess = features.postProcess,\r\n webvr = features.webVR,\r\n arkit = features.ARKit,\r\n inspector = features.inspector,\r\n lightShadowNode = lighting.getNodeShadow(),\r\n rootNode = node;\r\n\r\n if (postprocess) {\r\n node.addChild(postprocess.getNodeIn());\r\n rootNode = postprocess.getNodeOut();\r\n }\r\n rootNode.addChild(this.createGizmoNode());\r\n rootNode.addChild(this.createWorldGrid())\r\n rootNode.addChild(lightShadowNode);\r\n rootNode = lightShadowNode;\r\n features = [\r\n camera,\r\n environment,\r\n lighting,\r\n sound,\r\n webvr,\r\n hotspot,\r\n inspector,\r\n outline,\r\n autospin,\r\n arkit,\r\n ground,\r\n orientation,\r\n ];\r\n for (let idx = 0; idx < features.length; ++idx) {\r\n const feature = features[idx];\r\n if (feature) {\r\n const nodein = feature.getNodeIn ? feature.getNodeIn() : feature.getNode(),\r\n nodeout = feature.getNodeOut ? feature.getNodeOut() : feature.getNode();\r\n rootNode.addChild(nodein), (rootNode = nodeout);\r\n }\r\n }\r\n rootNode.addChild(modelroot);\r\n return node;\r\n }\r\n\r\n addGlobalUniforms() {\r\n var stateset = this._features.postProcess.getNodeIn().getOrCreateStateSet();\r\n for (var key in this._app.globalUniform) stateset.addUniform(this._app.globalUniform[key]);\r\n }\r\n\r\n finished(rootScene) {\r\n const features = this._features;\r\n const rootModel = this.getRootModel();\r\n rootModel.setNodeMask(PickMask.PICK_GEOMETRY_SHADOW);\r\n rootModel.setName('Scene - RootModel');\r\n //rootModel.addChild(this.createWorldGrid());\r\n //this.getNodeGrid().enable()\r\n this._app.nodeRootModel = rootModel;\r\n\r\n let camera = this._viewerOSGJS.getCamera();\r\n //Be.Z.setCamera(n),\r\n ///i.addUpdateCallback(Be.Z);\r\n let featuerRoot = this.initGraph(rootModel);\r\n rootScene.addChild(featuerRoot);\r\n // this.setManipulatorNode(this._features.orientation.getNode()),\r\n this.preloadMaxBackground();\r\n let lightingFeature = features.lighting; \r\n //lightingFeature && lightingFeature.getModel().initLights(t.material.getSceneLights());\r\n var environmentFeature = features.environment;\r\n if (environmentFeature) {\r\n environmentFeature.getNode().init(camera ,lightingFeature.getNodeShadow());\r\n }\r\n this._app._canvasPixelRatio.init(this._canvas, this._viewerOSGJS.getCanvasPixelRatio());\r\n //De.Z.init(this._canvas, this._features.quality.getModel(), this._viewerOSGJS.getCanvasPixelRatio()),\r\n\r\n this.focusOnSavedCamera();\r\n this._features.camera && this._features.camera.getModel().saveCameraPosition();\r\n\r\n this._app._featureEventManager.initGlobalClickEvents(this, this._canvas);\r\n this._viewerOSGJS.getInputManager().setEnable('global_click_events', !0);\r\n //i.getOrCreateStateSet().setAttribute(new re.Z) // vertexCompression\r\n\r\n this.addGlobalUniforms();\r\n //osg.time('drawFirstFrame')\r\n this._app.drawFrame();\r\n //osg.timeEnd('drawFirstFrame')\r\n this.initializePreciseBoundManager(rootModel);\r\n\r\n //features.webVR && features.webVR.getModel().initAfterFirstFrame();\r\n //features.postProcess && features.postProcess.getModel().initAfterFirstFrame();\r\n //features.camera && features.camera.getModel().initAfterFirstFrame();\r\n features.lighting && features.lighting.getModel().set(\"forceShadowRedraw\", !0);\r\n\r\n //osg.time('drawSecondFrame')\r\n this._app.drawFrame();\r\n //osg.timeEnd('drawSecondFrame')\r\n\r\n features.lighting && features.lighting.getModel().set(\"forceShadowRedraw\", !1),\r\n window.addEventListener('beforeunload', this.onBeforeUnload.bind(this)),\r\n false &&\r\n featuerRoot.addUpdateCallback({\r\n update: this.updateFocusOnAutoHit.bind(this),\r\n });\r\n return featuerRoot;\r\n }\r\n\r\n _registerCollection() { }\r\n\r\n registerOptionsJSON() { }\r\n\r\n getUnsavedChanges() { }\r\n\r\n getUnsavedMessage() { }\r\n\r\n onBeforeUnload() { }\r\n\r\n _hashChanged() { }\r\n\r\n getShadowForcedUpdate() {\r\n if(Config.shadow) {\r\n return !!this._app._frameManager.getShadowForcedUpdate() ||\r\n !!this._app.getSuperSample().isEnabled() ||\r\n !!this._features.lighting.getModel().get('forceShadowRedraw') \r\n // ||\r\n // !!this._features.autospin.getModel().get('enable') ||\r\n // !!this._features.animation.getModel().isPlaying()\r\n }\r\n return false\r\n \r\n }\r\n}\r\n","import osg from '../osg/osg';\r\nexport default {\r\n '三点光源': [\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n -0.9815804500275482,\r\n 0.1909922167095499,\r\n -0.004668327333101102,\r\n 0,\r\n -0.13044442805044293,\r\n -0.6878553985005321,\r\n -0.7140302528214524,\r\n 0,\r\n -0.13958535494209104,\r\n -0.7002691796088462,\r\n 0.700099282084794,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(\r\n 1,\r\n 1,\r\n 1\r\n ),\r\n intensity: 1\r\n },\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n 0.7755211495104662,\r\n -0.0666602860002539,\r\n 0.6277924441503967,\r\n 0,\r\n 0.2690483737361956,\r\n 0.9344846523281437,\r\n -0.233133882464682,\r\n 0,\r\n -0.5711216326246741,\r\n 0.3497067926613838,\r\n 0.7426474533145686,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(\r\n 1,\r\n 1,\r\n 1\r\n ),\r\n intensity: 1\r\n },\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n 0.6903299131022926,\r\n -0.7076363669144057,\r\n -0.15064986988498263,\r\n 0,\r\n -0.011089698239978026,\r\n 0.19785137301620165,\r\n -0.9801692980238416,\r\n 0,\r\n 0.7234097246160907,\r\n 0.6783108479272498,\r\n 0.12873524736872857,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(1, 1, 1),\r\n intensity: 1\r\n }\r\n ],\r\n\r\n '三点顶部': [\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n 0.9997395789367833,\r\n 0.0037284998571004493,\r\n -0.02251383121813605,\r\n 0,\r\n -0.003172416108909601,\r\n 0.9996902441347245,\r\n 0.024685047253076783,\r\n 0,\r\n 0.02259889562202194,\r\n -0.024607195505995896,\r\n 0.9994417320914686,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(\r\n 1,\r\n 1,\r\n 1\r\n ),\r\n intensity: 1\r\n },\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n -0.03668489915909917,\r\n 0.6173399031571284,\r\n -0.7858407358642296,\r\n 0,\r\n -0.3405482968780687,\r\n -0.7470238271733634,\r\n -0.5709485608430127,\r\n 0,\r\n -0.9395110833125567,\r\n 0.24667153383641294,\r\n 0.23763854638433113,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(\r\n 1,\r\n 1,\r\n 1\r\n ),\r\n intensity: 1\r\n },\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n 0.5165535747993983,\r\n -0.2459126458378022,\r\n -0.8201825254045677,\r\n 0,\r\n -0.40819067915319995,\r\n 0.771302442076031,\r\n -0.48833688402577136,\r\n 0,\r\n 0.7526970000035951,\r\n 0.5870430252243886,\r\n 0.29803978378898704,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(1, 1, 1),\r\n intensity: 1\r\n }\r\n ],\r\n\r\n\r\n '两侧光源': [\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n Math.SQRT1_2,\r\n 0,\r\n Math.SQRT1_2,\r\n 0,\r\n -0,\r\n 1,\r\n 0,\r\n 0,\r\n -Math.SQRT1_2,\r\n -0,\r\n Math.SQRT1_2,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(1,1,1),\r\n intensity: 1\r\n },\r\n {\r\n enable: true,\r\n type: 'DIRECTION',\r\n matrix: osg.mat4.fromValues(\r\n Math.SQRT1_2,\r\n 0,\r\n -Math.SQRT1_2,\r\n 0,\r\n 0,\r\n 1,\r\n 0,\r\n 0,\r\n Math.SQRT1_2,\r\n 0,\r\n Math.SQRT1_2,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(1, 1, 1),\r\n intensity: 1\r\n },\r\n { type: 'NONE', enable: true }\r\n ],\r\n\r\n '头顶光': [\r\n {\r\n type: 'DIRECTION',\r\n enable: true,\r\n matrix: osg.mat4.fromValues(\r\n 0.9997395789367833,\r\n 0.0037284998571004493,\r\n -0.02251383121813605,\r\n 0,\r\n -0.003172416108909601,\r\n 0.9996902441347245,\r\n 0.024685047253076783,\r\n 0,\r\n 0.02259889562202194,\r\n -0.024607195505995896,\r\n 0.9994417320914686,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 1\r\n ),\r\n color: osg.vec3.fromValues(1, 1, 1),\r\n intensity: 1\r\n },\r\n { type: 'NONE', enable: true },\r\n { type: 'NONE', enable: true }\r\n ]\r\n\r\n}","import osg from '../osg/osg';\r\nimport GLState from './GLState';\r\nimport ShaderMaker from './ShaderMaker';\r\n\r\nconst vert= '#ifdef ICON\\nattribute vec2 TexCoord0;\\nvarying vec2 vTexCoord0;\\n#endif\\n\\n#ifdef HEMI\\nvarying vec3 vLocalVertex;\\n#endif\\n\\nattribute vec3 Vertex;\\n\\nvarying vec4 vViewPos;\\n\\nuniform mat4 uModelViewMatrix;\\nuniform mat4 uProjectionMatrix;\\n\\nvoid main(void) {\\n#ifdef ICON\\n vTexCoord0 = TexCoord0;\\n#endif\\n\\n#ifdef HEMI\\n vLocalVertex = Vertex;\\n#endif\\n\\n vViewPos = uModelViewMatrix * vec4(Vertex.xyz, 1.0);\\n gl_Position = uProjectionMatrix * vViewPos;\\n}\\n'\r\nconst frag = '#pragma include \"utils/functions.glsl\"\\n#pragma include \"utils/decodeDepth.glsl\"\\n\\n#ifdef HEMI\\nuniform vec4 uGround;\\nvarying vec3 vLocalVertex;\\nuniform float uRadius;\\n#endif\\n\\n#ifdef ICON\\nuniform sampler2D uTextureIcon;\\nvarying vec2 vTexCoord0;\\nuniform int uEnable;\\n#endif\\n\\nvarying vec4 vViewPos;\\nuniform vec2 uNearFar;\\nuniform sampler2D uTextureDepth;\\nuniform vec2 uGlobalTexSize;\\nuniform vec2 uGlobalTexRatio;\\n\\nuniform vec4 uColor;\\n\\nvoid main(void) {\\n float distDepth = distanceToDepth(uTextureDepth, uGlobalTexRatio * gl_FragCoord.xy / uGlobalTexSize, vViewPos, uNearFar);\\n float alpha = distDepth < 0.0 ? 1.0 : 0.1;\\n\\n // handles colors with values higher than 1\\n vec3 normColor = uColor.rgb / max(max(1.0, uColor.r), max(uColor.g, uColor.b));\\n\\n#ifdef HEMI\\n gl_FragColor = vec4(mix(uGround.rgb, normColor, vLocalVertex.z / uRadius), alpha);\\n#endif\\n\\n#ifdef LINE\\n gl_FragColor = vec4(normColor, alpha);\\n#endif\\n\\n#ifdef ICON\\n gl_FragColor = vec4(float(uEnable) * normColor, alpha) * texture2D(uTextureIcon, vTexCoord0);\\n#endif\\n\\n gl_FragColor.rgb *= gl_FragColor.a;\\n\\n gl_FragColor.rgb = sRGBToLinear(gl_FragColor.rgb);\\n}\\n'\r\nexport default {\r\n\r\n \r\n createIconGeometry: function(texture) {\r\n var geom = osg.createTexturedQuadGeometry(-0.5, -0.5, 0, 1, 0, 0, 0, 1, 0)\r\n var stateset = geom.getOrCreateStateSet();\r\n stateset.setTextureAttributeAndModes(1, texture)\r\n stateset.addUniform(osg.Uniform.createInt(1, 'uTextureIcon'))\r\n stateset.setAttributeAndModes(GLState.BLEND_SUBSTRACTIVE)\r\n var shader = ShaderMaker.getOrCreateShader(vert, frag, 'icon', 'LightingIcon', 'ICON')\r\n stateset.setAttributeAndModes(shader)\r\n geom.setLightType = function(type) {\r\n stateset.setTextureAttributeAndModes(1, texture);\r\n }\r\n return geom;\r\n },\r\n createDirectionalGeometry: function(direction) {\r\n for (\r\n var t = void 0 === direction ? -1 : -direction,\r\n i = t / 15,\r\n n = 2 * Math.PI,\r\n data = new Float32Array(180),\r\n a = 0; a < 5;\r\n ++a\r\n ) {\r\n var o = 6 * a,\r\n s = (n * a) / 5;\r\n (data[o] = data[o + 3] = Math.cos(s) * i),\r\n (data[o + 1] = data[o + 4] = Math.sin(s) * i),\r\n (data[o + 5] = t);\r\n }\r\n var arrayBuffer = new osg.DrawArrays(osg.primitiveSet.LINES, 0, 30)\r\n var geom = new osg.Geometry();\r\n geom.getAttributes().Vertex = new osg.BufferArray(\r\n osg.BufferArray.ARRAY_BUFFER,\r\n data,\r\n 3,\r\n )\r\n geom.getPrimitives().push(arrayBuffer)\r\n\r\n geom.getOrCreateStateSet().setAttributeAndModes(ShaderMaker.getOrCreateShader(vert, frag, 'line', 'LightingLineGizmo', 'LINE'))\r\n geom.getOrCreateStateSet().setAttributeAndModes(GLState.BLEND_SUBSTRACTIVE)\r\n return geom\r\n },\r\n createSpotGeometry: function(e) {\r\n var t = void 0 === e ? -1 : -e,\r\n i = 50,\r\n n = 2 * Math.PI,\r\n r = new osg.Geometry(),\r\n a = new Float32Array(300),\r\n o = (r.getAttributes().Vertex = new osg.BufferArray(\r\n osg.BufferArray.ARRAY_BUFFER,\r\n a,\r\n 3,\r\n )),\r\n s = 0,\r\n u = new Uint16Array(i);\r\n for (s = 0; s < i; ++s) u[s] = 2 * s + 1;\r\n var l = new osg.DrawElements(\r\n osg.primitiveSet.LINE_LOOP,\r\n new osg.BufferArray(osg.BufferArray.ELEMENT_ARRAY_BUFFER, u, 1),\r\n ),\r\n h = new Uint16Array(10);\r\n for (s = 0; s < 5; ++s)(h[2 * s] = 20 * s), (h[2 * s + 1] = 20 * s + 1);\r\n var c = new osg.DrawElements(\r\n osg.primitiveSet.LINES,\r\n new osg.BufferArray(osg.BufferArray.ELEMENT_ARRAY_BUFFER, h, 1),\r\n );\r\n return (\r\n r.getPrimitives().push(c, l),\r\n r.getOrCreateStateSet().setAttributeAndModes(za()),\r\n r.getOrCreateStateSet().setAttributeAndModes(ja),\r\n (r.updateCone = function(e, u) {\r\n var l = u ? 2 * -u : t,\r\n h = Math.cos(e) * l,\r\n c = Math.sin(e) * l;\r\n for (s = 0; s < i; ++s) {\r\n var d = 6 * s,\r\n f = (n * s) / i;\r\n (a[d + 3] = Math.cos(f) * c),\r\n (a[d + 4] = Math.sin(f) * c),\r\n (a[d + 5] = h);\r\n }\r\n o.dirty(), r.dirtyBound();\r\n }),\r\n r.updateCone(0.1),\r\n r\r\n );\r\n },\r\n createHemiGeometry: function(e) {\r\n for (\r\n var t = void 0 === e ? -1 : -e,\r\n i = 50,\r\n n = new osg.Geometry(),\r\n r = new Float32Array(450),\r\n a = Math.PI,\r\n o = 150,\r\n s = 0; s < i;\r\n ++s\r\n ) {\r\n var u = 3 * s,\r\n l = (a * s) / 49,\r\n h = Math.cos(l),\r\n c = Math.sin(l);\r\n (r[u] = h * t),\r\n (r[u + 2] = -c * t),\r\n (r[o + u + 1] = h * t),\r\n (r[o + u + 2] = -c * t),\r\n (l = (2 * a * s) / 49),\r\n (r[300 + u] = Math.cos(l) * t),\r\n (r[300 + u + 1] = Math.sin(l) * t);\r\n }\r\n n.getAttributes().Vertex = new osg.BufferArray(\r\n osg.BufferArray.ARRAY_BUFFER,\r\n r,\r\n 3,\r\n );\r\n var d = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, 0, i),\r\n f = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, i, i),\r\n g = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, 100, i);\r\n n.getPrimitives().push(d, f, g);\r\n var p = n.getOrCreateStateSet();\r\n return (\r\n p.setAttributeAndModes(Ha('HEMI', 'LightingHemiGizmo')),\r\n p.setAttributeAndModes(ja),\r\n p.addUniform(osg.Uniform.createFloat(-t, 'uRadius')),\r\n n\r\n );\r\n },\r\n createPointGeometry: function() {\r\n var e = 2 * Math.PI,\r\n t = 50,\r\n i = new osg.Geometry(),\r\n n = new Float32Array(1350),\r\n r = (i.getAttributes().Vertex = new osg.BufferArray(\r\n osg.BufferArray.ARRAY_BUFFER,\r\n n,\r\n 3,\r\n )),\r\n a = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, 0, t),\r\n o = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, t, t),\r\n s = new osg.DrawArrays(osg.primitiveSet.LINE_STRIP, 100, t);\r\n return (\r\n i.getPrimitives().push(a, o, s),\r\n i.getOrCreateStateSet().setAttributeAndModes(za()),\r\n i.getOrCreateStateSet().setAttributeAndModes(ja),\r\n (i.updateRadius = function(a) {\r\n for (var o = 0; o < t; ++o) {\r\n var s = 3 * o,\r\n u = (e * o) / 49;\r\n (n[s] = n[150 + s] = n[300 + s + 1] = Math.cos(u) * a),\r\n (n[s + 1] = n[150 + s + 2] = n[300 + s + 2] = Math.sin(u) * a);\r\n }\r\n r.dirty(), i.dirtyBound();\r\n }),\r\n i.updateRadius(1),\r\n i\r\n );\r\n },\r\n};","import osg from '../osg/osg';\r\n\r\nconst dummyTexture = new osg.Texture()\r\ndummyTexture.setTextureSize(1, 1)\r\n\r\nexport default dummyTexture\r\n","import P from 'bluebird';\r\nconst CreatePromise = () => {\r\n var wrapper = {};\r\n var promise = new P(function (resolve, reject) {\r\n (wrapper.resolve = resolve), (wrapper.reject = reject);\r\n });\r\n promise.resolve = wrapper.resolve;\r\n promise.reject = wrapper.reject;\r\n promise.promise = promise;\r\n return promise;\r\n};\r\n\r\nexport default CreatePromise;\r\n","import osg from '../osg/osg';\r\n\r\nclass TextureCubeMap extends osg.TextureCubeMap {\r\n constructor() {\r\n super();\r\n this._imageProxy = undefined;\r\n }\r\n getHash() {\r\n return 'osgCustomTexture';\r\n }\r\n}\r\n\r\nTextureCubeMap.dummyTexture = new osg.TextureCubeMap();\r\nTextureCubeMap.dummyTexture.setTextureSize(1, 1);\r\n\r\nexport default TextureCubeMap;\r\n","import CreatePromise from './CreatePromise'\r\nimport fileHelper from \"../osgDB/fileHelper\";\r\nimport osg from \"../osg/osg\";\r\nimport TextureCubeMap from './TextureCubeMap';\r\nvar ResourceManagerInstance = null\r\n\r\nexport default class ResourceManager {\r\n\r\n constructor() {\r\n this._cache = {}\r\n this._enableCache = true\r\n }\r\n\r\n\r\n\r\n static getInstance() {\r\n if (ResourceManagerInstance === null) {\r\n ResourceManagerInstance = new ResourceManager()\r\n }\r\n return ResourceManagerInstance\r\n\r\n }\r\n\r\n // static arrayBuffer2Image(arraybuffer) {\r\n // let promise = CreatePromise()\r\n // let blob = new Blob([arraybuffer])\r\n // let domImage = new Image()\r\n // domImage.src = window.URL.createObjectURL(blob)\r\n // domImage.onload = function () {\r\n // promise.resolve(domImage)\r\n // if (window.URL.revokeObjectURL) window.URL.revokeObjectURL(domImage.src)\r\n // }\r\n // return promise\r\n // }\r\n\r\n static getSortedKeyValueString(parameters) {\r\n\r\n var notEmptyParameters = [];\r\n\r\n for (var n in parameters) {\r\n\r\n var option = parameters[n];\r\n\r\n if (option) notEmptyParameters.push(n);\r\n\r\n }\r\n\r\n notEmptyParameters.sort();\r\n\r\n var str = '';\r\n\r\n for (var i = 0; i < notEmptyParameters.length; i++) {\r\n\r\n n = notEmptyParameters[i];\r\n str += (n + parameters[n]);\r\n\r\n }\r\n\r\n return str;\r\n\r\n }\r\n\r\n setCache(enable) {\r\n this._enableCache = enable\r\n }\r\n\r\n createTextureFromColor(colorArg, srgb, textureOutput) {\r\n \r\n let id = ''\r\n if (typeof colorArg === 'number') {\r\n id = '' + colorArg;\r\n }\r\n if (typeof colorArg === 'object') {\r\n id = colorArg.reduce((pre, value)=>{\r\n return pre+value\r\n }, id)\r\n }\r\n id += srgb\r\n if(this._enableCache) {\r\n var cache = this._cache[id]\r\n if (cache) return cache.texture\r\n }\r\n \r\n let colorInput = colorArg;\r\n let albedo = new osg.Uint8Array(4);\r\n\r\n if (typeof colorInput === 'number') {\r\n colorInput = [colorInput];\r\n }\r\n let color = colorInput.slice(0);\r\n\r\n if (color.length === 3) color.push(1.0);\r\n\r\n if (color.length === 1) {\r\n color.push(color[0]);\r\n color.push(color[0]);\r\n color.push(1.0);\r\n }\r\n\r\n color.forEach(function(value, index) {\r\n if (srgb) albedo[index] = Math.floor(255 * linear2Srgb(value));\r\n else albedo[index] = Math.floor(255 * value);\r\n });\r\n\r\n let texture = textureOutput;\r\n if (!texture) texture = new osg.Texture();\r\n texture.setTextureSize(1, 1);\r\n texture.setImage(albedo);\r\n if(this._enableCache) {\r\n this._cache[id] = {texture}\r\n }\r\n \r\n return texture;\r\n }\r\n\r\n dirty(){\r\n\r\n this._cache = {}\r\n\r\n }\r\n\r\n setOptions(option, texture) {\r\n texture.setMinFilter(option.minFilter);\r\n texture.setMagFilter(option.magFilter);\r\n texture.setWrapT(option.wrapT);\r\n texture.setWrapS(option.wrapS);\r\n if (\r\n option.minFilter === osg.Texture.LINEAR_MIPMAP_LINEAR &&\r\n option.anisotropy\r\n )\r\n texture.setMaxAnisotropy(16);\r\n texture.setInternalFormat(option.internalFormat);\r\n }\r\n\r\n loadImage(file, option) {\r\n if (option.panoramaLUV || option.integrateBRDFLUV) {\r\n return this.loadLUV(file, option);\r\n } else if (option.cubemapLUV) {\r\n return this.loadCubemapLUV(file, option);\r\n } else {\r\n let osgjsImage = new osg.Image();\r\n let htmlImage = new Image()\r\n let promise = CreatePromise();\r\n \r\n htmlImage.crossOrigin = 'anonymous'\r\n htmlImage.addEventListener('load', ()=>{\r\n promise.resolve(osgjsImage)\r\n })\r\n htmlImage.onerror = ()=>{\r\n promise.reject(osgjsImage)\r\n }\r\n htmlImage.src = file\r\n osgjsImage.setImage(htmlImage)\r\n return promise\r\n }\r\n }\r\n\r\n loadLUV(file, option) {\r\n return fileHelper\r\n .requestURI(file, {\r\n responseType: 'arraybuffer',\r\n })\r\n .then((data) => {\r\n var imageData,\r\n size = Math.sqrt(data.byteLength / 4);\r\n\r\n if (option.integrateBRDFLUV) {\r\n imageData = new Uint8Array(data);\r\n } else {\r\n imageData = this.deinterleaveImage4(\r\n size,\r\n new Uint8Array(data),\r\n new Uint8Array(data.byteLength),\r\n );\r\n }\r\n\r\n var image = new osg.Image();\r\n\r\n image.setImage(imageData), image.setWidth(size);\r\n image.setHeight(size);\r\n let promise = CreatePromise();\r\n promise.resolve(image);\r\n return promise;\r\n });\r\n }\r\n loadCubemapLUV(file, option) {\r\n return fileHelper\r\n .requestURI(file, {\r\n responseType: 'arraybuffer',\r\n })\r\n .then((data) => {\r\n var maxPower = Math.log(option.size) / Math.LN2;\r\n var offset = 0;\r\n var images = {};\r\n\r\n for (\r\n var power = 0;\r\n power <= maxPower && !(offset >= data.byteLength);\r\n power++\r\n ) {\r\n for (\r\n var size = Math.pow(2, maxPower - power), face = 0;\r\n face < 6;\r\n face++\r\n ) {\r\n if (!images[osg.Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face])\r\n images[osg.Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face] = [];\r\n var byteSize = size * size * 4;\r\n var newData = new Uint8Array(byteSize);\r\n this.deinterleaveImage4(\r\n size,\r\n new Uint8Array(data, offset, byteSize),\r\n newData,\r\n );\r\n var image = new osg.Image();\r\n image.setImage(newData);\r\n image.setWidth(size);\r\n image.setHeight(size);\r\n images[osg.Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face].push(image);\r\n offset += byteSize;\r\n }\r\n }\r\n let promise = CreatePromise();\r\n promise.resolve(images);\r\n return promise;\r\n });\r\n }\r\n deinterleaveImage4(size, data, newData) {\r\n for (\r\n var n = size * size,\r\n r = 2 * size * size,\r\n a = 3 * size * size,\r\n o = 0,\r\n s = 0;\r\n s < n;\r\n s++\r\n )\r\n (newData[o++] = data[s]),\r\n (newData[o++] = data[s + n]),\r\n (newData[o++] = data[s + r]),\r\n (newData[o++] = data[s + a]);\r\n return newData;\r\n }\r\n\r\n getOrCreateTexture(file, option) {\r\n let id = file + ResourceManager.getSortedKeyValueString(option)\r\n if(this._enableCache) {\r\n var cache = this._cache[id]\r\n if (cache) return cache\r\n }\r\n var texture;\r\n if (option.cubemap) {\r\n texture = new TextureCubeMap();\r\n } else {\r\n texture = new osg.Texture();\r\n }\r\n texture.setTextureSize(1, 1);\r\n this.setOptions(option, texture);\r\n\r\n let promise = CreatePromise();\r\n\r\n this.loadImage(file, option).then((image) => {\r\n if (option.cubemap) {\r\n for (var face = 0; face < 6; face++) {\r\n var cubeFace = osg.Texture.TEXTURE_CUBE_MAP_POSITIVE_X + face;\r\n texture.setImage(cubeFace, image[cubeFace], 'RGBA');\r\n }\r\n promise.resolve(texture);\r\n } else {\r\n texture.setImage(image);\r\n // GlobalSetter.draw()\r\n promise.resolve(texture);\r\n }\r\n });\r\n\r\n let res = {\r\n promise,\r\n texture\r\n }\r\n if(this._enableCache) {\r\n this._cache[id] = res\r\n }\r\n \r\n return res\r\n }\r\n}\r\n","import utils from \"../osg/utils\";\r\n\r\nconst StateAtributeRegister = (\r\n constructor,\r\n prototype,\r\n libraryName,\r\n className,\r\n) => {\r\n prototype.attributeType = className;\r\n\r\n // createPrototypeStateAttribute\r\n utils.objectLibraryClass(prototype, libraryName, className);\r\n utils.setTypeID(constructor);\r\n prototype.attributeTypeId = utils.getOrCreateStateAttributeTypeId(constructor);\r\n};\r\n\r\nexport default StateAtributeRegister;\r\n","import osg from '../osg/osg';\r\nimport StateAtributeRegister from './StateAttributeRegister'\r\nclass EditorLight extends osg.Light {\r\n constructor(lightnum) {\r\n super(lightnum);\r\n }\r\n isDirectionLight() {\r\n return (\r\n 0 === this._position[3] &&\r\n (-1 === this._ground[3] || 0 === this._ground[3])\r\n );\r\n }\r\n}\r\n\r\nStateAtributeRegister(\r\n EditorLight,\r\n EditorLight.prototype,\r\n 'osgEditor',\r\n 'EditorLight',\r\n);\r\nEditorLight.DIRECTION = osg.Light.DIRECTION\r\nEditorLight.SPOT = osg.Light.SPOT\r\nEditorLight.POINT = osg.Light.POINT\r\nEditorLight.HEMI = osg.Light.HEMI\r\n\r\nconst tempvec3 = osg.vec3.create();\r\n\r\nosg.LightSource.prototype.computeBoundingSphere = function (boundingsphere) {\r\n osg.Node.prototype.computeBoundingSphere.call(this, boundingsphere);\r\n if (!boundingsphere.valid()) return boundingsphere;\r\n if (\r\n undefined !== this._light &&\r\n this._referenceFrame === osg.Transform.RELATIVE_RF\r\n ) {\r\n var pos = this._light.getPosition();\r\n if (pos[3] !== 0) {\r\n boundingsphere.expandByVec3(osg.vec3.scale(tempvec3, pos, 1 / pos[3]));\r\n }\r\n }\r\n return boundingsphere;\r\n};\r\n\r\nexport default EditorLight;\r\n","import utils from '../osg/utils';\r\nimport StateAttribute from '../osg/StateAttribute';\r\n\r\n// Used to notify the Compiler to create a Depth Casting optimized shader\r\nvar ShadowCastAttribute = function(disable, shadowReceiveAttribute) {\r\n StateAttribute.call(this);\r\n this._enable = !disable;\r\n this._shadowReceiveAttribute = shadowReceiveAttribute;\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n ShadowCastAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'ShadowCast',\r\n cloneType: function() {\r\n return new ShadowCastAttribute(true);\r\n },\r\n setReceiveAttribute: function(shadowReceiveAttribute) {\r\n this._shadowReceiveAttribute = shadowReceiveAttribute;\r\n },\r\n getReceiveAttribute: function() {\r\n return this._shadowReceiveAttribute;\r\n },\r\n getDefines: function() {\r\n return this._shadowReceiveAttribute.getDefines();\r\n },\r\n _computeInternalHash: function() {\r\n return 'ShadowCast' + this._enable + this._shadowReceiveAttribute.getPrecision();\r\n },\r\n getHash: function() {\r\n var receiveAttributeDirty = false;\r\n if (this._shadowReceiveAttribute && this._shadowReceiveAttribute._dirtyHash)\r\n this._receiveAttributeDirty = true;\r\n\r\n if (!this._dirtyHash && !receiveAttributeDirty) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n // need a isEnabled to let the ShaderGenerator to filter\r\n // StateAttribute from the shader compilation\r\n isEnabled: function() {\r\n return this._enable;\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowCastAttribute'\r\n);\r\n\r\nexport default ShadowCastAttribute;\r\n","import BlendFunc from '../osg/BlendFunc';\r\nimport Camera from '../osg/Camera';\r\nimport Depth from '../osg/Depth';\r\nimport Light from '../osg/Light';\r\nimport LightSource from '../osg/LightSource';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport utils from '../osg/utils';\r\n\r\n/*\r\n * Remove nodes that shouldn't not be culled when casting\r\n * like lights, camera with render texture targets,\r\n * transparent (alphablended) geometries\r\n * (otherwise it might break things)\r\n * visits whole underlying scene recursively\r\n */\r\nvar ShadowCasterVisitor = function(mask) {\r\n NodeVisitor.call(this);\r\n // mask setting to avoid casting shadows\r\n this._noCastMask = mask;\r\n this._nodeList = [];\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ShadowCasterVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function() {\r\n this._nodeList = [];\r\n },\r\n removeNodeFromCasting: function(node) {\r\n /*jshint bitwise: false */\r\n\r\n var nm = node.getNodeMask();\r\n // ~0x0 as not to be processed\r\n\r\n if (nm === ~0x0) {\r\n // set to avoid casting shadow\r\n nm = this._noCastMask;\r\n node.setNodeMask(nm);\r\n this._nodeList.push(node);\r\n } else if ((nm & ~this._noCastMask) !== 0) {\r\n // set to avoid casting shadow\r\n node.setNodeMask(nm | this._noCastMask);\r\n this._nodeList.push(node);\r\n }\r\n /*jshint bitwise: true */\r\n },\r\n // Visiting whole casting scene recursively\r\n apply: function(node) {\r\n // check that and other things ?\r\n // TODO: should check whole hierarchy to check for override/protected/etc\r\n // Depth, BlendFunc Attributes...\r\n var st = node.getStateSet();\r\n if (st) {\r\n // check for transparency not casting shadows\r\n // as no alpha blending transparency shadow (no transmittance support)\r\n var blend = st.getAttribute('BlendFunc');\r\n if (blend !== undefined && blend.getSource() !== BlendFunc.DISABLE) {\r\n var depth = st.getAttribute('Depth');\r\n if (\r\n depth &&\r\n (depth.getFunc() === Depth.DISABLE || depth.getWriteMask() === false)\r\n ) {\r\n this.removeNodeFromCasting(node);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n // check for lights, as lights are positionned attributes\r\n if (node.getTypeID() === Light.typeID || node.getTypeID() === LightSource.typeID) {\r\n this.removeNodeFromCasting(node);\r\n return;\r\n } else if (node.getTypeID() === Camera.typeID && node.isRenderToTextureCamera()) {\r\n // no \"Subrender\" when rendering the shadow map as from light point of view\r\n this.removeNodeFromCasting(node);\r\n return;\r\n }\r\n this.traverse(node);\r\n },\r\n\r\n setNoCastMask: function(mask) {\r\n this._noCastMask = mask;\r\n },\r\n\r\n // restore to any previous mask avoiding any breaks\r\n // in other application mask usage.\r\n restore: function() {\r\n for (var i = 0, l = this._nodeList.length; i < l; i++) {\r\n var node = this._nodeList[i];\r\n var nm = node.getNodeMask();\r\n\r\n if (nm === this._noCastMask) {\r\n node.setNodeMask(~0x0);\r\n } else {\r\n node.setNodeMask(nm & ~this._noCastMask);\r\n }\r\n }\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowCasterVisitor'\r\n);\r\n\r\nexport default ShadowCasterVisitor;\r\n","import BoundingBox from '../osg/BoundingBox';\r\nimport BoundingSphere from '../osg/BoundingSphere';\r\nimport Camera from '../osg/Camera';\r\nimport Geometry from '../osg/Geometry';\r\nimport Light from '../osg/Light';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport PooledResource from '../osg/PooledResource';\r\nimport PooledArray from '../osg/PooledArray';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport Plane from '../osg/Plane';\r\nimport utils from '../osg/utils';\r\n\r\n/**\r\n * [ComputeFrustumBoundsVisitor get a scene bounds limited by a light and camera frustum]\r\n */\r\nvar ComputeMultiFrustumBoundsVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n\r\n this._pooledMatrix = new PooledResource(mat4.create);\r\n\r\n this._matrixStack = new PooledArray();\r\n this._matrixStack.push(mat4.IDENTITY);\r\n\r\n this._bb = new BoundingBox();\r\n this._bs = new BoundingSphere();\r\n};\r\n\r\n/*\r\n * TODO: apply world matrix on the traverse instead of per node\r\n */\r\nutils.createPrototypeObject(\r\n ComputeMultiFrustumBoundsVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function(traversalMask, worldLightPos, cameraFrustum, cameraNearFar, lightFrustum) {\r\n this.setTraversalMask(traversalMask);\r\n\r\n this._cameraFrustum = cameraFrustum;\r\n this._lightFrustum = lightFrustum;\r\n\r\n // what plane to exclude from shadowedscene\r\n this.getCameraPlaneMaskForLightNear(\r\n worldLightPos,\r\n cameraFrustum,\r\n cameraNearFar ? 6 : 4\r\n );\r\n\r\n this._pooledMatrix.reset();\r\n this._matrixStack.reset();\r\n this._matrixStack.push(mat4.IDENTITY);\r\n this._bb.init();\r\n },\r\n\r\n getBoundingBox: function() {\r\n return this._bb;\r\n },\r\n\r\n getCameraPlaneMaskForLightNear: function(point, cameraFrustum, len) {\r\n var selectorMask = 0x1;\r\n var resultMask = 15;\r\n var i;\r\n\r\n for (i = 0; i < len; ++i) {\r\n resultMask = (resultMask << 1) | 1;\r\n }\r\n\r\n var planeList = cameraFrustum.getPlanes();\r\n for (i = 0; i < len; ++i) {\r\n if (Plane.distanceToPlane(planeList[i], point) < 0.0) {\r\n // Ligth frustum source poitn is outside this plane.\r\n // subsequent checks against this plane not required.\r\n // as light position is behind those,\r\n // and culling that would cull light near\r\n resultMask ^= selectorMask;\r\n }\r\n selectorMask <<= 1;\r\n }\r\n this._cameraPlaneMaskedByLightNear = resultMask;\r\n\r\n cameraFrustum.setResultMask(resultMask);\r\n cameraFrustum.pushCurrentMask(resultMask);\r\n return resultMask;\r\n },\r\n\r\n applyTransform: function(transform) {\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n mat4.copy(matrix, this._matrixStack.back());\r\n transform.computeLocalToWorldMatrix(matrix, this);\r\n\r\n var bs = this._bs;\r\n transform.getBound().transformMat4(this._bs, matrix);\r\n\r\n // camera cull\r\n if (this._cameraFrustum.getCurrentMask() !== 0) {\r\n // father bounding sphere is not totally inside\r\n // now test this one\r\n if (!this._cameraFrustum.containsBoundingSphere(bs)) return; // culled\r\n }\r\n\r\n // light cull\r\n if (this._lightFrustum.getCurrentMask() !== 0) {\r\n // father bounding sphere is not totally inside\r\n // now test this one\r\n if (!this._lightFrustum.containsBoundingSphere(bs)) return; // culled\r\n }\r\n\r\n this._cameraFrustum.pushCurrentMask();\r\n this._lightFrustum.pushCurrentMask();\r\n\r\n this.pushMatrix(matrix);\r\n\r\n this.traverse(transform);\r\n\r\n this._cameraFrustum.popCurrentMask();\r\n this._lightFrustum.popCurrentMask();\r\n\r\n this.popMatrix();\r\n },\r\n applyBoundingBox: (function() {\r\n var bbOut = new BoundingBox();\r\n return function(bbox) {\r\n var matrix = this._matrixStack.back();\r\n if (mat4.exactEquals(matrix, mat4.IDENTITY)) {\r\n this._bb.expandByBoundingBox(bbox);\r\n } else if (bbox.valid()) {\r\n bbox.transformMat4(bbOut, matrix);\r\n this._bb.expandByBoundingBox(bbOut);\r\n }\r\n };\r\n })(),\r\n\r\n apply: function(node) {\r\n var typeID = node.getTypeID();\r\n\r\n if (node instanceof MatrixTransform) {\r\n this.applyTransform(node);\r\n return;\r\n } else if (typeID === Geometry.getTypeID()) {\r\n var bs = this._bs;\r\n node.getBound().transformMat4(bs, this._matrixStack.back());\r\n\r\n // camera cull\r\n if (this._cameraFrustum.getCurrentMask() !== 0) {\r\n // father bounding sphere is not totally inside\r\n // now test this one\r\n if (!this._cameraFrustum.containsBoundingSphere(bs)) return; // culled\r\n }\r\n\r\n // light cull\r\n if (this._lightFrustum.getCurrentMask() !== 0) {\r\n // father bounding sphere is not totally inside\r\n // now test this one\r\n if (!this._lightFrustum.containsBoundingSphere(bs)) return; // culled\r\n }\r\n\r\n // Visible: we enlarge the bbox\r\n this.applyBoundingBox(node.getBoundingBox());\r\n\r\n return;\r\n } else if (typeID === Camera.getTypeID()) {\r\n } else if (typeID === Light.getTypeID()) {\r\n }\r\n\r\n this.traverse(node);\r\n },\r\n\r\n pushMatrix: function(matrix) {\r\n this._matrixStack.push(matrix);\r\n },\r\n\r\n popMatrix: function() {\r\n this._matrixStack.pop();\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ComputeMultiFrustumBoundsVisitor'\r\n);\r\n\r\nexport default ComputeMultiFrustumBoundsVisitor;\r\n","import utils from '../osg/utils';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport Uniform from '../osg/Uniform';\r\n\r\n/**\r\n * ShadowReceiveAttribute encapsulate Shadow Main State object\r\n * @class ShadowReceiveAttribute\r\n * @inherits StateAttribute\r\n */\r\nvar ShadowReceiveAttribute = function(lightNum, disable) {\r\n StateAttribute.call(this);\r\n\r\n this._lightNumber = lightNum;\r\n\r\n // see shadowSettings.js header for shadow algo param explanations\r\n // hash change var\r\n\r\n // shadow depth bias as projected in shadow camera space texture\r\n // and viewer camera space projection introduce its bias\r\n this._bias = 0.001;\r\n\r\n // shadow normal bias from normal exploding offset technique\r\n this._normalBias = undefined;\r\n // shader compilation different upon texture precision\r\n this._precision = 'UNSIGNED_BYTE';\r\n // kernel size & type for pcf\r\n this._kernelSizePCF = undefined;\r\n\r\n this._fakePCF = true;\r\n\r\n this._jitterOffset = 'none';\r\n\r\n this._enable = !disable;\r\n this._isAtlasTexture = false;\r\n\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nShadowReceiveAttribute.uniforms = {};\r\nutils.createPrototypeStateAttribute(\r\n ShadowReceiveAttribute,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'ShadowReceive',\r\n\r\n cloneType: function() {\r\n return new ShadowReceiveAttribute(this._lightNumber, true);\r\n },\r\n\r\n getTypeMember: function() {\r\n return this.attributeType + this.getLightNumber();\r\n },\r\n\r\n getLightNumber: function() {\r\n return this._lightNumber;\r\n },\r\n\r\n getUniformName: function(name) {\r\n var prefix = this.getType() + this.getLightNumber().toString();\r\n return 'u' + prefix + '_' + name;\r\n },\r\n\r\n getAtlas: function() {\r\n return this._isAtlasTexture;\r\n },\r\n setAtlas: function(v) {\r\n this._isAtlasTexture = v;\r\n },\r\n\r\n setBias: function(bias) {\r\n this._bias = bias;\r\n },\r\n\r\n getBias: function() {\r\n return this._bias;\r\n },\r\n\r\n setNormalBias: function(bias) {\r\n this._normalBias = bias;\r\n },\r\n\r\n getNormalBias: function() {\r\n return this._normalBias;\r\n },\r\n\r\n setJitterOffset: function(jitter) {\r\n this._jitterOffset = jitter;\r\n },\r\n\r\n getJitterOffset: function() {\r\n return this._jitterOffset;\r\n },\r\n\r\n getKernelSizePCF: function() {\r\n return this._kernelSizePCF;\r\n },\r\n\r\n setKernelSizePCF: function(v) {\r\n this._kernelSizePCF = v;\r\n this._dirtyHash = true;\r\n },\r\n\r\n setPrecision: function(precision) {\r\n this._precision = precision;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getPrecision: function() {\r\n return this._precision;\r\n },\r\n\r\n setLightNumber: function(lightNum) {\r\n this._lightNumber = lightNum;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getOrCreateUniforms: function() {\r\n // uniform are once per CLASS attribute, not per instance\r\n var obj = ShadowReceiveAttribute;\r\n\r\n var typeMember = this.getTypeMember();\r\n\r\n if (obj.uniforms[typeMember]) return obj.uniforms[typeMember];\r\n\r\n obj.uniforms[typeMember] = {\r\n bias: Uniform.createFloat(this.getUniformName('bias')),\r\n normalBias: Uniform.createFloat(this.getUniformName('normalBias'))\r\n };\r\n\r\n return obj.uniforms[typeMember];\r\n },\r\n\r\n // Here to be common between caster and receiver\r\n // (used by shadowMap and shadow node shader)\r\n getDefines: function() {\r\n var defines = [];\r\n\r\n var pcf = this.getKernelSizePCF();\r\n switch (pcf) {\r\n case '4Tap(16texFetch)':\r\n defines.push('#define _PCFx4');\r\n break;\r\n case '9Tap(36texFetch)':\r\n defines.push('#define _PCFx9');\r\n break;\r\n case '16Tap(64texFetch)':\r\n defines.push('#define _PCFx25');\r\n break;\r\n default:\r\n case '1Tap(4texFetch)':\r\n defines.push('#define _PCFx1');\r\n break;\r\n }\r\n\r\n if (this.getPrecision() !== 'UNSIGNED_BYTE') defines.push('#define _FLOATTEX');\r\n if (this.getAtlas()) defines.push('#define _ATLAS_SHADOW');\r\n if (this.getNormalBias()) defines.push('#define _NORMAL_OFFSET');\r\n if (this.getJitterOffset() !== 'none') defines.push('#define _JITTER_OFFSET');\r\n\r\n return defines;\r\n },\r\n\r\n apply: function() {\r\n if (!this._enable) return;\r\n\r\n var uniformMap = this.getOrCreateUniforms();\r\n\r\n uniformMap.normalBias.setFloat(this._normalBias);\r\n uniformMap.bias.setFloat(this._bias);\r\n },\r\n\r\n // need a isEnabled to let the ShaderGenerator to filter\r\n // StateAttribute from the shader compilation\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n return this.getTypeMember() + '_' + this.getKernelSizePCF();\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowReceiveAttribute'\r\n);\r\n\r\nexport default ShadowReceiveAttribute;\r\n","import notify from '../osg/notify';\r\nimport Object from '../osg/Object';\r\nimport utils from '../osg/utils';\r\n\r\n/**\r\n * ShadowTechnique provides an implementation interface of shadow techniques.\r\n * @class ShadowTechnique\r\n */\r\nvar ShadowTechnique = function() {\r\n Object.call(this);\r\n\r\n this._shadowedScene = undefined;\r\n this._dirty = false;\r\n this._continuousUpdate = true;\r\n // since dirtied, handy for static shadow map\r\n this._needRedraw = true;\r\n};\r\n\r\n/** @lends ShadowTechnique.prototype */\r\nutils.createPrototypeObject(\r\n ShadowTechnique,\r\n utils.objectInherit(Object.prototype, {\r\n dirty: function() {\r\n this._dirty = true;\r\n },\r\n\r\n getShadowedScene: function() {\r\n return this._shadowedScene;\r\n },\r\n\r\n setContinuousUpdate: function(enabled) {\r\n this._continuousUpdate = enabled;\r\n },\r\n\r\n isContinuousUpdate: function() {\r\n return this._continuousUpdate;\r\n },\r\n\r\n needRedraw: function() {\r\n return this._needRedraw;\r\n },\r\n\r\n requestRedraw: function() {\r\n this._needRedraw = true;\r\n },\r\n\r\n setShadowedScene: function(shadowedScene) {\r\n this._shadowedScene = shadowedScene;\r\n },\r\n\r\n init: function() {\r\n // well shouldn't be called\r\n notify.log('No ShadowTechnique activated: normal rendering activated');\r\n },\r\n\r\n valid: function() {\r\n // make sure abstract class not used.\r\n return false;\r\n },\r\n\r\n // update the technic\r\n updateShadowTechnique: function(/*nodeVisitor*/) {},\r\n\r\n cullShadowCasting: function(/*cullVisitor*/) {},\r\n\r\n cleanSceneGraph: function() {\r\n // well shouldn't be called\r\n notify.log('No ShadowTechnique activated: normal rendering activated');\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowTechnique'\r\n);\r\n\r\nexport default ShadowTechnique;\r\n","import notify from '../osg/notify';\r\nimport Texture from '../osg/Texture';\r\nimport Uniform from '../osg/Uniform';\r\nimport utils from '../osg/utils';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport { vec2 } from '../osg/glMatrix';\r\n\r\n/**\r\n * ShadowTexture Attribute encapsulate Texture webgl object\r\n * with Shadow specificities (no need of texcoord,fragtexcoord)\r\n * trigger hash change when changing texture precision from float to byt\r\n * shadowSettings.js header for param explanations\r\n * @class ShadowTexture\r\n * @inherits StateAttribute\r\n */\r\nvar ShadowTexture = function() {\r\n Texture.call(this);\r\n\r\n this._uniforms = {};\r\n this._mapSize = vec4.create();\r\n this._renderSize = vec2.create();\r\n this._lightNumber = -1; // default for a valid cloneType\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nShadowTexture.uniforms = {};\r\n/** @lends Texture.prototype */\r\nutils.createPrototypeStateAttribute(\r\n ShadowTexture,\r\n utils.objectInherit(Texture.prototype, {\r\n cloneType: function() {\r\n return new ShadowTexture();\r\n },\r\n invalidate: function() {\r\n Texture.prototype.invalidate.call(this);\r\n this.dirty();\r\n },\r\n hasLightNumber: function(lightNum) {\r\n return this._lightNumber === lightNum;\r\n },\r\n\r\n setLightNumber: function(lun) {\r\n this._lightNumber = lun;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getLightNumber: function() {\r\n return this._lightNumber;\r\n },\r\n\r\n getUniformName: function(name) {\r\n var prefix = 'Shadow_' + this.getType() + this._lightNumber.toString();\r\n return 'u' + prefix + '_' + name;\r\n },\r\n\r\n setInternalFormatType: function(value) {\r\n Texture.prototype.setInternalFormatType.call(this, value);\r\n this._dirtyHash = true;\r\n },\r\n\r\n getOrCreateUniforms: function(unit) {\r\n // uniform are once per CLASS attribute, not per instance\r\n var obj = ShadowTexture;\r\n\r\n notify.assert(unit !== undefined);\r\n notify.assert(this._lightNumber !== -1);\r\n\r\n if (obj.uniforms[unit] !== undefined) return obj.uniforms[unit];\r\n\r\n var uniforms = (obj.uniforms[unit] = {\r\n ViewRight: Uniform.createFloat4(this.getUniformName('viewRight')),\r\n ViewUp: Uniform.createFloat4(this.getUniformName('viewUp')),\r\n ViewLook: Uniform.createFloat4(this.getUniformName('viewLook')),\r\n Projection: Uniform.createFloat3(this.getUniformName('projection')),\r\n DepthRange: Uniform.createFloat2(this.getUniformName('depthRange')),\r\n MapSize: Uniform.createFloat4(this.getUniformName('mapSize')),\r\n RenderSize: Uniform.createFloat2(this.getUniformName('renderSize'))\r\n });\r\n\r\n // Dual Uniform of texture, needs:\r\n // - Sampler (type of texture)\r\n // - Int (texture unit)\r\n // tells Shader Program where to find it\r\n var name = 'Texture' + unit;\r\n var uniform = Uniform.createInt1(unit, name);\r\n uniforms[name] = uniform;\r\n\r\n return obj.uniforms[unit];\r\n },\r\n\r\n setViewMatrix: function(viewMatrix) {\r\n this._viewMatrix = viewMatrix;\r\n },\r\n\r\n setProjection: function(projection) {\r\n this._projection = projection;\r\n },\r\n\r\n setDepthRange: function(depthRange) {\r\n this._depthRange = depthRange;\r\n },\r\n\r\n setTextureSize: function(w, h) {\r\n Texture.prototype.setTextureSize.call(this, w, h);\r\n this.dirty();\r\n this._mapSize[0] = w;\r\n this._mapSize[1] = h;\r\n this._mapSize[2] = 1.0 / w;\r\n this._mapSize[3] = 1.0 / h;\r\n\r\n this._renderSize[0] = 1.0 / w;\r\n this._renderSize[1] = 1.0 / h;\r\n },\r\n\r\n // optimize a mat4 into 3 vec4 unforms\r\n _updateViewMatrixUniforms: function(viewMatrix, viewRight, viewUp, viewLook) {\r\n var v;\r\n var m = viewMatrix;\r\n v = viewRight.getInternalArray();\r\n v[0] = m[0];\r\n v[1] = m[4];\r\n v[2] = m[8];\r\n v[3] = m[12];\r\n\r\n v = viewUp.getInternalArray();\r\n v[0] = m[1];\r\n v[1] = m[5];\r\n v[2] = m[9];\r\n v[3] = m[13];\r\n\r\n v = viewLook.getInternalArray();\r\n v[0] = m[2];\r\n v[1] = m[6];\r\n v[2] = m[10];\r\n v[3] = m[14];\r\n },\r\n\r\n apply: function(state, texNumber) {\r\n // Texture stuff: call parent class method\r\n Texture.prototype.apply.call(this, state, texNumber);\r\n\r\n if (this._lightNumber === -1) return;\r\n\r\n // update Uniforms\r\n var uniformMap = this.getOrCreateUniforms(texNumber);\r\n\r\n this._updateViewMatrixUniforms(\r\n this._viewMatrix,\r\n uniformMap.ViewRight,\r\n uniformMap.ViewUp,\r\n uniformMap.ViewLook\r\n );\r\n uniformMap.Projection.setFloat3(this._projection);\r\n uniformMap.DepthRange.setFloat2(this._depthRange);\r\n uniformMap.MapSize.setFloat4(this._mapSize);\r\n uniformMap.RenderSize.setFloat2(this._renderSize);\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n return this.getTypeMember() + '_' + this._lightNumber + '_' + this._type;\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowTexture'\r\n);\r\n\r\nexport default ShadowTexture;\r\n","import Camera from '../osg/Camera';\r\nimport CullVisitor from '../osg/CullVisitor';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport Depth from '../osg/Depth';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport notify from '../osg/notify';\r\nimport Shape from '../osg/shape';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport StateSet from '../osg/StateSet';\r\nimport Debug from '../osgUtil/debug';\r\nimport Texture from '../osg/Texture';\r\nimport Transform from '../osg/Transform';\r\nimport Uniform from '../osg/Uniform';\r\nimport utils from '../osg/utils';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport { vec2, vec3, vec4 } from '../osg/glMatrix';\r\nimport Viewport from '../osg/Viewport';\r\nimport WebGLCaps from '../osg/WebGLCaps';\r\nimport ShadowReceiveAttribute from './ShadowReceiveAttribute';\r\nimport ShadowCastAttribute from './ShadowCastAttribute';\r\nimport ShadowTechnique from './ShadowTechnique';\r\nimport ShadowTexture from './ShadowTexture';\r\nimport Scissor from '../osg/Scissor';\r\n\r\n// Custom camera cull callback\r\n// we customize it just to avoid to add extra 'virtual' function\r\n// on the shadowTecnique class\r\nvar CameraCullCallback = function(shadowTechnique) {\r\n this._shadowTechnique = shadowTechnique;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n CameraCullCallback,\r\n {\r\n cull: function(node, nv) {\r\n this._shadowTechnique.getShadowedScene().nodeTraverse(nv);\r\n\r\n var cs = nv.getCurrentCullingSet();\r\n var m = nv.getCurrentProjectionMatrix();\r\n var near = nv.getComputedNear(),\r\n far = nv.getComputedFar();\r\n\r\n if (near === Infinity && far === -Infinity) {\r\n this._shadowTechnique.markSceneAsNoShadow();\r\n return false;\r\n }\r\n\r\n mat4.getFrustumPlanes(\r\n cs.getFrustum().getPlanes(),\r\n m,\r\n nv.getCurrentModelViewMatrix(),\r\n false\r\n );\r\n cs.getFrustum().setupMask(6);\r\n this._shadowTechnique.setLightFrustum(cs.getFrustum(), near, far);\r\n\r\n return false;\r\n }\r\n },\r\n 'osgShadow',\r\n 'CameraCullCallback'\r\n);\r\n\r\n/**\r\n * ShadowMap provides an implementation of shadow textures.\r\n * @class ShadowMap\r\n */\r\nvar ShadowMap = function(settings, shadowTexture) {\r\n ShadowTechnique.call(this);\r\n\r\n this._projectionMatrix = mat4.create();\r\n this._projection = vec3.create();\r\n this._viewMatrix = mat4.create();\r\n this._lightNumberArrayIndex = -1;\r\n this._lightUp = vec3.fromValues(0.0, 0.0, 1.0);\r\n\r\n this._light = settings.light;\r\n\r\n // data\r\n this._cameraShadow = new Camera();\r\n this._cameraShadow.setCullCallback(new CameraCullCallback(this));\r\n this._cameraShadow.setRenderOrder(Camera.PRE_RENDER, 0);\r\n this._cameraShadow.setReferenceFrame(Transform.ABSOLUTE_RF);\r\n this._cameraShadow.setClearColor(vec4.fromValues(1.0, 1.0, 1.0, 1.0));\r\n\r\n if (shadowTexture) {\r\n this._texture = shadowTexture;\r\n } else {\r\n this._texture = new ShadowTexture();\r\n this._textureUnitBase = 4;\r\n this._textureUnit = this._textureUnitBase;\r\n\r\n // see shadowSettings.js header for param explanations\r\n this._textureMagFilter = undefined;\r\n this._textureMinFilter = undefined;\r\n }\r\n\r\n this._textureSize = 256;\r\n var unifRenderSize = Uniform.createFloat2('RenderSize');\r\n this._texelSizeUniform = Uniform.createFloat1(1.0 / this._textureSize, 'texelSize');\r\n this._renderSize = unifRenderSize.getInternalArray();\r\n this._renderSize[0] = this._renderSize[1] = this._textureSize;\r\n\r\n this._receivingStateset = undefined;\r\n\r\n this._casterStateSet = new StateSet();\r\n this._casterStateSet.addUniform(Uniform.createFloat1(0, 'exponent0'));\r\n this._casterStateSet.addUniform(Uniform.createFloat1(0, 'exponent1'));\r\n this._casterStateSet.addUniform(Uniform.createFloat1(0.005, 'bias'));\r\n this._casterStateSet.addUniform(this._texelSizeUniform);\r\n this._casterStateSet.addUniform(unifRenderSize);\r\n\r\n // make sure no unintended blend happens\r\n // if casting semi-transparent (alphablend material with full opaque pixels) shadow\r\n this._casterStateSet.setAttributeAndModes(\r\n new Depth(Depth.LESS),\r\n StateAttribute.ON | StateAttribute.OVERRIDE\r\n );\r\n this._casterStateSet.setAttributeAndModes(\r\n new BlendFunc(),\r\n StateAttribute.ON | StateAttribute.OVERRIDE\r\n );\r\n\r\n this._shadowReceiveAttribute = new ShadowReceiveAttribute(this._light.getLightNumber());\r\n this._casterStateSet.setAttributeAndModes(\r\n this._shadowReceiveAttribute,\r\n StateAttribute.ON | StateAttribute.OVERRIDE\r\n );\r\n\r\n // default name, overridable with shadow settings\r\n this._shadowCastShaderGeneratorName = 'ShadowCast';\r\n\r\n var near = 0.001;\r\n var far = 1000;\r\n var unifRange = Uniform.createFloat4('uShadowDepthRange');\r\n this._casterStateSet.addUniform(unifRange);\r\n this._depthRange = unifRange.getInternalArray();\r\n this._depthRange[0] = near;\r\n this._depthRange[1] = far;\r\n\r\n this._worldLightPos = vec4.create();\r\n this._worldLightPos[3] = 0;\r\n this._worldLightDir = vec4.create();\r\n this._worldLightDir[3] = 1;\r\n\r\n this._castsShadowDrawTraversalMask = 0xffffffff;\r\n this._castsShadowBoundsTraversalMask = 0xffffffff;\r\n\r\n this._shaderProcessor = undefined;\r\n\r\n // tmp variables\r\n this._tmpVec = vec3.create();\r\n this._tmpVecBis = vec3.create();\r\n this._tmpVecTercio = vec3.create();\r\n this._tmpMatrix = mat4.create();\r\n\r\n if (settings) this.setShadowSettings(settings);\r\n\r\n this._infiniteFrustum = true;\r\n var shadowStateAttribute = new ShadowCastAttribute(false, this._shadowReceiveAttribute);\r\n\r\n this._casterStateSet.setAttributeAndModes(\r\n shadowStateAttribute,\r\n StateAttribute.ON | StateAttribute.OVERRIDE\r\n );\r\n this._casterStateSet.setShaderGeneratorName(\r\n this._shadowCastShaderGeneratorName,\r\n StateAttribute.OVERRIDE | StateAttribute.ON\r\n );\r\n\r\n this._debug = false;\r\n};\r\n\r\n/** @lends ShadowMap.prototype */\r\nutils.createPrototypeObject(\r\n ShadowMap,\r\n utils.objectInherit(ShadowTechnique.prototype, {\r\n getDepthRange: function() {\r\n return this._depthRange;\r\n },\r\n setLightFrustum: function(lf, near, far) {\r\n this._lightFrustum = lf;\r\n\r\n this._depthRange[0] = near;\r\n this._depthRange[1] = far;\r\n this.nearFarBounding();\r\n\r\n if (this._debug) {\r\n this._debugGeomFrustum.updateGeometry(this._projectionMatrix, this._depthRange);\r\n mat4.invert(this._debugNodeFrustum.getMatrix(), this._viewMatrix);\r\n }\r\n },\r\n getCamera: function() {\r\n return this._cameraShadow;\r\n },\r\n\r\n getTexture: function() {\r\n return this._texture;\r\n },\r\n\r\n isDirty: function() {\r\n return this._dirty;\r\n },\r\n /**\r\n * at which Texture unit number we start adding texture shadow\r\n */\r\n setTextureUnitBase: function(unitBase) {\r\n this._textureUnitBase = unitBase;\r\n this._textureUnit = unitBase;\r\n },\r\n\r\n /* Sets shadowSettings\r\n */\r\n setShadowSettings: function(shadowSettings) {\r\n if (!shadowSettings) return;\r\n\r\n this._light = shadowSettings.light;\r\n this._shadowCastShaderGeneratorName = shadowSettings.getShadowCastShaderGeneratorName();\r\n\r\n this.setCastsShadowDrawTraversalMask(shadowSettings.castsShadowDrawTraversalMask);\r\n this.setCastsShadowBoundsTraversalMask(shadowSettings.castsShadowBoundsTraversalMask);\r\n\r\n this.setLight(this._light);\r\n this.setTextureSize(shadowSettings.textureSize);\r\n this.setTexturePrecision(shadowSettings.textureType);\r\n\r\n this.setKernelSizePCF(shadowSettings.kernelSizePCF);\r\n this.setBias(shadowSettings.bias);\r\n this.setNormalBias(shadowSettings.normalBias);\r\n },\r\n\r\n setCastsShadowDrawTraversalMask: function(mask) {\r\n this._castsShadowDrawTraversalMask = mask;\r\n },\r\n\r\n getCastsShadowDrawTraversalMask: function() {\r\n return this._castsDrawShadowTraversalMask;\r\n },\r\n\r\n setCastsShadowBoundsTraversalMask: function(mask) {\r\n this._castsShadowBoundsTraversalMask = mask;\r\n },\r\n\r\n getCastsShadowBoundsTraversalMask: function() {\r\n return this._castsShadowBoundsTraversalMask;\r\n },\r\n\r\n getNormalBias: function() {\r\n return this._shadowReceiveAttribute.getNormalBias();\r\n },\r\n\r\n setNormalBias: function(value) {\r\n this._shadowReceiveAttribute.setNormalBias(value);\r\n },\r\n\r\n getJitterOffset: function() {\r\n return this._shadowReceiveAttribute.getJitterOffset();\r\n },\r\n\r\n setJitterOffset: function(value) {\r\n this._shadowReceiveAttribute.setJitterOffset(value);\r\n },\r\n\r\n getBias: function() {\r\n return this._shadowReceiveAttribute.getBias();\r\n },\r\n\r\n setBias: function(value) {\r\n this._shadowReceiveAttribute.setBias(value);\r\n var uniform = this._casterStateSet.getUniformList().bias.getUniform();\r\n uniform.setFloat(value);\r\n },\r\n\r\n getKernelSizePCF: function() {\r\n return this._shadowReceiveAttribute.getKernelSizePCF();\r\n },\r\n\r\n setKernelSizePCF: function(value) {\r\n this._shadowReceiveAttribute.setKernelSizePCF(value);\r\n },\r\n\r\n setShadowedScene: function(shadowedScene) {\r\n ShadowTechnique.prototype.setShadowedScene.call(this, shadowedScene);\r\n this._receivingStateset = this._shadowedScene.getReceivingStateSet();\r\n this.dirty();\r\n },\r\n\r\n checkLightNumber: function() {\r\n var lightNumber = this._light.getLightNumber();\r\n\r\n // if light number changed we need to remove cleanly\r\n // attributes from receiveStateSet\r\n // it's because it use a typemember like light attribute\r\n // so the number if very important to keep State clean\r\n if (this._shadowReceiveAttribute.getLightNumber() !== lightNumber) {\r\n if (\r\n this._receivingStateset.getAttribute(\r\n this._shadowReceiveAttribute.getTypeMember()\r\n ) === this._shadowReceiveAttribute\r\n )\r\n this._receivingStateset.removeAttribute(\r\n this._shadowReceiveAttribute.getTypeMember()\r\n );\r\n }\r\n\r\n /*develblock:start*/\r\n notify.assert(\r\n this._shadowReceiveAttribute.getTypeMember() ===\r\n this._shadowReceiveAttribute.attributeType + lightNumber,\r\n 'TypeMember isnt reflecting light number' +\r\n this._shadowReceiveAttribute.getTypeMember() +\r\n ' !== ' +\r\n this._shadowReceiveAttribute.attributeType +\r\n lightNumber\r\n );\r\n /*develblock:end*/\r\n\r\n if (this._texture && !this._texture.hasLightNumber(lightNumber)) {\r\n // remove this._texture, but not if it's not this._texture\r\n if (\r\n this._receivingStateset.getTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n ) === this._texture\r\n )\r\n this._receivingStateset.removeTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n );\r\n }\r\n },\r\n\r\n _rebindFbo: function() {\r\n this._cameraShadow.detachAll();\r\n this._cameraShadow.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, this._texture);\r\n this._cameraShadow.attachRenderBuffer(\r\n FrameBufferObject.DEPTH_ATTACHMENT,\r\n FrameBufferObject.DEPTH_COMPONENT16\r\n );\r\n },\r\n\r\n /** initialize the ShadowedScene and local cached data structures.*/\r\n init: function(atlasTexture, lightIndex, textureUnit) {\r\n if (!this._shadowedScene) return;\r\n\r\n this._needRedraw = true;\r\n\r\n this.checkLightNumber();\r\n\r\n var lightNumber = this._light.getLightNumber();\r\n\r\n if (!atlasTexture) {\r\n this.initTexture();\r\n this._rebindFbo();\r\n this._textureUnit = this._textureUnitBase + lightNumber;\r\n this._texture.setLightNumber(lightNumber);\r\n this._texture.setName('ShadowTexture' + this._textureUnit);\r\n this._shadowReceiveAttribute.setAtlas(false);\r\n } else {\r\n this._texture = atlasTexture;\r\n\r\n // allow indexing properties in the texture uniforms\r\n this._lightNumberArrayIndex = lightIndex;\r\n this._textureUnit = textureUnit;\r\n this._shadowReceiveAttribute.setAtlas(true);\r\n }\r\n\r\n this._cameraShadow.setName('light_shadow_camera' + this._light.getName());\r\n this._shadowReceiveAttribute.setLightNumber(lightNumber);\r\n\r\n // Idea is to make sure the null texture is \"binded\" to all shadow casting scene\r\n // so we override all existing texture bind in the scene, preventing any texture bind.\r\n // When user implements alpha mask casting, they use PROTECTED to prevent OVERRIDE to remove their alpha mask texture needed.\r\n var fullOverride = StateAttribute.OVERRIDE | StateAttribute.ON;\r\n\r\n this._receivingStateset.setAttributeAndModes(\r\n this._shadowReceiveAttribute,\r\n fullOverride\r\n );\r\n\r\n // prevent unnecessary texture bindings\r\n this._preventTextureBindingDuringShadowCasting();\r\n\r\n // Mandatory: prevent binding shadow textures themselves\r\n // ( ShadowedScene StateSet is applied just above in StateSet hierarchy)\r\n // that would mean undefined values as it would be read/write access...\r\n // So we force it against Texture.null binding done just above (PROTECTED)\r\n // and Prevent any under hierarchy bind with OVERRIDE\r\n // must be done AFTER the prevent binding.\r\n this._casterStateSet.setTextureAttributeAndModes(\r\n this._textureUnit,\r\n Texture.textureNull,\r\n StateAttribute.PROTECTED\r\n );\r\n\r\n // add shadow texture to the receivers\r\n // should make sure somehow that\r\n // alpha blender transparent receiver doesn't use it\r\n // compiler wise at least\r\n this._receivingStateset.setTextureAttributeAndModes(\r\n this._textureUnit,\r\n this._texture,\r\n fullOverride\r\n );\r\n\r\n this._dirty = false;\r\n },\r\n // Make sure we don't bind texture and thus make GPU work for nothing\r\n // as shadow casting just output Depth ( no color )\r\n // os we set a null texture and OVERRIDE StateAttribute flag\r\n // only case you want to use a texture is\r\n // alpha masked material, then you have StateAttribute to 'PROTECTED'\r\n _preventTextureBindingDuringShadowCasting: function() {\r\n // prevent unnecessary texture bindings on all texture unit\r\n var shouldGetMaxTextureUnits = WebGLCaps.instance().getWebGLParameter(\r\n 'MAX_TEXTURE_IMAGE_UNITS'\r\n );\r\n for (var k = 0; k < shouldGetMaxTextureUnits; k++) {\r\n // bind null texture which OSGJS will not bind,\r\n // effectively preventing any other texture bind\r\n // just not touching texture unit state.\r\n this._casterStateSet.setTextureAttributeAndModes(\r\n k,\r\n Texture.textureNull,\r\n StateAttribute.OVERRIDE\r\n );\r\n }\r\n },\r\n\r\n\r\n valid: function() {\r\n // checks\r\n return true;\r\n },\r\n\r\n updateShadowTechnique: function(nv, viewportDimension, frameBufferObject) {\r\n var camera = this._cameraShadow;\r\n var texture = this._texture;\r\n\r\n if (camera && texture) {\r\n var vp = camera.getViewport();\r\n\r\n if (!vp) {\r\n vp = new Viewport();\r\n camera.setViewport(vp);\r\n }\r\n\r\n if (viewportDimension) {\r\n var scissor = camera.getScissor();\r\n if (!scissor) {\r\n scissor = new Scissor(\r\n viewportDimension[0],\r\n viewportDimension[1],\r\n viewportDimension[2],\r\n viewportDimension[3]\r\n );\r\n camera.setScissor(scissor);\r\n }\r\n\r\n // if texture size changed update the camera rtt params\r\n if (\r\n vp.x() !== viewportDimension[0] ||\r\n vp.y() !== viewportDimension[1] ||\r\n vp.width() !== viewportDimension[2] ||\r\n vp.height() !== viewportDimension[3]\r\n ) {\r\n camera.setFrameBufferObject(frameBufferObject);\r\n vp.setViewport(\r\n viewportDimension[0],\r\n viewportDimension[1],\r\n viewportDimension[2],\r\n viewportDimension[3]\r\n );\r\n\r\n scissor.setScissor(\r\n viewportDimension[0],\r\n viewportDimension[1],\r\n viewportDimension[2],\r\n viewportDimension[3]\r\n );\r\n }\r\n } else if (\r\n vp.width() !== texture.getWidth() ||\r\n vp.height() !== texture.getHeight()\r\n ) {\r\n // if texture size changed update the camera rtt params\r\n this._rebindFbo();\r\n vp.setViewport(0, 0, texture.getWidth(), texture.getHeight());\r\n }\r\n }\r\n },\r\n\r\n updateShadowTechnic: function(/*nv*/) {\r\n notify.log(\r\n 'ShadowMap.updateShadowTechnic() is deprecated, use updateShadowTechnique instead'\r\n );\r\n this.updateShadowTechnique();\r\n },\r\n\r\n setTextureFiltering: function() {\r\n var textureType;\r\n var texType = this.getTexturePrecision();\r\n switch (texType) {\r\n case 'HALF_FLOAT':\r\n textureType = Texture.HALF_FLOAT;\r\n break;\r\n case 'FLOAT':\r\n textureType = Texture.FLOAT;\r\n break;\r\n default:\r\n case 'UNSIGNED_BYTE':\r\n textureType = Texture.UNSIGNED_BYTE;\r\n break;\r\n }\r\n\r\n this._texture.setInternalFormatType(textureType);\r\n this._texture.setMinFilter(Texture.NEAREST);\r\n this._texture.setMagFilter(Texture.NEAREST);\r\n this._textureMagFilter = Texture.NEAREST;\r\n this._textureMinFilter = Texture.NEAREST;\r\n },\r\n\r\n // internal texture allocation\r\n // handle any change like resize, filter param, etc.\r\n initTexture: function() {\r\n if (!this._dirty) return;\r\n\r\n if (!this._texture) {\r\n this._texture = new ShadowTexture();\r\n this._textureUnit = this._textureUnitBase;\r\n }\r\n\r\n this._texture.setTextureSize(this._textureSize, this._textureSize);\r\n this._texelSizeUniform.setFloat(1.0 / this._textureSize);\r\n this._renderSize[0] = this._textureSize;\r\n this._renderSize[1] = this._textureSize;\r\n\r\n var textureFormat;\r\n // luminance Float format ?\r\n textureFormat = Texture.RGBA;\r\n\r\n this.setTextureFiltering();\r\n this._texture.setInternalFormat(textureFormat);\r\n\r\n this._texture.setWrapS(Texture.CLAMP_TO_EDGE);\r\n this._texture.setWrapT(Texture.CLAMP_TO_EDGE);\r\n\r\n this._texture.dirty();\r\n },\r\n setTexturePrecision: function(format) {\r\n if (format === this._shadowReceiveAttribute.getPrecision()) return;\r\n\r\n this._shadowReceiveAttribute.setPrecision(format);\r\n this.dirty();\r\n },\r\n\r\n getTexturePrecision: function() {\r\n return this._shadowReceiveAttribute.getPrecision();\r\n },\r\n\r\n setTextureSize: function(mapSize) {\r\n if (mapSize === this._textureSize) return;\r\n\r\n this._textureSize = mapSize;\r\n\r\n this.dirty();\r\n },\r\n\r\n getCasterStateSet: function() {\r\n return this._casterStateSet;\r\n },\r\n\r\n setLight: function(light) {\r\n if (!light || light === this._light) return;\r\n\r\n this._light = light;\r\n this.dirty();\r\n },\r\n\r\n getUp: function(dir) {\r\n //avoid dir/up wrong angle breaking computation\r\n\r\n // compute a up vector ensuring avoiding parallel vectors\r\n // also might reverting to it once got the change here done once\r\n // vec3.fromValues( 0.0, 0.0, 1.0 );\r\n\r\n if (Math.abs(vec3.dot(this._lightUp, dir)) >= 1.0) {\r\n // another camera up\r\n // vec3.fromValues( 1.0, 0.0, 0.0 );\r\n if (this._lightUp[0] === 1.0) {\r\n this._lightUp[0] = 0.0;\r\n this._lightUp[1] = 1.0;\r\n this._lightUp[2] = 0.0;\r\n } else {\r\n this._lightUp[0] = 1.0;\r\n this._lightUp[1] = 0.0;\r\n this._lightUp[2] = 0.0;\r\n }\r\n }\r\n return this._lightUp;\r\n },\r\n\r\n // makes sure we don't have incorrect near/far\r\n // or we actually have to render something.\r\n // Empty or Bad Frustums\r\n // No objects, handle it gracefully\r\n nearFarBounding: function() {\r\n var zNear = this._depthRange[0];\r\n var zFar = this._depthRange[1];\r\n\r\n var epsilon = ShadowMap.EPSILON;\r\n if (zFar < zNear - epsilon) {\r\n // early out\r\n this._emptyCasterScene = true;\r\n zFar = 1;\r\n zNear = epsilon;\r\n } else if (zNear < epsilon) {\r\n zNear = epsilon;\r\n }\r\n\r\n this._depthRange[0] = zNear;\r\n this._depthRange[1] = zFar;\r\n },\r\n\r\n makePerspectiveFromBoundingBox: function(bbox, fov, eyePos, eyeDir, view, projection) {\r\n var center = bbox.center(this._tmpVec);\r\n var radius = bbox.radius();\r\n var epsilon = ShadowMap.EPSILON;\r\n var zNear = epsilon;\r\n var zFar = 1.0;\r\n\r\n this._radius = radius;\r\n\r\n var distance = vec3.distance(center, eyePos);\r\n // inside or not have influence\r\n // on using radius for fov\r\n if (distance <= radius) {\r\n // shhh.. we're inside !\r\n // sphere center is in front\r\n zNear = epsilon;\r\n zFar = distance + radius;\r\n } else {\r\n // Sphere totally in front\r\n // long distance runner\r\n // we must make a nicer zNear here!\r\n zNear = distance - radius;\r\n zFar = distance + radius;\r\n }\r\n\r\n this._depthRange[0] = zNear;\r\n this._depthRange[1] = zFar;\r\n this.nearFarBounding();\r\n\r\n // positional light: spot, point, area\r\n // fov < 180.0\r\n // statically defined by spot, only needs zNear zFar estimates\r\n var fovRadius = this._depthRange[0] * Math.tan(fov * Math.PI / 180.0);\r\n // if scene radius is smaller than fov on scene\r\n // Tighten and enhance precision\r\n fovRadius = fovRadius > radius ? radius : fovRadius;\r\n\r\n var ymax = fovRadius;\r\n var ymin = -ymax;\r\n\r\n var xmax = fovRadius;\r\n var xmin = -xmax;\r\n\r\n var up = this.getUp(eyeDir);\r\n\r\n if (this._infiniteFrustum) {\r\n mat4.infiniteFrustum(projection, xmin, xmax, ymin, ymax, this._depthRange[0]);\r\n } else {\r\n mat4.frustum(\r\n projection,\r\n xmin,\r\n xmax,\r\n ymin,\r\n ymax,\r\n this._depthRange[0],\r\n this._depthRange[1]\r\n );\r\n }\r\n\r\n this._projection[0] = this._projectionMatrix[0];\r\n this._projection[1] = this._projectionMatrix[5];\r\n this._projection[2] = 0.0;\r\n\r\n mat4.lookAtDirection(view, eyePos, eyeDir, up);\r\n },\r\n\r\n makeOrthoFromBoundingBox: function(bbox, eyeDir, view, projection) {\r\n var center = bbox.center(this._tmpVecTercio);\r\n\r\n var radius = bbox.radius();\r\n var diameter = radius + radius;\r\n\r\n var zNear = 0.0001;\r\n var zFar = diameter + 0.0001;\r\n\r\n // compute eye Pos from a inverted lightDir Ray shot from center of bbox\r\n // firs make a RAY then move the eye to the that far pos following the ray\r\n var eyePos = this._tmpVec;\r\n vec3.scaleAndAdd(eyePos, center, eyeDir, -diameter);\r\n\r\n zNear = radius;\r\n zFar += radius;\r\n\r\n var zNearRatio = 0.001;\r\n if (zNear < zFar * zNearRatio) {\r\n zNear = zFar * zNearRatio;\r\n }\r\n\r\n var up = this.getUp(eyeDir);\r\n mat4.lookAtDirection(view, eyePos, eyeDir, up);\r\n\r\n var right, top;\r\n top = radius;\r\n right = top;\r\n mat4.ortho(projection, -right, right, -top, top, zNear, zFar);\r\n\r\n this._projection[0] = right;\r\n this._projection[1] = top;\r\n this._projection[2] = 1.0;\r\n\r\n this._depthRange[0] = zNear;\r\n this._depthRange[1] = zFar;\r\n },\r\n /*\r\n * Sync camera and light vision so that\r\n * shadow map render using a camera whom\r\n * settings come from the light\r\n * and the scene being shadowed\r\n */\r\n aimShadowCastingCamera: function(cullVisitor, bbox) {\r\n var light = this._light;\r\n\r\n if (!light) {\r\n this._emptyCasterScene = true;\r\n return;\r\n }\r\n\r\n var camera = this._cameraShadow;\r\n\r\n var worldLightPos = this._worldLightPos;\r\n var worldLightDir = this._worldLightDir;\r\n\r\n // make sure it's not modified outside our computations\r\n // camera matrix can be modified by cullvisitor afterwards...\r\n mat4.copy(this._projectionMatrix, camera.getProjectionMatrix());\r\n mat4.copy(this._viewMatrix, camera.getViewMatrix());\r\n var projection = this._projectionMatrix;\r\n var view = this._viewMatrix;\r\n\r\n // inject camera world matrix.\r\n // from light current world/pos and camera eye pos.\r\n // inject camera world matrix.\r\n // from light current world/pos\r\n // NEED same camera eye pos\r\n var positionedAttribute = cullVisitor.getCurrentRenderBin().getPositionedAttribute();\r\n\r\n var lightMatrix;\r\n var positionedAttributeElements = positionedAttribute.getArray();\r\n for (var i = 0; i < positionedAttribute.getLength(); i++) {\r\n var pa = positionedAttributeElements[i];\r\n var attribute = pa[1];\r\n var matrix = pa[0];\r\n if (attribute === light) {\r\n lightMatrix = matrix;\r\n break;\r\n }\r\n }\r\n\r\n if (lightMatrix === undefined) {\r\n notify.warn('light isnt inside children of shadowedScene Node');\r\n this._emptyCasterScene = true;\r\n return;\r\n }\r\n\r\n var eyeToWorld = this._tmpMatrix;\r\n mat4.invert(eyeToWorld, cullVisitor.getCurrentModelViewMatrix());\r\n\r\n // light pos & lightTarget in World Space\r\n if (!this._light.isDirectionLight()) {\r\n mat4.mul(this._tmpMatrix, eyeToWorld, lightMatrix);\r\n var worldMatrix = this._tmpMatrix;\r\n\r\n // same code as light spot shader\r\n vec3.transformMat4(worldLightPos, light.getPosition(), worldMatrix);\r\n worldMatrix[12] = 0;\r\n worldMatrix[13] = 0;\r\n worldMatrix[14] = 0;\r\n mat4.invert(worldMatrix, worldMatrix);\r\n mat4.transpose(worldMatrix, worldMatrix);\r\n\r\n // not a directional light, compute the world light dir\r\n vec3.copy(worldLightDir, light.getDirection());\r\n vec4.transformMat4(worldLightDir, worldLightDir, worldMatrix);\r\n vec3.normalize(worldLightDir, worldLightDir);\r\n\r\n // and compute a perspective frustum\r\n this.makePerspectiveFromBoundingBox(\r\n bbox,\r\n light.getSpotCutoff(),\r\n worldLightPos,\r\n worldLightDir,\r\n view,\r\n projection\r\n );\r\n } else {\r\n vec4.transformMat4(worldLightPos, light.getPosition(), lightMatrix);\r\n vec4.transformMat4(worldLightPos, worldLightPos, eyeToWorld);\r\n // same code as light sun shader\r\n // lightpos is a light dir\r\n // so we now have to normalize\r\n // since the transform to world above\r\n vec3.scale(worldLightPos, worldLightPos, -1.0);\r\n vec3.normalize(worldLightPos, worldLightPos);\r\n this.makeOrthoFromBoundingBox(bbox, worldLightPos, view, projection);\r\n\r\n if (this._debug) {\r\n // project box by view to get projection debug bbox\r\n mat4.invert(this._debugNodeFrustum.getMatrix(), view);\r\n }\r\n }\r\n\r\n mat4.copy(camera.getProjectionMatrix(), this._projectionMatrix);\r\n mat4.copy(camera.getViewMatrix(), this._viewMatrix);\r\n },\r\n\r\n // culling is done,\r\n // now try for a the tightest frustum\r\n // possible for shadowcasting\r\n frameShadowCastingFrustum: function(cullVisitor) {\r\n if (!this._infiniteFrustum) {\r\n CullVisitor.prototype.clampProjectionMatrix(\r\n this._projectionMatrix,\r\n this._depthRange[0],\r\n this._depthRange[1],\r\n cullVisitor.getNearFarRatio(),\r\n this._depthRange\r\n );\r\n }\r\n\r\n // overwrite any cullvisitor wrongness done by any clampProjectionMatrix\r\n var camera = this._cameraShadow;\r\n mat4.copy(camera.getProjectionMatrix(), this._projectionMatrix);\r\n mat4.copy(camera.getViewMatrix(), this._viewMatrix);\r\n\r\n this.setShadowUniformsReceive(false);\r\n },\r\n\r\n setShadowUniformsReceive: function(noDepth) {\r\n if (noDepth) {\r\n // receiver shader can read and early out\r\n vec2.set(this._depthRange, 0.0, 0.0);\r\n }\r\n // even if noDepth, need to call those to make sure they are created\r\n // in shadowTexture / shadowTextureAtlas\r\n if (this._lightNumberArrayIndex !== -1) {\r\n var lightNumber = this._light.getLightNumber();\r\n this._texture.setViewMatrix(lightNumber, this._viewMatrix);\r\n this._texture.setProjection(lightNumber, this._projection);\r\n this._texture.setDepthRange(lightNumber, this._depthRange);\r\n } else {\r\n this._texture.setViewMatrix(this._viewMatrix);\r\n this._texture.setProjection(this._projection);\r\n this._texture.setDepthRange(this._depthRange);\r\n }\r\n },\r\n\r\n // we know the scene is empty so we don't draw it\r\n // but we still camera clear it.\r\n // but we want to mark the uniform so that receiver shader can do\r\n // an early out.\r\n // ie: in shader, no texfetch\r\n markSceneAsNoShadow: function() {\r\n this.setShadowUniformsReceive(true);\r\n // we still clear the shadow so we filled it\r\n this._needRedraw = false;\r\n },\r\n\r\n // Defines the frustum from light param.\r\n //\r\n cullShadowCasting: function(cullVisitor, bbox) {\r\n if (this._debug) {\r\n var min = bbox.getMin();\r\n var max = bbox.getMax();\r\n bbox.center(this._tmpVec);\r\n var matrix = this._debugNodeSceneCast.getMatrix();\r\n\r\n mat4.fromScaling(matrix, [max[0] - min[0], max[1] - min[1], max[2] - min[2], 1]);\r\n mat4.setTranslation(matrix, this._tmpVec);\r\n }\r\n\r\n this._emptyCasterScene = false;\r\n this.aimShadowCastingCamera(cullVisitor, bbox);\r\n\r\n if (this._emptyCasterScene) {\r\n // nothing to draw, tell receiver to do early out\r\n // ie: in shader, no texfetch\r\n this.markSceneAsNoShadow();\r\n // Early out, no need to traverse scene either\r\n return;\r\n }\r\n\r\n // get renderer to make the cull program\r\n // record the traversal mask on entry so we can reapply it later.\r\n var traversalMask = cullVisitor.getTraversalMask();\r\n\r\n cullVisitor.setTraversalMask(this._castsShadowDrawTraversalMask);\r\n\r\n // cast geometries into depth shadow map\r\n cullVisitor.pushStateSet(this._casterStateSet);\r\n\r\n this._cameraShadow.setEnableFrustumCulling(true);\r\n this._cameraShadow.setComputeNearFar(true);\r\n\r\n if (this._debug) {\r\n this._debugNode.accept(cullVisitor);\r\n }\r\n\r\n // do RTT from the camera traversal mimicking light pos/orient\r\n this._cameraShadow.accept(cullVisitor);\r\n\r\n // make sure no negative near\r\n this.nearFarBounding();\r\n\r\n // Here culling is done, we do have near/far.\r\n // and cull/non-culled info\r\n // if we wanted a tighter frustum.\r\n this.frameShadowCastingFrustum(cullVisitor);\r\n\r\n // disabling to prevent cullvisitor breaking\r\n // the projection matrix by \"clamping\" it\r\n this._cameraShadow.setComputeNearFar(false);\r\n\r\n cullVisitor.popStateSet();\r\n\r\n // re-apply the original traversal mask\r\n cullVisitor.setTraversalMask(traversalMask);\r\n this._needRedraw = false;\r\n },\r\n\r\n cleanReceivingStateSet: function(ignoreTexture) {\r\n if (this._receivingStateset) {\r\n if (\r\n this._receivingStateset.getAttribute(\r\n this._shadowReceiveAttribute.getTypeMember()\r\n ) === this._shadowReceiveAttribute\r\n )\r\n this._receivingStateset.removeAttribute(\r\n this._shadowReceiveAttribute.getTypeMember()\r\n );\r\n\r\n if (ignoreTexture) return;\r\n\r\n if (this._texture) {\r\n // remove this._texture, but not if it's not this._texture\r\n if (\r\n this._receivingStateset.getTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n ) === this._texture\r\n )\r\n this._receivingStateset.removeTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n );\r\n }\r\n }\r\n },\r\n cleanSceneGraph: function(ignoreTexture) {\r\n // well release a lot more things when it works\r\n this._needRedraw = true;\r\n this.cleanReceivingStateSet(ignoreTexture);\r\n // TODO: need state\r\n //this._texture.releaseGLObjects();\r\n //this._shadowReceiveAttribute = undefined;\r\n this._texture = undefined;\r\n this._shadowedScene = undefined;\r\n },\r\n\r\n setDebug: function(enable) {\r\n if (enable && !this._debug) {\r\n if (!this._debugNode) {\r\n this._debugGeomFrustum = Debug.createDebugFrustumGeometry();\r\n\r\n this._debugGeomSceneCast = Shape.createBoundingBoxGeometry();\r\n\r\n this._debugGeomSceneCast.getPrimitives()[0].mode = primitiveSet.LINES;\r\n\r\n this._debugNode = new MatrixTransform();\r\n this._debugNodeFrustum = new MatrixTransform();\r\n this._debugNodeSceneCast = new MatrixTransform();\r\n\r\n this._debugNodeFrustum.addChild(this._debugGeomFrustum);\r\n this._debugNodeSceneCast.addChild(this._debugGeomSceneCast);\r\n\r\n this._debugNode.addChild(this._debugNodeFrustum);\r\n this._debugNode.addChild(this._debugNodeSceneCast);\r\n }\r\n }\r\n this._debug = enable;\r\n },\r\n getDebug: function() {\r\n return this._debug;\r\n },\r\n getLightNumber: function() {\r\n return this._light.getLightNumber();\r\n },\r\n\r\n getLight: function() {\r\n return this._light;\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowMap'\r\n);\r\n\r\nShadowMap.EPSILON = 5e-3;\r\n\r\nexport default ShadowMap;\r\n","import notify from '../osg/notify';\r\nimport Texture from '../osg/Texture';\r\nimport ShadowTexture from './ShadowTexture';\r\nimport Uniform from '../osg/Uniform';\r\nimport utils from '../osg/utils';\r\nimport { vec2 } from '../osg/glMatrix';\r\n\r\n/**\r\n * ShadowTexture Attribute encapsulate Texture webgl object\r\n * with Shadow specificities (no need of texcoord,fragtexcoord)\r\n * trigger hash change when changing texture precision from float to byt\r\n * shadowSettings.js header for param explanations\r\n * @class ShadowTextureAtlas\r\n * @inherits TextureAttribute\r\n */\r\nvar ShadowTextureAtlas = function() {\r\n Texture.call(this);\r\n\r\n this._uniforms = {};\r\n this._lightNumberArray = []; // default for a valid cloneType\r\n\r\n this._viewMatrices = [];\r\n this._projection = [];\r\n this._depthRanges = [];\r\n this._mapSizes = [];\r\n this._renderSize = vec2.create();\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nShadowTextureAtlas.uniforms = {};\r\n/** @lends Texture.prototype */\r\n\r\nutils.createPrototypeStateAttribute(\r\n ShadowTextureAtlas,\r\n utils.objectInherit(Texture.prototype, {\r\n cloneType: function() {\r\n return new ShadowTextureAtlas();\r\n },\r\n\r\n getLightNumberArray: function() {\r\n return this._lightNumberArray;\r\n },\r\n\r\n hasLightNumber: function(lightNum) {\r\n return this._lightNumberArray.indexOf(lightNum) !== -1;\r\n },\r\n\r\n setLightNumberArray: function(lightNumberArray) {\r\n this._lightNumberArray = lightNumberArray;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getUniformName: function(lightNumber, name) {\r\n var prefix = 'Shadow_' + this.getType() + lightNumber.toString();\r\n return 'u' + prefix + '_' + name;\r\n },\r\n\r\n setInternalFormatType: function(value) {\r\n Texture.prototype.setInternalFormatType.call(this, value);\r\n this._dirtyHash = true;\r\n },\r\n\r\n createUniforms: function(lightNumber, uniforms) {\r\n uniforms['ViewRight_' + lightNumber] = Uniform.createFloat4(\r\n this.getUniformName(lightNumber, 'viewRight')\r\n );\r\n uniforms['ViewUp_' + lightNumber] = Uniform.createFloat4(\r\n this.getUniformName(lightNumber, 'viewUp')\r\n );\r\n uniforms['ViewLook_' + lightNumber] = Uniform.createFloat4(\r\n this.getUniformName(lightNumber, 'viewLook')\r\n );\r\n\r\n uniforms['Projection_' + lightNumber] = Uniform.createFloat3(\r\n this.getUniformName(lightNumber, 'projection')\r\n );\r\n uniforms['DepthRange_' + lightNumber] = Uniform.createFloat2(\r\n this.getUniformName(lightNumber, 'depthRange')\r\n );\r\n uniforms['MapSize_' + lightNumber] = Uniform.createFloat4(\r\n this.getUniformName(lightNumber, 'mapSize')\r\n );\r\n uniforms['RenderSize_' + lightNumber] = uniforms['RenderSize'];\r\n },\r\n\r\n getOrCreateUniforms: function(unit) {\r\n // uniform are once per CLASS attribute, not per instance\r\n var obj = ShadowTextureAtlas;\r\n notify.assert(unit !== undefined || this._lightNumberArray.length !== 0);\r\n\r\n if (obj.uniforms[unit] !== undefined) {\r\n return obj.uniforms[unit];\r\n }\r\n\r\n var uniforms = (obj.uniforms[unit] = {});\r\n\r\n // shadowmap texture size used for texel space which is viewport independant\r\n var renderSizeUniform = Uniform.createFloat2(this.getUniformName(0, 'renderSize'));\r\n uniforms['RenderSize'] = renderSizeUniform;\r\n\r\n for (var i = 0, l = this._lightNumberArray.length; i < l; i++) {\r\n this.createUniforms(this._lightNumberArray[i], uniforms);\r\n }\r\n\r\n // Dual Uniform of texture, needs:\r\n // - Sampler (type of texture)\r\n // - Int (texture unit)\r\n // tells Shader Program where to find it\r\n var name = 'Texture' + unit;\r\n var uniform = Uniform.createInt1(unit, name);\r\n uniforms[name] = uniform;\r\n\r\n return obj.uniforms[unit];\r\n },\r\n\r\n setViewMatrix: function(lightNumber, viewMatrix) {\r\n this._viewMatrices[lightNumber] = viewMatrix;\r\n },\r\n\r\n setProjection: function(lightNumber, projection) {\r\n this._projection[lightNumber] = projection;\r\n },\r\n\r\n setDepthRange: function(lighNumber, depthRange) {\r\n this._depthRanges[lighNumber] = depthRange;\r\n },\r\n\r\n setLightShadowMapSize: function(lightNumber, dimension) {\r\n this._mapSizes[lightNumber] = dimension;\r\n },\r\n\r\n apply: function(state, texUnit) {\r\n // Texture stuff: call parent class method\r\n Texture.prototype.apply.call(this, state, texUnit);\r\n\r\n if (this._lightNumberArray.length === 0) {\r\n return;\r\n }\r\n\r\n // update Uniforms\r\n var uniformMap = this.getOrCreateUniforms(texUnit);\r\n\r\n for (var i = 0, l = this._lightNumberArray.length; i < l; i++) {\r\n var lightNumber = this._lightNumberArray[i];\r\n\r\n if (!uniformMap['ViewRight_' + lightNumber]) {\r\n // enable disable uniforms and yet using getOrCreate\r\n this.createUniforms(lightNumber, uniformMap);\r\n }\r\n\r\n ShadowTexture.prototype._updateViewMatrixUniforms.call(\r\n this,\r\n this._viewMatrices[lightNumber],\r\n uniformMap['ViewRight_' + lightNumber],\r\n uniformMap['ViewUp_' + lightNumber],\r\n uniformMap['ViewLook_' + lightNumber]\r\n );\r\n\r\n uniformMap['Projection_' + lightNumber].setFloat3(this._projection[lightNumber]);\r\n uniformMap['DepthRange_' + lightNumber].setFloat2(this._depthRanges[lightNumber]);\r\n uniformMap['MapSize_' + lightNumber].setFloat4(this._mapSizes[lightNumber]);\r\n }\r\n\r\n uniformMap['RenderSize'].setFloat2(this._renderSize);\r\n },\r\n\r\n setTextureSize: function(w, h) {\r\n this._renderSize[0] = 1.0 / w;\r\n this._renderSize[1] = 1.0 / h;\r\n Texture.prototype.setTextureSize.call(this, w, h);\r\n this.dirty();\r\n },\r\n\r\n _computeInternalHash: function() {\r\n var hash = this.getTypeMember();\r\n for (var i = 0, l = this._lightNumberArray.length; i < l; i++) {\r\n hash += '_' + this._lightNumberArray[i];\r\n }\r\n hash += '_' + this._type;\r\n return hash;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowTextureAtlas'\r\n);\r\n\r\nexport default ShadowTextureAtlas;\r\n","import notify from '../osg/notify';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport Camera from '../osg/Camera';\r\nimport utils from '../osg/utils';\r\nimport ShadowTechnique from './ShadowTechnique';\r\nimport ShadowTextureAtlas from './ShadowTextureAtlas';\r\nimport ShadowMap from './ShadowMap';\r\nimport Texture from '../osg/Texture';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport Uniform from '../osg/Uniform';\r\nimport Viewport from '../osg/Viewport';\r\n\r\n/**\r\n * ShadowMapAtlas provides an implementation of shadow textures.\r\n * here, one shadow\r\n * @class ShadowMapAtlas\r\n */\r\nvar ShadowMapAtlas = function(settings) {\r\n this._lights = [];\r\n this._shadowMaps = [];\r\n this._viewportDimension = [];\r\n\r\n ShadowTechnique.apply(this, arguments);\r\n this._shadowSettings = settings;\r\n this._texture = new ShadowTextureAtlas();\r\n this._textureUnitBase = 4;\r\n this._textureUnit = this._textureUnitBase;\r\n\r\n // see shadowSettings.js header for param explanations\r\n this._textureMagFilter = undefined;\r\n this._textureMinFilter = undefined;\r\n\r\n this._textureSize = 1024;\r\n this._shadowMapSize = 256;\r\n\r\n this._receivingStateset = undefined;\r\n\r\n this._shaderProcessor = undefined;\r\n\r\n if (settings) {\r\n this.setShadowSettings(settings);\r\n if (settings.atlasSize) this._textureSize = settings.atlasSize;\r\n if (settings.textureSize) this._shadowMapSize = settings.textureSize;\r\n }\r\n\r\n this._texelSizeUniform = Uniform.createFloat1(1.0 / this._textureSize, 'texelSize');\r\n\r\n var unifRenderSize = Uniform.createFloat2('RenderSize');\r\n this._renderSize = unifRenderSize.getInternalArray();\r\n this._renderSize[0] = this._renderSize[1] = this._textureSize;\r\n\r\n this._numShadowWidth = this._textureSize / this._shadowMapSize;\r\n this._numShadowHeight = this._textureSize / this._shadowMapSize;\r\n\r\n this._cameraClear = new Camera();\r\n this._cameraClear.setName('shadowAtlasCameraClear');\r\n this._cameraClear.setRenderOrder(Camera.PRE_RENDER, 0);\r\n this._cameraClear.setClearColor(vec4.fromValues(1.0, 1.0, 1.0, 1.0));\r\n this._cameraClear.setFrameBufferObject(new FrameBufferObject());\r\n this._cameraClear.setClearMask(0x0);\r\n};\r\n\r\n/** @lends ShadowMapAtlas.prototype */\r\nutils.createPrototypeObject(\r\n ShadowMapAtlas,\r\n utils.objectInherit(ShadowTechnique.prototype, {\r\n getTexture: function() {\r\n return this._texture;\r\n },\r\n\r\n isDirty: function(ligthtIndex) {\r\n if (ligthtIndex !== undefined) {\r\n return this._shadowMaps[ligthtIndex].isDirty();\r\n } else {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n if (this._shadowMaps[i].isDirty()) return true;\r\n }\r\n }\r\n return false;\r\n },\r\n /**\r\n * at which Texture unit number we start adding texture shadow\r\n */\r\n setTextureUnitBase: function(unitBase) {\r\n this._textureUnitBase = unitBase;\r\n this._textureUnit = unitBase;\r\n\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setTextureUnitBase(unitBase);\r\n }\r\n },\r\n\r\n /* Sets shadowSettings\r\n */\r\n setShadowSettings: function(shadowSettings) {\r\n if (!shadowSettings) return;\r\n this._shadowSettings = shadowSettings;\r\n\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++)\r\n this._shadowMaps[i].setShadowSettings(shadowSettings);\r\n\r\n this.setTextureSize(shadowSettings.textureSize);\r\n this.setTexturePrecision(shadowSettings.textureType);\r\n },\r\n\r\n setCastsShadowDrawTraversalMask: function(mask) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setCastsShadowDrawTraversalMask(mask);\r\n }\r\n },\r\n\r\n getCastsShadowDrawTraversalMask: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getCastsShadowDrawTraversalMask();\r\n } else if (this._shadowMaps.length !== 0) {\r\n return this._shadowMaps[0].getCastsShadowDrawTraversalMask();\r\n }\r\n },\r\n\r\n setCastsShadowBoundsTraversalMask: function(mask) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setCastsShadowBoundsTraversalMask(mask);\r\n }\r\n },\r\n\r\n getCastsShadowBoundsTraversalMask: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getCastsShadowDrawTraversalMask();\r\n } else if (this._shadowMaps.length !== 0) {\r\n return this._shadowMaps[0].getCastsShadowDrawTraversalMask();\r\n }\r\n },\r\n\r\n getNormalBias: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getNormalBias();\r\n } else if (this._shadowMaps.length !== 0) {\r\n return this._shadowMaps[0].getNormalBias();\r\n }\r\n },\r\n\r\n setNormalBias: function(value) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setNormalBias(value);\r\n }\r\n },\r\n\r\n getBias: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getBias();\r\n } else if (this._shadowMaps.length !== 0) {\r\n return this._shadowMaps[0].getBias();\r\n }\r\n },\r\n\r\n setBias: function(value) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setBias(value);\r\n }\r\n },\r\n\r\n getKernelSizePCF: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getKernelSizePCF();\r\n } else if (this._shadowMaps.length !== 1) {\r\n return this._shadowMaps[0].getKernelSizePCF();\r\n }\r\n },\r\n\r\n setKernelSizePCF: function(value) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setKernelSizePCF(value);\r\n }\r\n },\r\n\r\n setShadowedScene: function(shadowedScene) {\r\n ShadowTechnique.prototype.setShadowedScene.call(this, shadowedScene);\r\n this._receivingStateset = this._shadowedScene.getReceivingStateSet();\r\n\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setShadowedScene(shadowedScene);\r\n }\r\n },\r\n\r\n setTexturePrecision: function(value) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setTexturePrecision(value);\r\n }\r\n },\r\n\r\n getTexturePrecision: function(numShadow) {\r\n if (numShadow !== undefined) {\r\n return this._shadowMaps[numShadow].getTexturePrecision();\r\n } else if (this._shadowMaps.length !== 1) {\r\n return this._shadowMaps[0].getTexturePrecision();\r\n }\r\n },\r\n\r\n setTextureSize: function(mapSize) {\r\n if (mapSize === this._textureSize) return;\r\n\r\n //this._textureSize = mapSize;\r\n //this._textureSize = settings.atlasSize;\r\n this._shadowMapSize = mapSize;\r\n\r\n this._numShadowWidth = this._textureSize / this._shadowMapSize;\r\n this._numShadowHeight = this._textureSize / this._shadowMapSize;\r\n\r\n this.dirty();\r\n },\r\n\r\n getShadowMap: function(lightNum) {\r\n return this._shadowMaps[lightNum];\r\n },\r\n\r\n addLight: function(light) {\r\n if (!light || this._lights.indexOf(light) !== -1) {\r\n notify.warn('no light or light already added');\r\n return -1;\r\n }\r\n\r\n var lightCount = this._lights.length;\r\n if (lightCount === this._numShadowWidth * this._numShadowHeight) {\r\n notify.warn(\r\n \"can't allocate shadow for light \" +\r\n light.getLightNumber() +\r\n ' ShadowAtlas already full '\r\n );\r\n return undefined;\r\n }\r\n\r\n this._lights.push(light);\r\n this._shadowSettings.setLight(light);\r\n\r\n var shadowMap = new ShadowMap(this._shadowSettings, this._texture);\r\n this._shadowMaps.push(shadowMap);\r\n\r\n if (this._shadowedScene) shadowMap.setShadowedScene(this._shadowedScene);\r\n\r\n this.recomputeViewports();\r\n\r\n return shadowMap;\r\n },\r\n\r\n /** initialize the ShadowedScene and local cached data structures.*/\r\n init: function() {\r\n if (!this._shadowedScene) return;\r\n\r\n this.initTexture();\r\n var lightNumberArray = [];\r\n for (var k = 0; k < this._lights.length; k++) {\r\n lightNumberArray.push(this._lights[k].getLightNumber());\r\n }\r\n this._texture.setLightNumberArray(lightNumberArray);\r\n\r\n this._textureUnit = this._textureUnitBase;\r\n this._texture.setName('ShadowTexture' + this._textureUnit);\r\n\r\n var unifRenderSize = Uniform.createFloat2('RenderSize');\r\n this._texelSizeUniform = Uniform.createFloat1(1.0 / this._textureSize, 'texelSize');\r\n this._renderSize = unifRenderSize.getInternalArray();\r\n this._renderSize[0] = this._renderSize[1] = this._textureSize;\r\n\r\n this.recomputeViewports();\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n var shadowMap = this._shadowMaps[i];\r\n\r\n if (!this._shadowedScene)\r\n this._shadowedScene = shadowMap.getShadowedScene(this._shadowedScene);\r\n if (this._shadowedScene) shadowMap.setShadowedScene(this._shadowedScene);\r\n shadowMap.init(this._texture, i, this._textureUnitBase);\r\n }\r\n },\r\n\r\n recomputeViewports: function() {\r\n var numViews = this._shadowMaps.length;\r\n\r\n var viewDivideY = numViews > 2 ? Math.sqrt(2 * Math.ceil(numViews / 2)) : numViews;\r\n var viewDivideX = viewDivideY;\r\n\r\n var mapSizeX = this._textureSize / viewDivideX;\r\n var mapSizeY = this._textureSize / viewDivideY;\r\n\r\n var numShadowWidth = this._textureSize / mapSizeX;\r\n var numShadowHeight = this._textureSize / mapSizeY;\r\n\r\n for (var i = 0; i < numViews; i++) {\r\n var shadowMap = this._shadowMaps[i];\r\n\r\n var x = mapSizeX * (i % numShadowWidth);\r\n var y = mapSizeY * Math.floor(i / numShadowHeight);\r\n\r\n if (this._viewportDimension.length <= i) {\r\n this._viewportDimension.push(vec4.fromValues(x, y, mapSizeX, mapSizeY));\r\n } else {\r\n vec4.set(this._viewportDimension[i], x, y, mapSizeX, mapSizeY);\r\n }\r\n\r\n this._texture.setLightShadowMapSize(\r\n this._lights[i].getLightNumber(),\r\n this._viewportDimension[i]\r\n );\r\n\r\n shadowMap.dirty();\r\n }\r\n },\r\n\r\n valid: function() {\r\n // checks\r\n return true;\r\n },\r\n\r\n updateCameraClear: function() {\r\n var camera = this._cameraClear;\r\n var texture = this._texture;\r\n\r\n if (camera && texture) {\r\n var vp = camera.getViewport();\r\n\r\n if (!vp) {\r\n vp = new Viewport();\r\n camera.setViewport(vp);\r\n }\r\n\r\n // if texture size changed update the camera rtt params\r\n if (vp.width() !== texture.getWidth() || vp.height() !== texture.getHeight()) {\r\n camera.detachAll();\r\n\r\n camera.attachTexture(FrameBufferObject.COLOR_ATTACHMENT0, texture);\r\n camera.attachRenderBuffer(\r\n FrameBufferObject.DEPTH_ATTACHMENT,\r\n FrameBufferObject.DEPTH_COMPONENT16\r\n );\r\n camera.getViewport().setViewport(0, 0, texture.getWidth(), texture.getHeight());\r\n }\r\n }\r\n },\r\n\r\n updateShadowTechnique: function(nv) {\r\n this.updateCameraClear();\r\n var fbo = this._cameraClear.getFrameBufferObject();\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].updateShadowTechnique(nv, this._viewportDimension[i], fbo);\r\n }\r\n },\r\n\r\n // internal texture allocation\r\n // handle any change like resize, filter param, etc.\r\n initTexture: function() {\r\n if (!this._dirty) return;\r\n\r\n if (!this._texture) {\r\n this._texture = new ShadowTextureAtlas();\r\n this._textureUnit = this._textureUnitBase;\r\n }\r\n\r\n this._texture.setTextureSize(this._textureSize, this._textureSize);\r\n this._texelSizeUniform.setFloat(1.0 / this._textureSize);\r\n this._renderSize[0] = this._textureSize;\r\n this._renderSize[1] = this._textureSize;\r\n\r\n var textureFormat;\r\n // luminance Float format ?\r\n textureFormat = Texture.RGBA;\r\n\r\n ShadowMap.prototype.setTextureFiltering.call(this);\r\n this._texture.setInternalFormat(textureFormat);\r\n\r\n this._texture.setWrapS(Texture.CLAMP_TO_EDGE);\r\n this._texture.setWrapT(Texture.CLAMP_TO_EDGE);\r\n\r\n this._texture.dirty();\r\n },\r\n\r\n // Defines the frustum from light param.\r\n //\r\n cullShadowCasting: function(cullVisitor, bbox) {\r\n this._cameraClear.accept(cullVisitor);\r\n\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n var shadowMap = this._shadowMaps[i];\r\n if (shadowMap.isContinuousUpdate() || shadowMap.needRedraw()) {\r\n shadowMap.cullShadowCasting(cullVisitor, bbox);\r\n }\r\n }\r\n },\r\n\r\n isContinuousUpdate: function() {\r\n // need at least one shadow to be enabled\r\n // so that shadowedScene will continue shadowCasting\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n if (this._shadowMaps[i].isContinuousUpdate()) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n\r\n needRedraw: function() {\r\n // need at least one shadow not dirty\r\n // so that shadowedScene will continue shadowCasting\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n if (this._shadowMaps[i].needRedraw()) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n\r\n removeShadowMap: function(shadowMap) {\r\n if (this._shadowMaps.length > 0) {\r\n var idx = this._shadowMaps.indexOf(shadowMap);\r\n if (idx !== -1) {\r\n if (this._shadowMaps[idx].valid()) {\r\n this._shadowMaps[idx].cleanSceneGraph(true);\r\n }\r\n this._shadowMaps.splice(idx, 1);\r\n\r\n var lightNumberArray = this._texture.getLightNumberArray();\r\n idx = lightNumberArray.indexOf(shadowMap.getLightNumber());\r\n if (idx !== -1) lightNumberArray.splice(idx, 1);\r\n\r\n var light = shadowMap.getLight();\r\n idx = this._lights.indexOf(light);\r\n if (idx !== -1) this._lights.splice(idx, 1);\r\n\r\n if (this._viewportDimension.length > idx) {\r\n this._viewportDimension.splice(idx, 1);\r\n }\r\n\r\n this.recomputeViewports();\r\n }\r\n }\r\n },\r\n\r\n addShadowMap: function(shadowMap) {\r\n if (this._shadowMaps.length > 0) {\r\n if (this._shadowMaps.indexOf(shadowMap) !== -1) return;\r\n }\r\n\r\n this._shadowMaps.push(shadowMap);\r\n\r\n var light = shadowMap.getLight();\r\n if (this._lights.indexOf(light) === -1) {\r\n this._lights.push(light);\r\n }\r\n\r\n if (this._shadowedScene) shadowMap.setShadowedScene(this._shadowedScene);\r\n\r\n var lightNumberArray = this._texture.getLightNumberArray();\r\n if (lightNumberArray.indexOf(shadowMap.getLightNumber()) === -1) {\r\n lightNumberArray.push(light.getLightNumber());\r\n }\r\n\r\n this.recomputeViewports();\r\n },\r\n\r\n cleanReceivingStateSet: function() {\r\n if (this._receivingStateset) {\r\n if (this._texture) {\r\n // remove this._texture, but not if it's not this._texture\r\n if (\r\n this._receivingStateset.getTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n ) === this._texture\r\n )\r\n this._receivingStateset.removeTextureAttribute(\r\n this._textureUnit,\r\n this._texture.getTypeMember()\r\n );\r\n }\r\n\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].cleanReceivingStateSet();\r\n }\r\n }\r\n },\r\n cleanSceneGraph: function() {\r\n // TODO: need state\r\n //this._texture.releaseGLObjects();\r\n //this._shadowReceiveAttribute = undefined;\r\n this._texture = undefined;\r\n this._shadowedScene = undefined;\r\n },\r\n setDebug: function(enable, lightNum) {\r\n if (!lightNum) {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].setDebug(enable);\r\n }\r\n } else {\r\n this._shadowMaps[lightNum].setDebug(enable);\r\n }\r\n },\r\n markSceneAsNoShadow: function() {\r\n for (var i = 0, l = this._shadowMaps.length; i < l; i++) {\r\n this._shadowMaps[i].markSceneAsNoShadow();\r\n }\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowMapAtlas'\r\n);\r\n\r\nexport default ShadowMapAtlas;\r\n","import utils from '../osg/utils';\r\nimport Texture from '../osg/Texture';\r\n\r\nvar kernelSizeList = [\r\n '1Tap(4texFetch)',\r\n '4Tap(16texFetch)',\r\n '9Tap(36texFetch)',\r\n '16Tap(64texFetch)'\r\n];\r\n\r\n/**\r\n * ShadowSettings provides the parameters that the ShadowTechnique should use as a guide for setting up shadowing\r\n * @class ShadowSettings\r\n */\r\nvar ShadowSettings = function(options) {\r\n this.castsShadowDrawTraversalMask = 0xffffffff;\r\n this.castsShadowBoundsTraversalMask = 0xffffffff;\r\n\r\n this.textureSize = 1024;\r\n\r\n // important note:\r\n // comparison shadow is: DepthShadow > DephFragment => shadowed\r\n // which is d<z\r\n // and\r\n // Average( (d < z) ) != (Average( z ) < d)\r\n // so PCF/NONE technique cannot be prefiltered (bilinear, etc..) with HW filter\r\n // on gl/dx desktop there is a sampler2DShadow that allows that taking z in third param\r\n // we emulate that with texture2DShadowLerp\r\n // which is why some techniques have more texfetch than advertized.\r\n // http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html\r\n\r\n // texture precision. (and bandwith implication)\r\n this.textureType = 'UNSIGNED_BYTE';\r\n\r\n this.textureFormat = Texture.RGBA;\r\n\r\n // either orthogonal (non-fov) or perpsective (fov)\r\n this.shadowProjection = 'fov';\r\n // fov size: can be infered from spotlight angle\r\n this.fov = 50;\r\n\r\n // PCF algo and kernel size\r\n // Band kernelsize gives nxn texFetch\r\n // others a n*n*4 (emulating the HW shadowSampler)\r\n // ['4Tap(16texFetch)', '9Tap(36texFetch)', '16Tap(64texFetch)']\r\n this.kernelSizePCF = '4Tap(4texFetch)';\r\n\r\n // depth offset (shadow acne / peter panning)\r\n this.bias = 0.005;\r\n\r\n // normal exploding offset (shadow acne / peter panning)\r\n this.normalBias = undefined;\r\n\r\n // defaut shader generator name for shadow casting\r\n this.shadowCastShaderGeneratorName = 'ShadowCast';\r\n\r\n // if url options override url options\r\n utils.objectMix(this, options);\r\n};\r\n\r\nShadowSettings.kernelSizeList = kernelSizeList;\r\n\r\nShadowSettings.prototype = {\r\n setCastsShadowDrawTraversalMask: function(mask) {\r\n this.castsShadowDrawTraversalMask = mask;\r\n },\r\n getCastsShadowDrawTraversalMask: function() {\r\n return this.castsDrawShadowTraversalMask;\r\n },\r\n\r\n setCastsShadowBoundsTraversalMask: function(mask) {\r\n this.castsShadowBoundsTraversalMask = mask;\r\n },\r\n getCastsShadowBoundsTraversalMask: function() {\r\n return this.castsShadowBoundsTraversalMask;\r\n },\r\n\r\n setLight: function(light) {\r\n this.light = light;\r\n },\r\n getLight: function() {\r\n return this.light;\r\n },\r\n\r\n setTextureSize: function(textureSize) {\r\n this.textureSize = textureSize;\r\n },\r\n getTextureSize: function() {\r\n return this.textureSize;\r\n },\r\n setTextureType: function(tt) {\r\n this.textureType = tt;\r\n },\r\n getTextureType: function() {\r\n return this.textureType;\r\n },\r\n setTextureFormat: function(tf) {\r\n this.textureFormat = tf;\r\n },\r\n getTextureFormat: function() {\r\n return this.textureFormat;\r\n },\r\n setShadowCastShaderGeneratorName: function(n) {\r\n this.shadowCastShaderGeneratorName = n;\r\n },\r\n getShadowCastShaderGeneratorName: function() {\r\n return this.shadowCastShaderGeneratorName;\r\n }\r\n};\r\n\r\nexport default ShadowSettings;\r\n","import CullVisitor from '../osg/CullVisitor';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Node from '../osg/Node';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport StateSet from '../osg/StateSet';\r\nimport utils from '../osg/utils';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport ComputeBoundsVisitor from '../osg/ComputeBoundsVisitor';\r\nimport ShadowCasterVisitor from './ShadowCasterVisitor';\r\n\r\n/**\r\n * ShadowedScene provides a mechanism for decorating a scene that the needs to have shadows cast upon it.\r\n * @class ShadowedScene\r\n * @{@link [http://trac.openscenegraph.org/projects/osg//wiki/Support/ProgrammingGuide/osgShadow]}\r\n * @{@link [http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf]};\r\n */\r\nvar ShadowedScene = function(settings) {\r\n Node.call(this);\r\n\r\n // TODO: all techniques (stencil/projTex/map/vol)\r\n this._shadowTechniques = [];\r\n\r\n this._optimizedFrustum = false;\r\n\r\n this._frustumReceivers = [\r\n vec4.create(),\r\n vec4.create(),\r\n vec4.create(),\r\n vec4.create(),\r\n vec4.create(),\r\n vec4.create()\r\n ];\r\n\r\n this._tmpMat = mat4.create();\r\n\r\n this._receivingStateset = new StateSet();\r\n\r\n this._computeBoundsVisitor = new ComputeBoundsVisitor();\r\n\r\n this._castsShadowDrawTraversalMask = 0xffffffff;\r\n this._castsShadowBoundsTraversalMask = 0xffffffff;\r\n if (settings) this.setShadowSettings(settings);\r\n};\r\n\r\n/** @lends ShadowedScene.prototype */\r\nutils.createPrototypeNode(\r\n ShadowedScene,\r\n utils.objectInherit(Node.prototype, {\r\n getReceivingStateSet: function() {\r\n return this._receivingStateset;\r\n },\r\n\r\n getShadowTechniques: function() {\r\n return this._shadowTechniques;\r\n },\r\n\r\n addShadowTechnique: function(technique) {\r\n if (this._shadowTechniques.length > 0) {\r\n if (this._shadowTechniques.indexOf(technique) !== -1) return;\r\n }\r\n\r\n this._shadowTechniques.push(technique);\r\n\r\n if (technique.valid()) {\r\n technique.setShadowedScene(this);\r\n technique.dirty();\r\n }\r\n },\r\n removeShadowTechnique: function(technique) {\r\n if (this._shadowTechniques.length > 0) {\r\n var idx = this._shadowTechniques.indexOf(technique);\r\n if (idx !== -1) {\r\n if (this._shadowTechniques[idx].valid()) {\r\n this._shadowTechniques[idx].cleanSceneGraph();\r\n }\r\n this._shadowTechniques.splice(idx, 1);\r\n }\r\n }\r\n },\r\n /** Clean scene graph from any shadow technique specific nodes, state and drawables.*/\r\n cleanSceneGraph: function() {\r\n for (var i = 0, lt = this._shadowTechniques.length; i < lt; i++) {\r\n if (this._shadowTechniques[i] && this._shadowTechniques[i].valid()) {\r\n this._shadowTechniques[i].cleanSceneGraph();\r\n }\r\n }\r\n },\r\n\r\n /** Dirty any cache data structures held in the attached ShadowTechnique.*/\r\n dirty: function() {\r\n for (var i = 0; i < this._shadowTechniques.length; i++)\r\n this._shadowTechniques[i].dirty();\r\n },\r\n\r\n nodeTraverse: function(nv) {\r\n Node.prototype.traverse.call(this, nv);\r\n },\r\n\r\n setShadowSettings: function(shadowSettings) {\r\n this._settings = shadowSettings;\r\n\r\n this.setCastsShadowDrawTraversalMask(shadowSettings.castsShadowDrawTraversalMask);\r\n this.setCastsShadowBoundsTraversalMask(shadowSettings.castsShadowBoundsTraversalMask);\r\n\r\n // Overridable Visitor so that user can override the visitor to enable disable\r\n // in its own shadowmap implementation\r\n // settings.userShadowCasterVisitor:\r\n // - undefined means using default\r\n // - false means no removal visitor needed\r\n // - otherwise must be an instance of a class inherited from shadowCaster\r\n if (shadowSettings.userShadowCasterVisitor !== false) {\r\n this._removeNodesNeverCastingVisitor =\r\n shadowSettings.userShadowCasterVisitor ||\r\n new ShadowCasterVisitor(this._castsShadowTraversalMask);\r\n }\r\n },\r\n\r\n setCastsShadowDrawTraversalMask: function(mask) {\r\n this._castsShadowDrawTraversalMask = mask;\r\n },\r\n\r\n getCastsShadowDrawTraversalMask: function() {\r\n return this._castsDrawShadowTraversalMask;\r\n },\r\n\r\n setCastsShadowBoundsTraversalMask: function(mask) {\r\n this._castsShadowBoundsTraversalMask = mask;\r\n },\r\n\r\n getCastsShadowBoundsTraversalMask: function() {\r\n return this._castsShadowBoundsTraversalMask;\r\n },\r\n\r\n computeShadowedSceneBounds: function() {\r\n if (this._removeNodesNeverCastingVisitor) {\r\n this._removeNodesNeverCastingVisitor.setNoCastMask(\r\n ~(this._castsShadowBoundsTraversalMask | this._castsShadowDrawTraversalMask)\r\n );\r\n this._removeNodesNeverCastingVisitor.reset();\r\n this.accept(this._removeNodesNeverCastingVisitor);\r\n }\r\n\r\n this._computeBoundsVisitor.setTraversalMask(this._castsShadowBoundsTraversalMask);\r\n this._computeBoundsVisitor.reset();\r\n this.accept(this._computeBoundsVisitor);\r\n var bbox = this._computeBoundsVisitor.getBoundingBox();\r\n\r\n if (!bbox.valid()) {\r\n // nothing to draw Early out.\r\n if (this._removeNodesNeverCastingVisitor) {\r\n // remove our flags changes on any bitmask\r\n // not to break things\r\n this._removeNodesNeverCastingVisitor.restore();\r\n }\r\n\r\n return false;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n traverse: function(nv) {\r\n // update the scene\r\n if (nv.getVisitorType() === NodeVisitor.CULL_VISITOR) {\r\n var i,\r\n st,\r\n lt = this._shadowTechniques.length;\r\n\r\n // cull Shadowed Scene\r\n if (lt) nv.pushStateSet(this._receivingStateset);\r\n this.nodeTraverse(nv);\r\n if (lt) nv.popStateSet();\r\n\r\n var isDirty = false;\r\n for (i = 0; i < lt; i++) {\r\n st = this._shadowTechniques[i];\r\n\r\n // dirty check for user playing with shadows inside update traverse\r\n if (!st || !st.valid()) continue;\r\n\r\n if (st.isDirty()) {\r\n isDirty = true;\r\n st.init();\r\n }\r\n\r\n if (st.isContinuousUpdate() || st.needRedraw()) isDirty = true;\r\n }\r\n if (!isDirty) return;\r\n\r\n var hasCastingScene = this.computeShadowedSceneBounds(nv);\r\n if (!hasCastingScene) {\r\n // no shadow but still may need to clear\r\n // and makes sure shadow receiver shader\r\n // uses optimized early out codepath\r\n for (i = 0; i < lt; i++) {\r\n st = this._shadowTechniques[i];\r\n st.markSceneAsNoShadow();\r\n }\r\n\r\n return;\r\n }\r\n var bbox = this._computeBoundsVisitor.getBoundingBox();\r\n\r\n // HERE we get the shadowedScene Current World Matrix\r\n // to get any world transform ABOVE the shadowedScene\r\n var worldMatrix = nv.getCurrentModelMatrix();\r\n bbox.transformMat4(bbox, worldMatrix);\r\n\r\n // cull Casters\r\n for (i = 0; i < lt; i++) {\r\n st = this._shadowTechniques[i];\r\n if (st.isContinuousUpdate() || st.needRedraw()) {\r\n st.updateShadowTechnique(nv);\r\n st.cullShadowCasting(nv, bbox);\r\n }\r\n }\r\n\r\n if (this._removeNodesNeverCastingVisitor) {\r\n // remove our flags changes on any bitmask\r\n // not to break things\r\n this._removeNodesNeverCastingVisitor.restore();\r\n }\r\n } else {\r\n this.nodeTraverse(nv);\r\n }\r\n }\r\n }),\r\n 'osgShadow',\r\n 'ShadowedScene'\r\n);\r\n\r\n// same code like Node\r\nCullVisitor.registerApplyFunction(\r\n ShadowedScene.nodeTypeID,\r\n CullVisitor.getApplyFunction(Node.nodeTypeID)\r\n);\r\n\r\nexport default ShadowedScene;\r\n","import ShadowCastAttribute from './ShadowCastAttribute';\r\nimport ShadowCastCompiler from './ShadowCastCompiler';\r\nimport ShadowCastShaderGenerator from './ShadowCastShaderGenerator';\r\nimport ShadowCasterVisitor from './ShadowCasterVisitor';\r\nimport ShadowFrustumIntersection from './ShadowFrustumIntersection';\r\nimport ShadowMap from './ShadowMap';\r\nimport ShadowMapAtlas from './ShadowMapAtlas';\r\nimport ShadowReceiveAttribute from './ShadowReceiveAttribute';\r\nimport ShadowSettings from './ShadowSettings';\r\nimport ShadowTechnique from './ShadowTechnique';\r\nimport ShadowTexture from './ShadowTexture';\r\nimport ShadowTextureAtlas from './ShadowTextureAtlas';\r\nimport ShadowedScene from './ShadowedScene';\r\n\r\nvar osgShadow = {};\r\n\r\nosgShadow.ShadowCastAttribute = ShadowCastAttribute;\r\nosgShadow.ShadowCastCompiler = ShadowCastCompiler;\r\nosgShadow.ShadowReceiveAttribute = ShadowReceiveAttribute;\r\nosgShadow.ShadowCasterVisitor = ShadowCasterVisitor;\r\nosgShadow.ShadowFrustumIntersection = ShadowFrustumIntersection;\r\nosgShadow.ShadowMap = ShadowMap;\r\nosgShadow.ShadowMapAtlas = ShadowMapAtlas;\r\nosgShadow.ShadowedScene = ShadowedScene;\r\nosgShadow.ShadowSettings = ShadowSettings;\r\nosgShadow.ShadowCastShaderGenerator = ShadowCastShaderGenerator;\r\nosgShadow.ShadowTechnique = ShadowTechnique;\r\nosgShadow.ShadowTexture = ShadowTexture;\r\nosgShadow.ShadowTextureAtlas = ShadowTextureAtlas;\r\n\r\nexport default osgShadow;\r\n","import Config from './Config';\r\nimport osg from \"../osg/osg\";\r\n\r\nexport default function () {\r\n var maxUnits = osg.WebGLCaps.instance().getWebGLParameter(\r\n 'MAX_TEXTURE_IMAGE_UNITS',\r\n );\r\n return Math.min(maxUnits, Config.maxTextureUnits);\r\n}\r\n","\r\nimport StateAttributeRegister from '../StateAttributeRegister';\r\nimport StateAttribute from \"../../osg/StateAttribute\";\r\nimport osg from '../../osg/osg'\r\nclass PBRMaterial extends StateAttribute {\r\n constructor() {\r\n super();\r\n this._enableVertexColor = false;\r\n this._hasClearcoat = false;\r\n this._hasNormalMap = false;\r\n this._hasOpacityMap = false;\r\n this._opacityFactor = 1.0\r\n this._normalFactor = 1.0\r\n this._normalFlipY = 0\r\n this._depthWrite = true\r\n this._onlyDepthMaskNoShading = false\r\n this._displacementAmount = 1.0;\r\n this._cullFace = osg.CullFace.DISABLE\r\n this._unlit = false;\r\n this._invertAlpha = false\r\n this._metalnessWorkFlow = true \r\n this._clearcoatParam = [1.0, 0.3]\r\n }\r\n\r\n getHash() {\r\n return (\r\n this.getType() +\r\n (this._enableVertexColor ? 'VertexColor' : '') +\r\n (this._hasNormalMap ? 'NormalMap' : '') +\r\n (this._hasOpacityMap ? 'HasOpacityMap' : '') +\r\n (this._hasAOMap ? 'HasAOMap' : '') +\r\n (this._hasDisplacementMap ? 'HasDisplacementMap': '') +\r\n (this._onlyDepthMaskNoShading ? 'OnlyDepthMaskNoShading': '') +\r\n (this._unlit ? 'UnLit': '') +\r\n (this._invertAlpha ? 'InvertAlpha': '') +\r\n (this._metalnessWorkFlow ? 'MetalnessWorkFlow': '')\r\n \r\n );\r\n }\r\n\r\n cloneType() {\r\n return new PBRMaterial();\r\n }\r\n\r\n getType() {\r\n return this.attributeType;\r\n }\r\n\r\n getTypeMember() {\r\n return this.attributeType;\r\n }\r\n\r\n getMetalnessWorkFlow() {\r\n return this._metalnessWorkFlow;\r\n }\r\n\r\n setMetalnessWorkFlow(flag) {\r\n this._metalnessWorkFlow = flag;\r\n }\r\n\r\n getVertexColorEnable() {\r\n return this._enableVertexColor;\r\n }\r\n setVertexColorEnable(enable) {\r\n this._enableVertexColor = enable;\r\n }\r\n\r\n getHasNormalMap() {\r\n return this._hasNormalMap;\r\n }\r\n\r\n setHasNormalMap(value) {\r\n this._hasNormalMap = value;\r\n }\r\n\r\n getHasClearcoat() {\r\n return this._hasClearcoat;\r\n }\r\n\r\n setHasClaercoat(value) {\r\n this._hasClearcoat = value;\r\n }\r\n\r\n\r\n\r\n getOnlyDepthMaskNoShading() {\r\n return this._onlyDepthMaskNoShading\r\n }\r\n\r\n setOnlyDepthMaskNoShading(value) {\r\n this._onlyDepthMaskNoShading = value\r\n }\r\n\r\n getDepthWrite() {\r\n return this._depthWrite;\r\n }\r\n getCullFace () {\r\n return this._cullFace\r\n }\r\n setHasOpacityMap(value) {\r\n this._hasOpacityMap = value;\r\n this.updateOpacity()\r\n }\r\n\r\n getHasOpacityMap() {\r\n return this._hasOpacityMap;\r\n }\r\n\r\n setOpacityFactor(value) {\r\n this._opacityFactor = value\r\n this.updateOpacity()\r\n }\r\n getOpacityFactor() {\r\n return this._opacityFactor\r\n }\r\n\r\n setNormalFactor(value) {\r\n this._normalFactor = value\r\n }\r\n getNormalFactor() {\r\n return this._normalFactor\r\n }\r\n\r\n setDisplacementAmount(value) {\r\n this._displacementAmount = value\r\n }\r\n\r\n getDisplacementAmount() {\r\n return this._displacementAmount\r\n }\r\n\r\n setNormalFlipY(value) {\r\n this._normalFlipY = value ? 1: 0\r\n }\r\n getNormalFlipY() {\r\n return !!this._normalFlipY\r\n }\r\n\r\n updateOpacity() {\r\n this._depthWrite = true\r\n if(this._opacityFactor < 1.0) {\r\n this._depthWrite = false\r\n } \r\n else if(this._opacityFactor === 1.0 && this._hasOpacityMap) {\r\n this._depthWrite = true\r\n }\r\n }\r\n\r\n setHasAOMap(value) {\r\n this._hasAOMap = value\r\n }\r\n\r\n getHasAOMap() {\r\n return this._hasAOMap\r\n }\r\n\r\n setHasDisplacementMap(value){\r\n this._hasDisplacementMap = value\r\n }\r\n\r\n getHasDisplacementMap() {\r\n return this._hasDisplacementMap\r\n }\r\n\r\n setUnLit(value){\r\n this._unlit = value\r\n }\r\n getUnLit(){\r\n return this._unlit\r\n }\r\n\r\n enableInvertAlpha(value){\r\n this._invertAlpha = value\r\n }\r\n\r\n getOrCreateUniforms() {\r\n if (PBRMaterial.uniforms) return PBRMaterial.uniforms;\r\n var uniforms = (PBRMaterial.uniforms = {\r\n opacityFactor: osg.Uniform.createFloat('uOpacityFactor'),\r\n normalFactor: osg.Uniform.createFloat('uNormalMapFactor'),\r\n normalFlipY: osg.Uniform.createInt('uNormalMapFlipY'),\r\n displacementAmount: osg.Uniform.createFloat('uDisplacementAmount'),\r\n clearcoatParam: osg.Uniform.createFloat2('uClearcoatParam')\r\n });\r\n return uniforms;\r\n }\r\n\r\n apply() {\r\n var uniforms = this.getOrCreateUniforms();\r\n uniforms.opacityFactor.setFloat(this._opacityFactor);\r\n uniforms.normalFactor.setFloat(this._normalFactor);\r\n uniforms.normalFlipY.setInt(this._normalFlipY);\r\n uniforms.displacementAmount.setFloat(this._displacementAmount);\r\n uniforms.clearcoatParam.setFloat2(this._clearcoatParam)\r\n }\r\n}\r\n\r\nStateAttributeRegister(\r\n PBRMaterial,\r\n PBRMaterial.prototype,\r\n 'osgEditor',\r\n 'PBRMaterial',\r\n);\r\n\r\n//osg.objectLibraryClass(PBRMaterial.prototype, 'osgEditor', 'PBRMaterial');\r\n//osg.setTypeID(PBRMaterial);\r\n//PBRMaterial.prototype.attributeTypeId = utils.getOrCreateStateAttributeTypeId(PBRMaterial);\r\n//PBRMaterial.prototype.attributeType = 'PBRMaterial';\r\n\r\nexport default PBRMaterial;\r\n","import osg from '../osg/osg';\r\n\r\nimport StateAttribute from \"../osg/StateAttribute\";\r\nimport StateAttributeRegister from './StateAttributeRegister';\r\nvar isPowerOf2 = function (x) {\r\n return x !== 0 && (x & (~x + 1)) === x;\r\n};\r\nclass ChangeColorAttribute extends StateAttribute {\r\n constructor(texture) {\r\n super();\r\n this._attributeEnable = false\r\n this._valid = false\r\n this._texture = texture\r\n this.caclLod()\r\n this._targetColor = osg.vec3.fromValues(0.5, 0.5, 0.5)\r\n this._sourceLod = 0\r\n this._useMask = 1\r\n this._maskRange = osg.vec3.fromValues(30, 0.5, 0.5)\r\n\r\n this._useSourceColor = false\r\n this._sourceColor = osg.vec3.fromValues(0.5, 0.5, 0.5)\r\n }\r\n\r\n caclLod() {\r\n var texture = this._texture\r\n if(texture && texture.className() === 'Texture') {\r\n this._valid = true\r\n } else {\r\n return\r\n }\r\n var w = texture.getWidth()\r\n var h = texture.getHeight()\r\n if (w !== h || !isPowerOf2(w) || !isPowerOf2(h)) {\r\n this._valid = false\r\n return\r\n } else {\r\n this._valid = true\r\n }\r\n\r\n this._sourceLod = Math.max(Math.log2(w), 0)\r\n\r\n }\r\n\r\n cloneType() {\r\n return new ChangeColorAttribute(new osg.Texture());\r\n }\r\n getHash() {\r\n return this.getType() + (this._attributeEnable ? 1 : 0) + (this._valid ? 1 : 0) + (this._useSourceColor ? 1 : 0);\r\n }\r\n setEnabled(state) {\r\n this._attributeEnable = state;\r\n }\r\n\r\n isEnabled() {\r\n return this._attributeEnable;\r\n }\r\n\r\n setTexture(texture) {\r\n this._texture = texture\r\n this.caclLod()\r\n }\r\n\r\n setTargetColor(targetColor) {\r\n osg.vec3.copy(this._targetColor, targetColor);\r\n }\r\n\r\n enableMask(value) {\r\n this._useMask = value ? 1 : 0\r\n }\r\n\r\n setMaskRange(range) {\r\n osg.vec3.copy(this._maskRange, range);\r\n }\r\n\r\n enableSourceColor(value) {\r\n this._useSourceColor = !!value\r\n }\r\n\r\n isUseSourceColor() {\r\n return this._useSourceColor;\r\n }\r\n\r\n setSourceColor(sourceColor) {\r\n osg.vec3.copy(this._sourceColor, sourceColor);\r\n }\r\n\r\n getOrCreateUniforms() {\r\n if (ChangeColorAttribute.uniforms) return ChangeColorAttribute.uniforms;\r\n ChangeColorAttribute.uniforms = {\r\n maskRange: osg.Uniform.createFloat3('uMaskRange'),\r\n targetColor: osg.Uniform.createFloat3('uTargetColor'),\r\n sourceColor: osg.Uniform.createFloat3('uSourceColor'),\r\n mask: osg.Uniform.createFloat('uMask'),\r\n sourceLod: osg.Uniform.createFloat('uSourceLod'),\r\n };\r\n return ChangeColorAttribute.uniforms;\r\n }\r\n\r\n apply() {\r\n if (!this._attributeEnable || !this._valid) return;\r\n let uniformMap = this.getOrCreateUniforms()\r\n\r\n uniformMap.maskRange.setFloat3(this._maskRange)\r\n uniformMap.targetColor.setFloat3(this._targetColor)\r\n uniformMap.mask.setFloat(this._useMask)\r\n if(this._useSourceColor) {\r\n uniformMap.sourceColor.setFloat3(this._sourceColor)\r\n } else {\r\n uniformMap.sourceLod.setFloat(this._sourceLod)\r\n }\r\n }\r\n\r\n}\r\nStateAttributeRegister(\r\n ChangeColorAttribute,\r\n ChangeColorAttribute.prototype,\r\n 'osgEditor',\r\n 'ChangeColorAttribute',\r\n);\r\n\r\nexport default ChangeColorAttribute;\r\n","import StateAttribute from \"../osg/StateAttribute\";\r\nimport StateAttributeRegister from './StateAttributeRegister';\r\nimport osg from '../osg/osg';\r\n\r\nexport default class DiamondAttribute extends StateAttribute {\r\n constructor() {\r\n super();\r\n this._enabled = false\r\n this._brightness = 1.0;\r\n this._scale = 1.0;\r\n }\r\n\r\n get scale() {\r\n return this._scale\r\n }\r\n\r\n set scale(s) {\r\n this._scale = s\r\n }\r\n\r\n get brightness() {\r\n return this._brightness\r\n }\r\n\r\n set brightness(brightness) {\r\n this._brightness = brightness\r\n }\r\n\r\n getHash() {\r\n return 'DiamondAttribute' + (this._enabled ? 1 : 0);\r\n }\r\n\r\n cloneType() {\r\n return new DiamondAttribute();\r\n }\r\n\r\n setEnabled(enable) {\r\n this._enabled = enable;\r\n }\r\n\r\n isEnabled() {\r\n return this._enabled;\r\n }\r\n\r\n getOrCreateUniforms() {\r\n const cls = DiamondAttribute;\r\n if (cls.uniforms) return cls.uniforms;\r\n cls.uniforms = {\r\n // uTriplanarBlendWeight: osg.Uniform.createFloat1('uTriplanarBlendWeight')\r\n brightness: osg.Uniform.createFloat1('uBrightness'),\r\n scale: osg.Uniform.createFloat1('uScale'),\r\n \r\n };\r\n return cls.uniforms;\r\n }\r\n\r\n apply() {\r\n if (!this._enabled) return;\r\n const uniformMap = this.getOrCreateUniforms();\r\n uniformMap.brightness.setFloat(this._brightness);\r\n uniformMap.scale.setFloat(this._scale)\r\n } \r\n\r\n}\r\n\r\nStateAttributeRegister(\r\n DiamondAttribute,\r\n DiamondAttribute.prototype,\r\n 'osgEditor',\r\n 'DiamondAttribute'\r\n)\r\n","export default {\r\n \"hdr\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/photo_studio_01_8k.hdr\",\r\n \"size\": 100350789\r\n },\r\n \"thumbnail\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg\",\r\n \"size\": 15905\r\n },\r\n \"order\": 0,\r\n \"_id\": \"60c317bca9e97d73e92ccd1f\",\r\n \"createTime\": \"2021-06-11T07:58:52.718Z\",\r\n \"name\": \"工作室\",\r\n \"config\": {\r\n \"textures\": [{\r\n \"images\": [{\r\n \"width\": 256,\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg\",\r\n \"height\": 128,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg\",\r\n \"size\": \"15905\"\r\n }\r\n }],\r\n \"encoding\": \"srgb\",\r\n \"type\": \"thumbnail\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1779853,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz\",\r\n \"size\": \"1779853\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1200968,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz\",\r\n \"size\": \"1200968\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 317622,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz\",\r\n \"size\": \"317622\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 97956,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz\",\r\n \"size\": \"97956\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 29064,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz\",\r\n \"size\": \"29064\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"luv\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 2977192,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz\",\r\n \"size\": \"2977192\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1858076,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz\",\r\n \"size\": \"1858076\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 487212,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz\",\r\n \"size\": \"487212\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 149136,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz\",\r\n \"size\": \"149136\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 46566,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz\",\r\n \"size\": \"46566\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 3043958,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz\",\r\n \"size\": \"3043958\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1766005,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz\",\r\n \"size\": \"1766005\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 473185,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz\",\r\n \"size\": \"473185\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 149500,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz\",\r\n \"size\": \"149500\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 49221,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz\",\r\n \"size\": \"49221\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz\",\r\n \"sizeUncompressed\": 18874368,\r\n \"sizeCompressed\": 16116615,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz\",\r\n \"size\": \"16116615\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz\",\r\n \"sizeUncompressed\": 18874368,\r\n \"sizeCompressed\": 16067477,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz\",\r\n \"size\": \"16067477\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz\",\r\n \"sizeUncompressed\": 4718592,\r\n \"sizeCompressed\": 4041881,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz\",\r\n \"size\": \"4041881\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz\",\r\n \"sizeUncompressed\": 1179648,\r\n \"sizeCompressed\": 1020352,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz\",\r\n \"size\": \"1020352\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz\",\r\n \"sizeUncompressed\": 294912,\r\n \"sizeCompressed\": 258568,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz\",\r\n \"size\": \"258568\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"float\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 673838,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz\",\r\n \"size\": \"673838\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"luv\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 1095123,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz\",\r\n \"size\": \"1095123\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 1130918,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz\",\r\n \"size\": \"1130918\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz\",\r\n \"sizeUncompressed\": 12582912,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 7099449,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz\",\r\n \"size\": \"7099449\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"float\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 635016,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz\",\r\n \"size\": \"635016\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"luv\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 1055995,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz\",\r\n \"size\": \"1055995\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 1109686,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz\",\r\n \"size\": \"1109686\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz\",\r\n \"sizeUncompressed\": 6291432,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 5417781,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz\",\r\n \"size\": \"5417781\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"float\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz\",\r\n \"sizeUncompressed\": 65536,\r\n \"samples\": 2048,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"sizeCompressed\": 59665,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz\",\r\n \"size\": \"59665\"\r\n }\r\n }],\r\n \"encoding\": \"rg16\",\r\n \"type\": \"brdf_ue4\",\r\n \"format\": \"lut\"\r\n }\r\n ],\r\n \"writeByChannel\": true,\r\n \"lights\": [{\r\n \"direction\": [\r\n 0.0331058, -0.82285,\r\n 0.567294\r\n ],\r\n \"lum_ratio\": 0.0797674,\r\n \"color\": [\r\n 43.9513,\r\n 47.0473,\r\n 49.9592\r\n ],\r\n \"luminosity\": 508.628,\r\n \"sum\": 0.74215,\r\n \"area\": {\r\n \"y\": 0.192383,\r\n \"x\": 0.490723,\r\n \"w\": 0.0166016,\r\n \"h\": 0.0878906\r\n },\r\n \"error\": 0,\r\n \"variance\": 0.00071996\r\n }],\r\n \"diffuseSPH\": [\r\n 2.52177,\r\n 2.6475,\r\n 2.71793, -0.970495, -1.03103, -1.07638, -0.517793, -0.556958, -0.594671, -0.335999, -0.36003, -0.390184,\r\n 0.14915,\r\n 0.157474,\r\n 0.170339,\r\n 0.305085,\r\n 0.325537,\r\n 0.345122, -0.000786492, -0.00349557, -0.00655254, -0.000955614, -0.000445611,\r\n 0.00699492, -0.00675775, -0.0107802, -0.0170637,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0, -0.0128212, -0.0135017, -0.0145362,\r\n 0.0321759,\r\n 0.0344156,\r\n 0.0357341,\r\n 0.010143,\r\n 0.0108799,\r\n 0.0117446,\r\n 0.0164007,\r\n 0.0178076,\r\n 0.0192644,\r\n 0.0183598,\r\n 0.0198073,\r\n 0.0203541,\r\n 0.00825731,\r\n 0.00872035,\r\n 0.0094819,\r\n 0.0411866,\r\n 0.044173,\r\n 0.0463374,\r\n 0.0160459,\r\n 0.0171311,\r\n 0.0176568, -0.0096879, -0.0103498, -0.00986728\r\n ]\r\n }\r\n}","import osg from '../osg/osg';\r\n\r\nimport StateAttribute from \"../osg/StateAttribute\";\r\nimport StateAttributeRegister from './StateAttributeRegister';\r\n\r\nexport default class UVTransformAttribute extends StateAttribute {\r\n constructor() {\r\n super();\r\n this._attributeEnable = false;\r\n this._transform = osg.vec4.fromValues(1, 0, 0, 0);\r\n }\r\n\r\n getHash() {\r\n return this.getType() + (this._attributeEnable ? 1 : 0);\r\n }\r\n\r\n cloneType() {\r\n return new UVTransformAttribute();\r\n }\r\n\r\n setEnabled(state) {\r\n this._attributeEnable = state;\r\n }\r\n\r\n isEnabled() {\r\n return this._attributeEnable;\r\n }\r\n\r\n setTransform(scale, rotation, offsetx, offsety) {\r\n osg.vec4.set(this._transform, scale, rotation, offsetx, offsety);\r\n }\r\n\r\n getTransform() {\r\n return {\r\n scale: this._transform[0],\r\n ration: this._transform[1],\r\n offsetx: this._transform[2],\r\n offsety: this._transform[3],\r\n };\r\n }\r\n\r\n getOrCreateUniforms() {\r\n const cls = UVTransformAttribute;\r\n if (cls.uniforms) return cls.uniforms;\r\n cls.uniforms = {\r\n transform: osg.Uniform.createFloat4('uUVTransform'),\r\n };\r\n return cls.uniforms;\r\n }\r\n\r\n apply() {\r\n if (!this._attributeEnable) return;\r\n const uniformMap = this.getOrCreateUniforms();\r\n uniformMap.transform.setFloat4(this._transform);\r\n }\r\n}\r\n\r\nStateAttributeRegister(\r\n UVTransformAttribute,\r\n UVTransformAttribute.prototype,\r\n 'osgEditor',\r\n 'UVTransformAttribute',\r\n);\r\n","import NodeVisitor from \"../../osg/NodeVisitor\";\r\nimport Geometry from \"../../osg/Geometry\";\r\n\r\nclass GeomNodeVisitor extends NodeVisitor {\r\n geoms = [];\r\n includeShadow = false;\r\n map = {};\r\n compGeoms = {};\r\n _meshIndex = 0;\r\n _nameIndex = {};\r\n\r\n constructor(cb, includeShadow) {\r\n super();\r\n this.cb = cb;\r\n this.geoms = [];\r\n this.map = {};\r\n\r\n this.includeShadow = includeShadow;\r\n }\r\n\r\n apply(node) {\r\n if (node instanceof Geometry) {\r\n let name = this.getNodeName(node);\r\n this.cb && this.cb(node, name);\r\n\r\n if (name == \"shadow\") this.shadow = node;\r\n\r\n if (\r\n (!this.includeShadow && name && name != \"shadow\") ||\r\n this.includeShadow\r\n ) {\r\n const nodeState = node.getOrCreateStateSet();\r\n let currMatId = nodeState._uniqueID;\r\n\r\n let find = this.geoms.find(\r\n (item) => item.node == name && item.matId == currMatId\r\n );\r\n if (!find) {\r\n if (!this.compGeoms[name]) this.compGeoms[name] = [];\r\n const geoms = this.compGeoms[name];\r\n const gitem = {\r\n node: name,\r\n matId: currMatId,\r\n geom: node,\r\n index: geoms.length,\r\n };\r\n // gitem.node = gitem.node + gitem.index;\r\n geoms.push(gitem);\r\n this.geoms.push(gitem);\r\n this.map[name] = node;\r\n }\r\n console.log(\"xxxxxxxxxxx\", name, currMatId);\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n\r\n getNodeName(node) {\r\n let name = node.getName();\r\n if (!name) {\r\n if (node._parents && node._parents.length) {\r\n name = node._parents[0].getName();\r\n }\r\n }\r\n\r\n if (!name) {\r\n let index = this._meshIndex + 1;\r\n this._meshIndex = index;\r\n return \"未定义@\" + index;\r\n }\r\n let names = name.split(\"_\");\r\n names = names.length > 1 ? names.slice(0, names.length - 1) : names;\r\n let targetName = names.join(\"_\");\r\n if (!targetName) {\r\n targetName = name;\r\n }\r\n\r\n targetName = targetName.toLowerCase();\r\n\r\n if (this._nameIndex[targetName] == undefined) {\r\n this._nameIndex[targetName] = 0;\r\n return targetName;\r\n }\r\n this._nameIndex[targetName] = this._nameIndex[targetName] + 1;\r\n\r\n return targetName + \"@\" + this._nameIndex[targetName];\r\n }\r\n}\r\n\r\nexport { GeomNodeVisitor };\r\n","import NodeVisitor from \"../../osg/NodeVisitor\";\r\nimport Geometry from \"../../osg/Geometry\";\r\n\r\nclass GeomNodeVisitorV3 extends NodeVisitor {\r\n geoms = [];\r\n includeShadow = false;\r\n map = {};\r\n compGeoms = {};\r\n _meshIndex = 0;\r\n _nameIndex = {};\r\n\r\n constructor(cb, includeShadow) {\r\n super();\r\n this.cb = cb;\r\n this.geoms = [];\r\n this.map = {};\r\n\r\n this.includeShadow = includeShadow;\r\n }\r\n\r\n apply(node) {\r\n if (node instanceof Geometry) {\r\n let name = this.getNodeNameV3(node);\r\n this.cb && this.cb(node, name);\r\n\r\n if (name == \"shadow\") this.shadow = node;\r\n\r\n if (\r\n (!this.includeShadow && name && name != \"shadow\") ||\r\n this.includeShadow\r\n ) {\r\n\r\n const v1Name = this.getNodeNameV1(node);\r\n\r\n const nodeState = node.getOrCreateStateSet();\r\n let currMatId = nodeState._uniqueID;\r\n\r\n let find = this.geoms.find(\r\n (item) => item.node == name && item.matId == currMatId\r\n );\r\n if (!find) {\r\n if (!this.compGeoms[name]) this.compGeoms[name] = [];\r\n const geoms = this.compGeoms[name];\r\n const gitem = {\r\n node: name,\r\n matId: currMatId,\r\n geom: node,\r\n index: geoms.length,\r\n v1Name,\r\n };\r\n // gitem.node = gitem.node + gitem.index;\r\n geoms.push(gitem);\r\n this.geoms.push(gitem);\r\n this.map[name] = node;\r\n }\r\n console.log(\"v3 name=>\", name, \"v1 name=>\", v1Name);\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n\r\n getNodeNameV3(node) {\r\n let name = node.getName();\r\n if (!name) {\r\n if (node._parents && node._parents.length) {\r\n name = node._parents[0].getName();\r\n }\r\n }\r\n return name;\r\n }\r\n\r\n getNodeNameV1(node) {\r\n let name = node.getName();\r\n if (!name) {\r\n if (node._parents && node._parents.length) {\r\n name = node._parents[0].getName();\r\n }\r\n }\r\n\r\n if (!name) {\r\n let index = this._meshIndex + 1;\r\n this._meshIndex = index;\r\n return \"未定义@\" + index;\r\n }\r\n let names = name.split(\"_\");\r\n names = names.length > 1 ? names.slice(0, names.length - 1) : names;\r\n let targetName = names.join(\"_\");\r\n if (!targetName) {\r\n targetName = name;\r\n }\r\n\r\n targetName = targetName.toLowerCase();\r\n\r\n if (this._nameIndex[targetName] == undefined) {\r\n this._nameIndex[targetName] = 0;\r\n return targetName;\r\n }\r\n this._nameIndex[targetName] = this._nameIndex[targetName] + 1;\r\n\r\n return targetName + \"@\" + this._nameIndex[targetName];\r\n }\r\n}\r\n\r\nexport { GeomNodeVisitorV3 };\r\n","import osg from '../osg/osg';\r\nimport StateAttribute from \"../osg/StateAttribute\";\r\nimport StateAttributeRegister from './StateAttributeRegister';\r\n\r\nexport default class UVProjectionAttribute extends StateAttribute {\r\n constructor() {\r\n super();\r\n this._attributeEnable = false;\r\n this._mode = UVProjectionAttribute.ProjectionMode.TRIPLANAR\r\n this._triplanarBlendWeight = 0.1;\r\n }\r\n\r\n getHash() {\r\n return this.getMode() + (this._attributeEnable ? 1 : 0);\r\n }\r\n\r\n cloneType() {\r\n return new UVProjectionAttribute();\r\n }\r\n\r\n setEnabled(enable) {\r\n this._attributeEnable = enable;\r\n }\r\n\r\n isEnabled() {\r\n return this._attributeEnable;\r\n }\r\n\r\n getMode() {\r\n return this._mode\r\n }\r\n\r\n setMode(mode) {\r\n const validModes = Object.values(UVProjectionAttribute.ProjectionMode)\r\n if (validModes.indexOf(mode) == -1) {\r\n console.error('invalid uv projection mode')\r\n }\r\n this._mode = mode\r\n }\r\n\r\n setTriplanarBlendWeight(weight = 0.1) {\r\n this._triplanarBlendWeight = weight\r\n } \r\n\r\n getOrCreateUniforms() {\r\n const cls = UVProjectionAttribute;\r\n if (cls.uniforms) return cls.uniforms;\r\n cls.uniforms = {\r\n uTriplanarBlendWeight: osg.Uniform.createFloat1('uTriplanarBlendWeight')\r\n };\r\n return cls.uniforms;\r\n }\r\n\r\n apply() {\r\n if (!this._attributeEnable) return;\r\n const uniformMap = this.getOrCreateUniforms();\r\n uniformMap.uTriplanarBlendWeight.setFloat(this._triplanarBlendWeight);\r\n }\r\n}\r\n\r\nStateAttributeRegister(\r\n UVProjectionAttribute,\r\n UVProjectionAttribute.prototype,\r\n 'osgEditor',\r\n 'UVProjectionAttribute'\r\n)\r\n\r\n\r\nUVProjectionAttribute.ProjectionMode = {\r\n TRIPLANAR: 'TRIPLANAR_PROJECTION', // default mode\r\n POLAR: 'POLAR_PROJECTION',\r\n ORTHOGONAL: 'ORTHOGONAL_PROJECTION'\r\n}\r\n","import readerParser from \"../../osgDB/readerParser\";\r\nimport UVTransformAttribute from \"../UVTransformAttribute\";\r\nimport MaterialUtils from \"../material/MaterialUtils\";\r\nimport { GeomNodeVisitor } from \"./GeomNodeVisitor\";\r\nimport { GeomNodeVisitorV3 } from \"./GeomNodeVisitorV3\";\r\n\r\nimport UVProjectionAttribute from \"../UVProjectionAttribute\";\r\n\r\nclass ModelLoader {\r\n constructor() {\r\n }\r\n\r\n //options - database shoe model config\r\n static async loadModel(url, options={uvproject: true, version: \"1.0\"}) {\r\n\r\n //https的处理\r\n if (!window.noForceHttps) {\r\n let httpHeader = \"http://\";\r\n if (url.indexOf(httpHeader) == 0) {\r\n url = \"https://\" + url.substr(httpHeader.length);\r\n }\r\n }\r\n let model = await readerParser.readNodeURL(url);\r\n\r\n if (typeof model == \"string\") {\r\n console.error(model);\r\n return null;\r\n }\r\n\r\n const Visitor = options.version == \"3.0\" ? GeomNodeVisitorV3 : GeomNodeVisitor;\r\n const pm = new Visitor(function(node) {\r\n MaterialUtils.resetGeometryStateSet(node);\r\n const uvTranform = new UVTransformAttribute();\r\n node.getOrCreateStateSet().setAttributeAndModes(uvTranform);\r\n\r\n if (options && options.uvproject) {\r\n const UVProjection = new UVProjectionAttribute();\r\n node.getOrCreateStateSet().setAttributeAndModes(UVProjection);\r\n }\r\n });\r\n \r\n model.accept(pm);\r\n\r\n return model;\r\n }\r\n}\r\n\r\nexport { ModelLoader };","import { isPc } from \"@queenjs/utils\";\r\n\r\nclass DefaultUrlResolver {\r\n\r\n useCdn = true;\r\n constructor(useCdn) {\r\n this.useCdn = useCdn;\r\n }\r\n\r\n Parse(imageUrl) {\r\n if (imageUrl.indexOf(\"unknown\")!= -1) {\r\n console.log(\"error=>\", imageUrl, factor, textureConfig, enable, targetColor, uint);\r\n }\r\n \r\n const urlParams = new URLSearchParams(location.search);\r\n let limited = false\r\n \r\n let urlSearch = '?t=texture';\r\n if(urlParams.get('phonetexture') === 'true' || !isPc()){\r\n // urlSearch = \"?x-image-process=style/phonetexture\";\r\n urlSearch = \"?x-image-process=image/resize,m_lfit,h_512,w_512\";\r\n limited = true;\r\n }\r\n if (imageUrl.indexOf(\"?\") == -1 && imageUrl.indexOf('blob:http') !== 0 && imageUrl.indexOf(\"data:\") !== 0) imageUrl += urlSearch;\r\n\r\n if (!limited && this.useCdn) { //加速下载\r\n imageUrl = imageUrl.replace(\"sku3d-test.obs.cn-east-3.myhuaweicloud.com\", \"obs.sku3d.com\");\r\n if (imageUrl.indexOf(\"https:\") == 0) {\r\n imageUrl = imageUrl.substr(6)\r\n } else if (imageUrl.indexOf(\"http:\") == 0) {\r\n imageUrl = imageUrl.substr(5)\r\n }\r\n }\r\n return imageUrl;\r\n }\r\n}\r\n\r\nconst UrlConfig = {\r\n TextureResolver: new DefaultUrlResolver(true)\r\n}\r\n\r\nexport { UrlConfig, DefaultUrlResolver}\r\n\r\n","import osg from \"../../osg/osg\"\r\nimport ResourceManager from \"../ResourceManager\";\r\nimport PBRMaterial from \"./PBRMaterial\";\r\nimport RenderDetail from '../RenderDetail';\r\nimport CreatePromise from \"../CreatePromise\";\r\nimport ChangeColorAttribute from '../ChangeColorAttribute'\r\nimport DiamondAttribute from '../DiamondAttribute'\r\nimport Application from \"../application\";\r\nimport defaultEnv3d from '../../../module/objects/Env3d/defaultEnv3d';\r\nimport { ModelLoader } from \"../objects/ModelLoader\";\r\nimport { GeomNodeVisitor} from \"../objects/GeomNodeVisitor\"\r\nimport UVTransformAttribute from \"../UVTransformAttribute\"\r\nimport UVProjectionAttribute from \"../UVProjectionAttribute\"\r\nimport {UrlConfig} from \"./UrlResolver\"\r\n\r\nfunction _createTextureFeature(geom, uint) {\r\n let textureUnit = uint;\r\n let stateSet = geom.getOrCreateStateSet();\r\n\r\n return function(factor, textureConfig, enable, targetColor) {\r\n\r\n var channel = {\r\n hasMap: false,\r\n promise: undefined\r\n }\r\n if (enable === false) {\r\n stateSet.removeTextureAttribute(textureUnit, 'Texture');\r\n return channel\r\n }\r\n\r\n let imageUrl = textureConfig ? (textureConfig.file ? textureConfig.file.url : textureConfig.url ? textureConfig.url : null) : null;\r\n\r\n //图片\r\n if (imageUrl) {\r\n imageUrl = UrlConfig.TextureResolver.Parse(imageUrl);\r\n let texRes = ResourceManager.getInstance().getOrCreateTexture(imageUrl, {\r\n minFilter: textureUnit === MaterialUtils.DISPLACEMENT_TEXTURE_UNIT ? osg.Texture.LINEAR : osg.Texture.LINEAR_MIPMAP_LINEAR,\r\n magFilter: osg.Texture.LINEAR,\r\n internalFormat: osg.Texture.RGB,\r\n wrapS: osg.Texture.REPEAT,\r\n wrapT: osg.Texture.REPEAT,\r\n anisotropy: 16\r\n })\r\n texRes.texture.setFlipY(true);\r\n texRes.texture.setImageFormat('RGB')\r\n if (textureUnit === MaterialUtils.OPACITY_TEXTURE_UNIT) {\r\n stateSet.setTextureAttributeAndModes(textureUnit, ResourceManager.getInstance().createTextureFromColor(0, false));\r\n }\r\n \r\n texRes.promise.then(() => {\r\n if (textureUnit === MaterialUtils.ALBEDO_TEXTURE_UNIT && targetColor) {\r\n var attribute = stateSet.getAttribute('ChangeColorAttribute')\r\n if(!attribute){\r\n attribute = new ChangeColorAttribute()\r\n stateSet.setAttributeAndModes(attribute)\r\n }\r\n attribute.setTexture(texRes.texture)\r\n attribute.setEnabled(true)\r\n attribute.setTargetColor(targetColor)\r\n \r\n }\r\n stateSet.setTextureAttributeAndModes(textureUnit, texRes.texture);\r\n })\r\n channel.hasMap = true\r\n channel.promise = texRes.promise\r\n return channel;\r\n }\r\n\r\n //颜色\r\n if (factor != null) {\r\n let colorTexture = ResourceManager.getInstance().createTextureFromColor(factor, false);\r\n colorTexture.setFlipY(true);\r\n colorTexture.setWrapS(osg.Texture.REPEAT);\r\n colorTexture.setWrapT(osg.Texture.REPEAT);\r\n colorTexture.setMagFilter(osg.Texture.LINEAR);\r\n colorTexture.setMinFilter(osg.Texture.LINEAR_MIPMAP_LINEAR);\r\n colorTexture.setImageFormat('RGB');\r\n stateSet.setTextureAttributeAndModes(textureUnit, colorTexture);\r\n channel.promise = CreatePromise()\r\n channel.promise.resolve()\r\n } else {\r\n stateSet.removeTextureAttribute(textureUnit, 'Texture');\r\n }\r\n\r\n return channel;;\r\n }\r\n}\r\n\r\nconst _defaultText = {\r\n url: \"\",\r\n size: 0,\r\n}\r\n\r\n\r\nconst _defaultMat = {\r\n // uvtransform: {\r\n // scale: 1,\r\n // rotate: 0,\r\n // offsetX: 0,\r\n // offsetY: 0,\r\n // },\r\n classType: \"pbr\",\r\n cullFace: \"\",\r\n metalnessWorkFlow: true,\r\n channels: {\r\n Diamond:{\r\n color: [0.4, 0.4, 0.4],\r\n brightness: 1.0,\r\n scaleX: 1.0,\r\n scaleY: 1.0\r\n },\r\n Albedo: {\r\n color: [0.509803950786591, 0.474509835243225, 0.474509835243225],\r\n texture: _defaultText\r\n },\r\n Roughness: {\r\n factor: 1,\r\n invert: false,\r\n texture: _defaultText\r\n },\r\n Emissive: {\r\n color: [0, 0, 0],\r\n factor: 1,\r\n enable: false\r\n },\r\n NormalMap: {\r\n enable: false,\r\n factor: 1,\r\n flipY: false,\r\n texture: _defaultText,\r\n },\r\n BumpMap: {\r\n enable: false,\r\n factor: 1,\r\n texture: _defaultText\r\n },\r\n Opacity: {\r\n enable: false,\r\n type: \"ALPHA_BLEND\",\r\n factor: 1,\r\n invert: false,\r\n sampleChannel: \"a\",\r\n refractionTint: [1, 1, 1],\r\n refractUseDiffuse: false,\r\n refractUseShininessMap: false,\r\n IOR: 1,\r\n roughnessFactor: 0,\r\n texture: _defaultText\r\n },\r\n AO: {\r\n enable: false,\r\n occludeSpecular: false,\r\n factor: 0,\r\n texture: _defaultText\r\n },\r\n MetalnessPBR: {\r\n factor: 0,\r\n texture: _defaultText\r\n },\r\n SpecularF0: 0.5,\r\n ClearCoat: {\r\n enable: false,\r\n thickness: 5,\r\n intensity: 1,\r\n color: [1, 1, 1],\r\n reflectivity: 0,\r\n roughness: {\r\n factor: 0.04,\r\n },\r\n normalmap: {\r\n factor: 1,\r\n flipY: false,\r\n }\r\n },\r\n Displacement: {\r\n enable: false,\r\n factor: 1.0,\r\n texture: _defaultText,\r\n },\r\n CavityMap: {\r\n enable: false,\r\n factor: 0,\r\n }\r\n }\r\n // cullFace:'both'\r\n};\r\n\r\nconst _silverMat = {\r\n // uvtransform: {\r\n // scale: 1,\r\n // rotate: 0,\r\n // offsetX: 0,\r\n // offsetY: 0,\r\n // },\r\n classType: \"pbr\",\r\n cullFace: \"\",\r\n metalnessWorkFlow: true,\r\n channels: {\r\n Diamond:{\r\n color: [0.4, 0.4, 0.4],\r\n brightness: 1.0,\r\n scaleX: 1.0,\r\n scaleY: 1.0\r\n },\r\n Albedo: {\r\n color: [0.753, 0.753, 0.753],\r\n texture: _defaultText\r\n },\r\n Roughness: {\r\n factor: 0.3,\r\n invert: false,\r\n texture: _defaultText\r\n },\r\n Emissive: {\r\n color: [0, 0, 0],\r\n factor: 1,\r\n enable: false\r\n },\r\n NormalMap: {\r\n enable: false,\r\n factor: 1,\r\n flipY: false,\r\n texture: _defaultText,\r\n },\r\n BumpMap: {\r\n enable: false,\r\n factor: 1,\r\n texture: _defaultText\r\n },\r\n Opacity: {\r\n enable: false,\r\n type: \"ALPHA_BLEND\",\r\n factor: 1,\r\n invert: false,\r\n sampleChannel: \"a\",\r\n refractionTint: [1, 1, 1],\r\n refractUseDiffuse: false,\r\n refractUseShininessMap: false,\r\n IOR: 1,\r\n roughnessFactor: 0,\r\n texture: _defaultText\r\n },\r\n AO: {\r\n enable: false,\r\n occludeSpecular: false,\r\n factor: 0,\r\n texture: _defaultText\r\n },\r\n MetalnessPBR: {\r\n factor: 1,\r\n texture: _defaultText\r\n },\r\n SpecularF0: 0.5,\r\n ClearCoat: {\r\n enable: false,\r\n thickness: 5,\r\n intensity: 1,\r\n color: [1, 1, 1],\r\n reflectivity: 0,\r\n roughness: {\r\n factor: 0.04,\r\n },\r\n normalmap: {\r\n factor: 1,\r\n flipY: false,\r\n }\r\n },\r\n Displacement: {\r\n enable: false,\r\n factor: 1.0,\r\n texture: _defaultText,\r\n },\r\n CavityMap: {\r\n enable: false,\r\n factor: 0,\r\n }\r\n }\r\n // cullFace:'both'\r\n};\r\n\r\nexport default class MaterialUtils {\r\n\r\n static AO_TEXTURE_UNIT = 1;\r\n static ALBEDO_TEXTURE_UNIT = 2;\r\n static METALLIC_TEXTURE_UNIT = 3;\r\n static ROUGHNESS_TEXTURE_UNIT = 4;\r\n static NORMAL_TEXTURE_UNIT = 5;\r\n static ENV_SPECUAR_TEXTURE_UNIT = 6;\r\n static OPACITY_TEXTURE_UNIT = 7;\r\n static ENV_BRDF_TEXTURE_UNIT = 8;\r\n static DISPLACEMENT_TEXTURE_UNIT = 13;\r\n static STICKER_TEXTURE_UNIT = 9; //STICKER COUNT 3\r\n static SHADOW_TEXTURE_UNIT = 12\r\n static DefaultMaterial = _defaultMat;\r\n\r\n static capApp = undefined\r\n static async captureMaterial(replaceMat) {\r\n replaceMat |= _defaultMat\r\n ResourceManager.getInstance().setCache(false)\r\n if(!MaterialUtils.capApp) {\r\n if(typeof OffscreenCanvas === 'undefined') {\r\n throw new Error('OffscreenCanvas is not supported')\r\n }\r\n let offscreen = new OffscreenCanvas(512, 512)\r\n MaterialUtils.capApp = new Application(offscreen)\r\n MaterialUtils.capApp._viewer.setupManipulator(MaterialUtils.capApp._switchManipulator);\r\n MaterialUtils.capApp.setEnvironmentModel(defaultEnv3d.config)\r\n MaterialUtils.capApp.setBackgroundMode('none')\r\n MaterialUtils.capApp.start()\r\n }\r\n \r\n let model = await ModelLoader.loadModel('https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/upload/osgjs/16630502469853QVNZg_1663050233489.glb.osgjs');\r\n\r\n const pm = new GeomNodeVisitor(function(node) {\r\n MaterialUtils.resetGeometryStateSet(node);\r\n \r\n const uvTranform = new UVTransformAttribute();\r\n node.getOrCreateStateSet().setAttributeAndModes(uvTranform);\r\n\r\n const UVProjection = new UVProjectionAttribute();\r\n node.getOrCreateStateSet().setAttributeAndModes(UVProjection);\r\n \r\n if(pm.getNodeName(node) === 'fabric@1'){ \r\n MaterialUtils.attachMaterial(node, replaceMat)\r\n } else{\r\n MaterialUtils.attachMaterial(node, _silverMat)\r\n }\r\n \r\n });\r\n \r\n model.accept(pm);\r\n MaterialUtils.capApp.scene.addChild(model);\r\n MaterialUtils.capApp._rootScene.dirtyBound()\r\n MaterialUtils.capApp._viewer.getManipulator().computeHomePosition();\r\n let takeScreen = await new Promise((resolve, reject)=>{\r\n setTimeout(() => {\r\n try {\r\n let canvas = MaterialUtils.capApp.takeScreenShot(512, 512)\r\n resolve(canvas) \r\n } catch (error) {\r\n reject(error)\r\n }\r\n \r\n }, 500);\r\n })\r\n ResourceManager.getInstance().setCache(true)\r\n return takeScreen\r\n }\r\n\r\n static async resetGeometryStateSet(node) {\r\n const stateSet = node.getOrCreateStateSet();\r\n const config = MaterialUtils.attachMaterial(node);\r\n const material = MaterialUtils.createPBRMaterial(config);\r\n // if(config.cullFace) {\r\n // material._cullFace = MaterialUtils.cullFaceEnum[config.cullFace]\r\n // stateSet.setAttributeAndModes(new osg.CullFace(MaterialUtils.cullFaceEnum[config.cullFace]))\r\n // } else {\r\n // material._cullFace = osg.CullFace.DISABLE\r\n // stateSet.setAttributeAndModes(new osg.CullFace(osg.CullFace.DISABLE))\r\n // }\r\n stateSet.setAttributeAndModes(material);\r\n stateSet.setRenderBinDetails(RenderDetail.OPAQUE, 'RenderBin');\r\n return await Promise.all(config.promises)\r\n }\r\n\r\n static async updateGeomMaterial(geom, json) {\r\n let config = MaterialUtils.attachMaterial(geom, json);\r\n const material = MaterialUtils.configMaterial(geom.getOrCreateStateSet(), config);\r\n if (json && json.classType == 'diamond') { \r\n material._depthWrite = true\r\n }\r\n try {\r\n return await Promise.all(config.promises)\r\n } catch (error) { \r\n }\r\n }\r\n\r\n static async attachMaterialSync(geom, mat) {\r\n let json = mat || _defaultMat;\r\n\r\n //uv transform\r\n const transform = json.uvtransform;\r\n if (transform) {\r\n const newValue = [\r\n transform.scale,\r\n (Math.PI * transform.rotate) / 180,\r\n transform.offsetX,\r\n transform.offsetY,\r\n ];\r\n const isDefaultValue =\r\n newValue[0] === 1 && newValue[1] === 0 && newValue[2] === 0 && newValue[3] === 0;\r\n const uvTransform = geom.getOrCreateStateSet().getAttribute('UVTransformAttribute');\r\n if (uvTransform) {\r\n uvTransform.setEnabled(!isDefaultValue);\r\n uvTransform.setTransform.apply(uvTransform, newValue);\r\n }\r\n }\r\n\r\n const UVProjection = geom.getOrCreateStateSet().getAttribute('UVProjectionAttribute');\r\n if (UVProjection) {\r\n UVProjection.setEnabled(json.uvProjection);\r\n }\r\n let config = {\r\n promises: []\r\n };\r\n config.metalnessWorkFlow = json.metalnessWorkFlow\r\n config.cullFace = json.cullFace == \"DISABLE\" ? \"\" : json.cullFace\r\n\r\n config.vertexColor = geom.getAttributes().Color !== undefined;\r\n\r\n //Albedo\r\n let albedoSetter = _createTextureFeature(geom, MaterialUtils.ALBEDO_TEXTURE_UNIT);\r\n let albedoChannel = albedoSetter(json.channels.Albedo.color, json.channels.Albedo.texture, true);\r\n await albedoChannel.promise;\r\n // config.promises.push(albedoChannel.promise)\r\n //metallic\r\n let metallicSetter = _createTextureFeature(geom, MaterialUtils.METALLIC_TEXTURE_UNIT);\r\n let metalChannel = metallicSetter(json.channels.MetalnessPBR.factor, json.channels.MetalnessPBR.texture, true);\r\n await metalChannel.promise;\r\n // config.promises.push(metalChannel.promise)\r\n //roughness\r\n let roughnessSetter = _createTextureFeature(geom, MaterialUtils.ROUGHNESS_TEXTURE_UNIT);\r\n let roughnessChannel = roughnessSetter(json.channels.Roughness.factor, json.channels.Roughness.texture, true);\r\n await roughnessChannel.promise;\r\n // config.promises.push(roughnessChannel.promise)\r\n //normalmap todo\r\n let normalmapSetter = _createTextureFeature(geom, MaterialUtils.NORMAL_TEXTURE_UNIT);\r\n let normalChannel = normalmapSetter(null, json.channels.NormalMap.texture, json.channels.NormalMap.enable)\r\n config.normalMap = normalChannel.hasMap;\r\n if (normalChannel.hasMap && normalChannel.promise) {\r\n await normalChannel.promise;\r\n // config.promises.push(normalChannel.promise)\r\n }\r\n config.normalFactor = json.channels.NormalMap.factor;\r\n config.normalFlipY = json.channels.NormalMap.flipY;\r\n\r\n //ao todo\r\n let aomapSetter = _createTextureFeature(geom, MaterialUtils.AO_TEXTURE_UNIT);\r\n let aoChannel = aomapSetter(json.channels.AO.factor, json.channels.AO.texture, json.channels.AO.enable);\r\n config.aoMap = aoChannel.hasMap\r\n if (aoChannel.hasMap && aoChannel.promise) {\r\n await aoChannel.promise;\r\n // config.promises.push(aoChannel.promise)\r\n }\r\n //opacity\r\n let opacitySetter = _createTextureFeature(geom, MaterialUtils.OPACITY_TEXTURE_UNIT);\r\n let opacityChannel = opacitySetter(null, json.channels.Opacity.texture, json.channels.Opacity.enable);\r\n config.hasOpacityMap = opacityChannel.hasMap\r\n if (opacityChannel.hasMap && opacityChannel.promise) {\r\n await opacityChannel.promise;\r\n // config.promises.push(opacityChannel.promise)\r\n }\r\n config.opacityFactor = json.channels.Opacity.factor;\r\n if (!json.channels.Opacity.enable) {\r\n config.opacityFactor = 1\r\n }\r\n //displacement\r\n let displacementSetter = _createTextureFeature(geom, MaterialUtils.DISPLACEMENT_TEXTURE_UNIT);\r\n let diplacementChannel = displacementSetter(0, json.channels.Displacement.texture, true);\r\n config.hasDisplacementMap = diplacementChannel.hasMap\r\n config.displacementFactor = json.channels.Displacement.factor\r\n await diplacementChannel.promise;\r\n // config.promises.push(diplacementChannel.promise)\r\n\r\n return config;\r\n\r\n }\r\n\r\n static attachMaterial(geom, mat) {\r\n let json = mat || _defaultMat;\r\n\r\n //uv transform\r\n const transform = json.uvtransform;\r\n if (transform) {\r\n const newValue = [\r\n transform.scale,\r\n (Math.PI * transform.rotate) / 180,\r\n transform.offsetX,\r\n transform.offsetY,\r\n ];\r\n const isDefaultValue =\r\n newValue[0] === 1 && newValue[1] === 0 && newValue[2] === 0 && newValue[3] === 0;\r\n const uvTransform = geom.getOrCreateStateSet().getAttribute('UVTransformAttribute');\r\n if (uvTransform) {\r\n uvTransform.setEnabled(!isDefaultValue);\r\n uvTransform.setTransform.apply(uvTransform, newValue);\r\n }\r\n }\r\n\r\n const UVProjection = geom.getOrCreateStateSet().getAttribute('UVProjectionAttribute');\r\n if (UVProjection) {\r\n UVProjection.setEnabled(json.uvProjection);\r\n } \r\n\r\n let diamondAttribute = geom.getOrCreateStateSet().getAttribute('DiamondAttribute')\r\n if (!diamondAttribute) {\r\n diamondAttribute = new DiamondAttribute()\r\n //const depth = new osg.Depth()\r\n //depth.setWriteMask(true)\r\n //geom.getOrCreateStateSet().setAttributeAndModes(depth)\r\n geom.getOrCreateStateSet().setAttributeAndModes(diamondAttribute)\r\n }\r\n if (json.classType == 'diamond') {\r\n diamondAttribute.setEnabled(true)\r\n json.channels.Albedo.texture = {\r\n url: 'https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/colours.png'\r\n }\r\n json.channels.MetalnessPBR.texture = {\r\n url: 'https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/triangles.png'\r\n }\r\n json.channels.NormalMap.texture = {\r\n url: 'https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/normals.png'\r\n }\r\n json.channels.Roughness.texture = {\r\n url: 'https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/points.png'\r\n }\r\n json.channels.Opacity.factor = 0 // djr thick\r\n json.channels.Opacity.enable = true\r\n json.cullFace = 'back'\r\n } else {\r\n diamondAttribute.setEnabled(false)\r\n }\r\n \r\n \r\n let config = {\r\n promises: []\r\n };\r\n config.metalnessWorkFlow = json.metalnessWorkFlow\r\n config.cullFace = json.cullFace == \"DISABLE\" ? \"\" : json.cullFace\r\n\r\n config.vertexColor = geom.getAttributes().Color !== undefined;\r\n\r\n //Albedo\r\n let albedoSetter = _createTextureFeature(geom, MaterialUtils.ALBEDO_TEXTURE_UNIT);\r\n let albedoChannel = albedoSetter(json.channels.Albedo.color, json.channels.Albedo.texture, true);\r\n config.promises.push(albedoChannel.promise)\r\n //metallic\r\n let metallicSetter = _createTextureFeature(geom, MaterialUtils.METALLIC_TEXTURE_UNIT);\r\n let metalChannel = metallicSetter(json.channels.MetalnessPBR.factor, json.channels.MetalnessPBR.texture, true);\r\n config.promises.push(metalChannel.promise)\r\n //roughness\r\n let roughnessSetter = _createTextureFeature(geom, MaterialUtils.ROUGHNESS_TEXTURE_UNIT);\r\n let roughnessChannel = roughnessSetter(json.channels.Roughness.factor, json.channels.Roughness.texture, true);\r\n config.promises.push(roughnessChannel.promise)\r\n //normalmap todo\r\n let normalmapSetter = _createTextureFeature(geom, MaterialUtils.NORMAL_TEXTURE_UNIT);\r\n let normalChannel = normalmapSetter(null, json.channels.NormalMap.texture, json.channels.NormalMap.enable)\r\n config.normalMap = normalChannel.hasMap;\r\n if (normalChannel.hasMap && normalChannel.promise) {\r\n config.promises.push(normalChannel.promise)\r\n }\r\n config.normalFactor = json.channels.NormalMap.factor;\r\n config.normalFlipY = json.channels.NormalMap.flipY;\r\n\r\n //ao todo\r\n let aomapSetter = _createTextureFeature(geom, MaterialUtils.AO_TEXTURE_UNIT);\r\n let aoChannel = aomapSetter(json.channels.AO.factor, json.channels.AO.texture, json.channels.AO.enable);\r\n config.aoMap = aoChannel.hasMap\r\n if (aoChannel.hasMap && aoChannel.promise) {\r\n config.promises.push(aoChannel.promise)\r\n }\r\n //opacity\r\n let opacitySetter = _createTextureFeature(geom, MaterialUtils.OPACITY_TEXTURE_UNIT);\r\n let opacityChannel = opacitySetter(null, json.channels.Opacity.texture, json.channels.Opacity.enable);\r\n config.hasOpacityMap = opacityChannel.hasMap\r\n if (opacityChannel.hasMap && opacityChannel.promise) {\r\n config.promises.push(opacityChannel.promise)\r\n }\r\n config.opacityFactor = json.channels.Opacity.factor;\r\n if (!json.channels.Opacity.enable) {\r\n config.opacityFactor = 1\r\n }\r\n //displacement\r\n let displacementSetter = _createTextureFeature(geom, MaterialUtils.DISPLACEMENT_TEXTURE_UNIT);\r\n let diplacementChannel = displacementSetter(0, json.channels.Displacement.texture, true);\r\n config.hasDisplacementMap = diplacementChannel.hasMap\r\n config.displacementFactor = json.channels.Displacement.factor\r\n config.promises.push(diplacementChannel.promise)\r\n\r\n return config;\r\n\r\n }\r\n\r\n static cullFaceEnum = {\r\n front: osg.CullFace.FRONT,\r\n back: osg.CullFace.BACK,\r\n both: osg.CullFace.FRONT_AND_BACK,\r\n }\r\n\r\n static configMaterial(stateSet, config) {\r\n var material = stateSet.getAttribute('PBRMaterial');\r\n if (material) {\r\n config.normalMap !== undefined &&\r\n material.setHasNormalMap(config.normalMap);\r\n config.hasOpacityMap !== undefined &&\r\n material.setHasOpacityMap(config.hasOpacityMap);\r\n config.opacityFactor !== undefined &&\r\n material.setOpacityFactor(config.opacityFactor);\r\n \r\n config.aoMap !== undefined &&\r\n material.setHasAOMap(config.aoMap);\r\n if(config.hasDisplacementMap !== undefined){\r\n material.setHasDisplacementMap(config.hasDisplacementMap);\r\n material.setDisplacementAmount(config.displacementFactor)\r\n }\r\n\r\n config.normalFlipY !== undefined && material.setNormalFlipY(config.normalFlipY);\r\n config.normalFactor !== undefined && material.setNormalFactor(config.normalFactor);\r\n if (config.cullFace) {\r\n material._cullFace = MaterialUtils.cullFaceEnum[config.cullFace]\r\n } else {\r\n material._cullFace = osg.CullFace.DISABLE\r\n }\r\n material.setMetalnessWorkFlow(config.metalnessWorkFlow !== false)\r\n } else {\r\n var material = MaterialUtils.createPBRMaterial(config);\r\n stateSet.setAttributeAndModes(material);\r\n }\r\n if (config.cullFace) {\r\n stateSet.setAttributeAndModes(new osg.CullFace(MaterialUtils.cullFaceEnum[config.cullFace]))\r\n } else {\r\n stateSet.setAttributeAndModes(new osg.CullFace(osg.CullFace.DISABLE))\r\n }\r\n if (material.getHasOpacityMap() || material.getOpacityFactor() < 1.0) {\r\n stateSet.setRenderBinDetails(RenderDetail.TRANSPARENT, 'DepthSortedBin');\r\n } else {\r\n stateSet.setRenderBinDetails(RenderDetail.OPAQUE, 'RenderBin');\r\n }\r\n return material\r\n }\r\n\r\n static createPBRMaterial(config) {\r\n let pbrMaterial = new PBRMaterial();\r\n\r\n if (!config) return pbrMaterial;\r\n\r\n config.normalMap !== undefined &&\r\n pbrMaterial.setHasNormalMap(config.normalMap);\r\n config.vertexColor !== undefined &&\r\n pbrMaterial.setVertexColorEnable(config.vertexColor);\r\n config.hasOpacityMap !== undefined &&\r\n pbrMaterial.setHasOpacityMap(config.hasOpacityMap);\r\n config.opacityFactor !== undefined &&\r\n pbrMaterial.setOpacityFactor(config.opacityFactor);\r\n config.aoMap !== undefined &&\r\n pbrMaterial.setHasAOMap(config.aoMap);\r\n if(config.hasDisplacementMap !== undefined){\r\n pbrMaterial.setHasDisplacementMap(config.hasDisplacementMap);\r\n pbrMaterial.setDisplacementAmount(config.displacementFactor)\r\n }\r\n config.normalFlipY !== undefined && pbrMaterial.setNormalFlipY(config.normalFlipY);\r\n config.normalFactor !== undefined && pbrMaterial.setNormalFactor(config.normalFactor);\r\n pbrMaterial.setMetalnessWorkFlow(config.metalnessWorkFlow !== false)\r\n return pbrMaterial;\r\n }\r\n\r\n}\r\n","\r\nimport osg from '../../osg/osg';\r\nimport RenderDetail from '../RenderDetail.js';\r\nimport PickMask from '../PickMask.js';\r\nimport Config from '../Config.js';\r\nimport { Model } from 'backbone'\r\nimport BoundingComputer from '../BoundingComputer'\r\nimport PresetLights from '../PresetLights'\r\nimport osgUtil from '../../osgUtil/osgUtil';\r\nimport GLState from '../GLState';\r\nimport GeometryCreator from '../GeometryCreator'\r\nimport dummyTexture from '../DummyTexture';\r\nimport ResourceManager from '../ResourceManager';\r\nimport light_icon from '../assets/light_icon.png'\r\nimport EditorLight from '../EditorLight';\r\nimport osgShadow from '../../osgShadow/osgShadow';\r\nimport MaxTextureUnit from '../MaxTextureUnit';\r\nimport MaterialUtils from '../material/MaterialUtils';\r\n\r\n\r\n\r\n\r\nvar createShadowSetting = function (light) {\r\n var setting = new osgShadow.ShadowSettings();\r\n setting.setLight(light);\r\n setting.setShadowCastShaderGeneratorName('shadowcast')\r\n setting.setCastsShadowDrawTraversalMask(PickMask.SHADOW)\r\n setting.setCastsShadowBoundsTraversalMask(PickMask.SHADOW_BOUNDS)\r\n setting.userShadowCasterVisitor = false\r\n setting.kernelSizePCF = Config.shadowPCF\r\n setting.fakePCF = false\r\n setting.setTextureSize(Config.shadowTextureSize);\r\n return setting;\r\n};\r\n\r\n\r\nclass LightModel extends Model {\r\n\r\n defaults() {\r\n return {\r\n enable: true,\r\n matrix: osg.mat4.create(),\r\n type: 'DIRECTION',\r\n color: osg.vec3.fromValues(\r\n 1,\r\n 1,\r\n 1\r\n ),\r\n intensity: 1,\r\n matrixPrev: osg.mat4.create(),\r\n }\r\n }\r\n initialize() {\r\n\r\n this.bind('change:mask', this.dirty, this)\r\n \r\n }\r\n\r\n init(index, lightingFeature) {\r\n this.createNode(index, lightingFeature)\r\n }\r\n\r\n createNode(index, lightingFeature) {\r\n this._mtLight = new osg.MatrixTransform()\r\n this._mtLight.setName('Lighting - Mt')\r\n var lightNode = lightingFeature.createLight('Lighting', index)\r\n this._shadowMap = lightNode.shadowMap,\r\n this._light = lightNode.light\r\n this._lightSource = lightNode.lightSource\r\n this._node = lightNode.node\r\n this._mtQuad = new osg.MatrixTransform()\r\n this._mtQuad.setName('Lighting - TransformIcon ' + index)\r\n\r\n this._quadGeom = GeometryCreator.createIconGeometry(ResourceManager.getInstance().getOrCreateTexture(light_icon, {\r\n internalFormat: osg.Texture.RGBA,\r\n magFilter: osg.Texture.LINEAR,\r\n minFilter: osg.Texture.LINEAR_MIPMAP_LINEAR,\r\n wrapS: osg.Texture.CLAMP_TO_EDGE,\r\n wrapT: osg.Texture.CLAMP_TO_EDGE,\r\n }).texture)\r\n this._quadGeom.setName('Lighting - GeomIcon ' + index)\r\n this._dirGeom = new GeometryCreator.createDirectionalGeometry(5)\r\n\r\n this._scale = new osg.MatrixTransform()\r\n this._scale.setName('Lighting - ScaleIcon ' + index)\r\n this._mtEditLight = new osg.MatrixTransform()\r\n this._mtEditLight\r\n .getOrCreateStateSet()\r\n .setTextureAttributeAndModes(0, dummyTexture)\r\n this._mtEditLight.setName('Lighting - MtEditLight ' + index)\r\n var editLightSS = this._mtEditLight.getOrCreateStateSet()\r\n editLightSS.addUniform(osg.Uniform.createFloat4(osg.vec4.fromValues(1, 1, 1, 1), 'uColor'))\r\n editLightSS.addUniform(osg.Uniform.createInt(1, 'uEnable'))\r\n editLightSS.addUniform(osg.Uniform.createInt(0, 'uTextureDepth'))\r\n this._node.addChild(this._mtLight)\r\n this._node.addChild(this._mtEditLight)\r\n this._mtLight.addChild(this._lightSource)\r\n this._mtEditLight.addChild(this._scale)\r\n this._scale.addChild(this._mtQuad)\r\n this._scale.addChild(this._dirGeom)\r\n this._mtQuad.addChild(this._quadGeom)\r\n this._dirty = true\r\n this._updateMatrixOnToggleCamera = true\r\n this._scene = null\r\n }\r\n\r\n setDepthTexture(depthTexture) {\r\n depthTexture && this._mtEditLight.getOrCreateStateSet().setTextureAttributeAndModes(0, depthTexture)\r\n }\r\n\r\n setScene(scene) {\r\n this._scene = scene\r\n }\r\n getShadowMap() {\r\n return this._shadowMap\r\n }\r\n\r\n getLightSource() {\r\n return this._lightSource\r\n }\r\n getNodeScale() {\r\n return this._scale\r\n }\r\n getNodeQuad() {\r\n return this._mtQuad\r\n }\r\n getNode() {\r\n return this._node\r\n }\r\n getNodeLight() {\r\n return this._mtLight\r\n }\r\n getNodeEditLight() {\r\n return this._mtEditLight\r\n }\r\n dirty() {\r\n this._dirty = true\r\n }\r\n isDirty() {\r\n return this._dirty\r\n }\r\n updateNode() {\r\n if (this._dirty) {\r\n this._dirty = false\r\n var node = this._node\r\n var light = this._light\r\n var type = this.get('type')\r\n if ('NONE' === type) {\r\n node.setNodeMask(0)\r\n light.setEnabled(false)\r\n this._mtEditLight.editMask = 0\r\n return\r\n }\r\n\r\n node.setNodeMask(-1)\r\n\r\n this._mtEditLight.editMask = osgUtil.NodeGizmo.PICK_GIZMO\r\n\r\n var lightEnable = this.get('enable')\r\n light.setLightType(type)\r\n light.setEnabled(lightEnable)\r\n osg.mat4.copy(this._mtLight.getMatrix(), this.get('matrix'))\r\n\r\n \r\n\r\n this._mtLight.dirtyBound()\r\n this._mtEditLight.dirtyBound()\r\n osg.vec3.scale(light.getDiffuse(), this.get('color'), this.get('intensity'))\r\n osg.vec3.copy(light.getSpecular(), light.getDiffuse())\r\n\r\n var shadowMap = this.getShadowMap();\r\n if(shadowMap) {\r\n shadowMap.setTextureSize(Config.shadowTextureSize)\r\n shadowMap.setBias(0.005)\r\n }\r\n\r\n // Config.shadowNormalOffset && shadowMap.setNormalBias(this.get(\"shadowNormalBias\"))),\r\n\r\n this._mtLight.setReferenceFrame(osg.Transform.RELATIVE_RF)\r\n this._mtLight.setCullingActive(true)\r\n this._dirGeom.setNodeMask(\r\n lightEnable && 'DIRECTION' === type ? PickMask.NO_PICK_NO_SHADOW : 0\r\n )\r\n\r\n osg.vec3.copy(\r\n this._mtEditLight\r\n .getOrCreateStateSet()\r\n .getUniform('uColor')\r\n .getInternalArray(),\r\n this.get('color')\r\n )\r\n var stateSet = this._mtEditLight.getOrCreateStateSet()\r\n stateSet.getUniform('uEnable').setInt(0 | lightEnable),\r\n this._quadGeom.setLightType(type)\r\n }\r\n }\r\n setLightUnit(unit) {\r\n if (this._light.getLightNumber() !== unit) {\r\n this._light.setLightNumber(unit)\r\n this._light.setName('osg' + this._light.getTypeMember())\r\n this._shadowMap.dirty()\r\n }\r\n\r\n }\r\n setIconVisibility(visiable) {\r\n this._mtEditLight.setNodeMask(visiable ? PickMask.PICK_GIZMO_LIGHT : 0)\r\n }\r\n\r\n setUpdateMatrixOnToggleCamera(enable) {\r\n this._updateMatrixOnToggleCamera = enable\r\n }\r\n\r\n setJSON(json) {\r\n\r\n this.set(json)\r\n }\r\n getJSON() {\r\n return this.toJSON()\r\n }\r\n}\r\n\r\n\r\n\r\nclass LightsModel extends Model {\r\n\r\n defaults() {\r\n return {\r\n select: -1,\r\n lights: [new LightModel(), new LightModel(), new LightModel()],\r\n forceShadowRedraw: false\r\n }\r\n }\r\n getName() {\r\n return 'Lighting'\r\n }\r\n \r\n dirtyScene() {\r\n\r\n let bc = new BoundingComputer();\r\n bc.computePreciseBox(this._app.getRootModel());\r\n var modelBoxWithDisp = bc.getModelBoxWithDisplacement();\r\n var lights = this.get('lights')\r\n var translate = osg.vec3.fromValues(0, 0, 0.8 * modelBoxWithDisp.radius())\r\n var center = modelBoxWithDisp.center(osg.vec3.create())\r\n for (\r\n var o = 0;\r\n o < 3;\r\n ++o\r\n ) {\r\n var lightModel = lights[o]\r\n var matrix = lightModel.get('matrix')\r\n\r\n matrix[12] = center[0]\r\n matrix[13] = center[1]\r\n matrix[14] = center[2]\r\n osg.mat4.translate(matrix, matrix, translate)\r\n lightModel.dirty()\r\n }\r\n }\r\n\r\n\r\n init(app, lightingFeature) {\r\n this._app = app\r\n this._lightingFeature = lightingFeature\r\n this._root = this._app.getRootModel()\r\n this.initLights()\r\n this._app._finishPromise.then(this.initDepthTexture.bind(this))\r\n\r\n }\r\n\r\n initDepthTexture() {\r\n for (\r\n var depthTexture = this._app.getFeaturesManager().getTextureDepth(),\r\n lights = this.get('lights'),\r\n i = 0;\r\n i < 3;\r\n ++i\r\n )\r\n lights[i].setDepthTexture(depthTexture)\r\n }\r\n\r\n initLights() {\r\n var lights = this.get('lights')\r\n for (var index = 0; index < 3; ++index){\r\n lights[index].setScene(this._root)\r\n lights[index].init(index, this._lightingFeature)\r\n }\r\n \r\n }\r\n getJSON() {\r\n var json = {}\r\n var lights = this.get('lights')\r\n json.enable = this.get('enable')\r\n json.lights = [lights[0].getJSON(), lights[1].getJSON(), lights[2].getJSON()]\r\n return json\r\n }\r\n setJSON(json, dirtyScene) {\r\n var lights = this.get('lights')\r\n this.set('enable', json.enable)\r\n for (var o = 0; o < 3; ++o) {\r\n var jsonLight = json.lights[o]\r\n if (jsonLight) {\r\n var light = lights[o]\r\n light.setUpdateMatrixOnToggleCamera(false)\r\n light.setJSON(jsonLight)\r\n light.setUpdateMatrixOnToggleCamera(true)\r\n dirtyScene && this.dirtyScene()\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default class LightingFeature {\r\n constructor(app) {\r\n this._app = app;\r\n var shadowmapSizeUniform = app.globalUniform.uShadowMapSize.getInternalArray();\r\n shadowmapSizeUniform[0] = Config.shadowTextureSize\r\n shadowmapSizeUniform[1] = Config.shadowTextureSize\r\n this._viewerOSGJS = this._app.getViewerOSGJS();\r\n this._manipulator = this._viewerOSGJS.getManipulator();\r\n this._isScreenshot = false;\r\n this.model = new LightsModel()\r\n this.model.bind('change:select', this.onSelectChanged, this)\r\n this.model.bind('change:enable', this.onEnableChanged, this)\r\n this.model.bind('change', this._app.redraw, this._app)\r\n if (Config.shadowAtlas) {\r\n this._shadowAtlasSetting = createShadowSetting();\r\n this._shadowAtlasSetting.atlasSize = 2 * Config.shadowTextureSize;\r\n this._shadowAtlasSetting.setTextureSize(Config.shadowTextureSize);\r\n this._shadowMapAtlas = new osgShadow.ShadowMapAtlas(this._shadowAtlasSetting);\r\n this._shadowMapAtlas.setTextureUnitBase(MaterialUtils.SHADOW_TEXTURE_UNIT);\r\n }\r\n this.model.init(this._app, this)\r\n this._nodeFeature = new osg.Node();\r\n this._nodeFeature.setName('Feature - Lighting');\r\n this._shadowNode = new osgShadow.ShadowedScene(createShadowSetting())\r\n this._shadowNode.setName(\"Shadowed scene\")\r\n this._lightNode = new osg.Camera();\r\n this._lightNode.setName('Lighting - Camera');\r\n this._lightNode.setNearFarRatio(5e-5);\r\n var lightnodeStateSet = this._lightNode.getOrCreateStateSet();\r\n lightnodeStateSet.setRenderBinDetails(RenderDetail.EDITOR_GIZMO, 'RenderBin');\r\n this._lightNode.setNodeMask(PickMask.NO_SHADOW);\r\n this.initLightNode();\r\n this.onEnableChanged();\r\n this._nodeFeature.addChild(this._lightNode);\r\n this._showLighting = false\r\n this._onLightGizmoEditing = null\r\n }\r\n\r\n\r\n addShadowMap(shadowedScene, shadowmap) {\r\n if (Config.shadow) {\r\n shadowmap.setContinuousUpdate(false);\r\n if (Config.shadowAtlas) {\r\n shadowedScene.addShadowTechnique(this._shadowMapAtlas);\r\n this._shadowMapAtlas.addShadowMap(shadowmap);\r\n } else {\r\n shadowedScene.addShadowTechnique(shadowmap);\r\n }\r\n }\r\n }\r\n\r\n removeShadowMap(shadowedScene, shadowmap) {\r\n Config.shadowAtlas\r\n ? this._shadowMapAtlas.removeShadowMap(shadowmap)\r\n : shadowedScene.removeShadowTechnique(shadowmap);\r\n };\r\n\r\n createLight(feature, index, type) {\r\n var transform = new osg.MatrixTransform()\r\n transform.setName(feature + ' - LightNode ' + index)\r\n transform.getOrCreateStateSet().setAttributeAndModes(GLState.DEPTH_DISABLE)\r\n var light = new EditorLight(index)\r\n type && light.setLightType(type)\r\n light.setName(feature + ' - Light ' + index)\r\n osg.vec3.copy(light.getAmbient(), osg.vec3.ZERO)\r\n osg.vec3.copy(light.getSpecular(), osg.vec3.ZERO)\r\n light.setLinearAttenuation(0)\r\n\r\n var lightSource = new osg.LightSource()\r\n lightSource.setName(feature + ' - LightSource ' + index)\r\n lightSource.setLight(light)\r\n\r\n var shadowMap\r\n var shadowSetting\r\n if (!Config.shadow) {\r\n return {\r\n node: transform,\r\n light: light,\r\n lightSource: lightSource,\r\n shadowSettings: this._shadowMapAtlas ? this._shadowAtlasSetting : createShadowSetting(light),\r\n enableShadow: false,\r\n };\r\n }\r\n if (this._shadowMapAtlas) {\r\n shadowSetting = this._shadowAtlasSetting\r\n shadowMap = this._shadowMapAtlas.addLight(light)\r\n }\r\n else {\r\n shadowSetting = createShadowSetting(light);\r\n shadowMap = new osgShadow.ShadowMap(shadowSetting);\r\n shadowMap.setTextureUnitBase(MaterialUtils.SHADOW_TEXTURE_UNIT);\r\n shadowMap.setContinuousUpdate(false);\r\n shadowMap.setTextureSize(Config.shadowTextureSize);\r\n }\r\n shadowMap.setJitterOffset(Config.shadowJitterOffset);\r\n\r\n\r\n return {\r\n node: transform,\r\n light: light,\r\n lightSource: lightSource,\r\n shadowSettings: shadowSetting,\r\n shadowMap: shadowMap,\r\n enableShadow: Config.shadow && MaxTextureUnit() > MaterialUtils.SHADOW_TEXTURE_UNIT,\r\n }\r\n\r\n }\r\n\r\n getNode() {\r\n return this._nodeFeature;\r\n }\r\n\r\n getNodeLight() {\r\n return this._lightNode;\r\n }\r\n getNodeShadow() {\r\n return this._shadowNode\r\n }\r\n enable(value) {\r\n this.model.set('enable', value)\r\n }\r\n\r\n getModel() {\r\n return this.model\r\n }\r\n\r\n setSelect(index){\r\n this.model.set('select', index)\r\n }\r\n\r\n isLightNone(index) {\r\n return -1 === index || 'NONE' === this.model.get('lights')[index].get('type')\r\n }\r\n\r\n showLighting(visiable) {\r\n this._showLighting = visiable\r\n this._app.redraw()\r\n }\r\n\r\n\r\n onEnableChanged() {\r\n var enable = this.model.get('enable')\r\n this._lightNode.setNodeMask(enable ? PickMask.NO_SHADOW : 0)\r\n if (!enable) {\r\n var gizmo = this.getGizmo()\r\n gizmo && gizmo.attachToNode(null)\r\n }\r\n for (\r\n var lights = this.model.get('lights'), n = 0, r = lights.length;\r\n n < r;\r\n ++n\r\n ) {\r\n var lightModel = lights[n]\r\n var lightEnable = enable && lightModel.get('enable')\r\n lightModel.getLightSource().getLight().setEnabled(lightEnable)\r\n Config.shadowAtlas && !lightEnable && this.removeShadowMap(this._shadowNode, lightModel.getShadowMap())\r\n }\r\n enable && this._updateLightsAndIcons()\r\n }\r\n\r\n initLightNode() {\r\n this._nodeFeature.addUpdateCallback(this)\r\n for (\r\n var lights = this.model.get('lights'), t = 0, i = lights.length;\r\n t < i;\r\n ++t\r\n ) {\r\n var lightModel = lights[t]\r\n lightModel.setLightUnit(t)\r\n lightModel.bind('change', lightModel.dirty, lightModel)\r\n lightModel.bind('change', this._app.redraw, this._app)\r\n this._lightNode.addChild(lightModel.getNode())\r\n }\r\n }\r\n\r\n getGizmo() {\r\n const featureManager = this._app.getFeaturesManager();\r\n return featureManager ? featureManager.getNodeGizmo() : null;\r\n }\r\n\r\n onSelectChanged() {\r\n let gizmoNode = this.getGizmo();\r\n if (gizmoNode) {\r\n var index = this.model.get('select');\r\n if (this.isLightNone(index)) {\r\n gizmoNode.attachToNode(null)\r\n } else {\r\n gizmoNode.attachToNode(this.model.get('lights')[index].getNodeEditLight());\r\n }\r\n }\r\n }\r\n\r\n updateSelection() {\r\n var gizmoNode = this.getGizmo();\r\n if (gizmoNode && !gizmoNode._isEditing) {\r\n var attachnode = gizmoNode._attachedNode;\r\n if (!this.isLightNone(this.model.get('select')) || attachnode) {\r\n for (\r\n var lights = this.model.get('lights'), index = 0;\r\n index < 3;\r\n ++index\r\n ) {\r\n if (lights[index].getNodeEditLight() === attachnode) {\r\n gizmoNode.updateGizmoMask();\r\n this.model.set('select', index);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n setLightGizmoEditingCallback(cb) {\r\n this._onLightGizmoEditing = cb\r\n }\r\n\r\n updateLightIcons() {\r\n var tempVec4 = osg.vec4.create()\r\n var tempVec3 = osg.vec3.create()\r\n var eye = osg.vec3.create()\r\n var tempQuat = osg.quat.create()\r\n var lights = this.model.get('lights')\r\n var camera = this._app.getCamera()\r\n var fov = this._app.getFeaturesManager().getIconScaleFov()\r\n this._manipulator.getEyePosition(eye)\r\n for (var gizmo = this.getGizmo(), u = 0; u < 3; ++u) {\r\n var lightModel = lights[u]\r\n if ('NONE' !== lightModel.get('type')) {\r\n var editLight = lightModel.getNodeEditLight()\r\n var nodeLight = lightModel.getNodeLight()\r\n var lightQuad = lightModel.getNodeQuad()\r\n var lightScale = lightModel.getNodeScale()\r\n var isEditing = gizmo._isEditing && gizmo._attachedNode === editLight\r\n var quadMatrix = lightQuad.getMatrix()\r\n var editMatrix = editLight.getMatrix()\r\n var nodeMatrix = nodeLight.getMatrix()\r\n\r\n if (isEditing) {\r\n osg.mat4.copy(nodeMatrix, editMatrix) \r\n if (this._onLightGizmoEditing)\r\n this._onLightGizmoEditing(nodeMatrix)\r\n } else {\r\n osg.mat4.copy(editMatrix, nodeMatrix)\r\n }\r\n\r\n osg.mat4.copy(lightModel.get('matrix'), nodeMatrix)\r\n editLight.getWorldMatrix(void 0, quadMatrix)\r\n osg.mat4.getTranslation(tempVec3, quadMatrix)\r\n var v = osg.vec3.dist(eye, tempVec3) / fov\r\n osg.mat4.fromScaling(\r\n lightScale.getMatrix(),\r\n osg.vec3.set(tempVec4, v, v, v)\r\n )\r\n osg.mat4.multiply(quadMatrix, camera.getViewMatrix(), quadMatrix)\r\n osg.mat4.invert(quadMatrix, quadMatrix)\r\n osg.mat4.fromQuat(quadMatrix, osg.mat4.getRotation(tempQuat, quadMatrix))\r\n lightQuad.dirtyBound()\r\n nodeLight.dirtyBound()\r\n lightScale.dirtyBound()\r\n }\r\n }\r\n }\r\n\r\n setIsScreenshot(screenshot) {\r\n this._isScreenshot = screenshot;\r\n }\r\n\r\n _updateLightsAndIcons() {\r\n if (this._lightNode.getNodeMask() && this._shadowNode.getChildren().length) {\r\n var shadowNeedUpdate = this._app.getFeaturesManager().getShadowForcedUpdate()\r\n var lights = this.model.get('lights')\r\n var showLight = !this._isScreenshot && this._showLighting\r\n for (var o = 0; o < 3; ++o) {\r\n var light = lights[o]\r\n var needUpdate = light.isDirty() || shadowNeedUpdate\r\n\r\n light.updateNode();\r\n var shadowMap = light.getShadowMap();\r\n if (shadowMap) {\r\n\r\n if (light.get(\"enable\") && !this.isLightNone(o)) {\r\n if (!(needUpdate = needUpdate || shadowNeedUpdate)) {\r\n for (var curMat = light.get(\"matrix\"), preMat = light.get(\"matrixPrev\"), d = 0; d < 16; d++)\r\n if (curMat[d] !== preMat[d]) {\r\n needUpdate = true;\r\n break\r\n }\r\n osg.mat4.copy(preMat, curMat)\r\n }\r\n if(needUpdate) {\r\n shadowMap.requestRedraw()\r\n }\r\n this.addShadowMap(this._shadowNode, shadowMap)\r\n } else{\r\n needUpdate && this.removeShadowMap(this._shadowNode, shadowMap);\r\n }\r\n \r\n \r\n }\r\n light.setIconVisibility(showLight)\r\n\r\n }\r\n if(showLight){\r\n this.updateLightIcons()\r\n this.updateSelection()\r\n }\r\n\r\n\r\n }\r\n }\r\n\r\n update(lightNode, updateVisitor) {\r\n if (lightNode.getNumChildrenRequiringUpdateTraversal() > 0)\r\n updateVisitor.traverse(lightNode);\r\n this._updateLightsAndIcons();\r\n return false\r\n }\r\n\r\n prepareForScreenShot () {\r\n this.setIsScreenshot(true)\r\n }\r\n \r\n resetAfterScreenShot () {\r\n this.setIsScreenshot(false)\r\n }\r\n}\r\n","import osg from '../osg/osg';\r\nimport PickMask from './PickMask.js';\r\n\r\nclass CullVisitor extends osg.CullVisitor {\r\n constructor(app) {\r\n super();\r\n this._separateVR = false\r\n this._isEnv = false\r\n this._isRootModel = false\r\n this._app = app\r\n }\r\n\r\n popCameraModelViewProjectionMatrix(e) {\r\n this.popModelViewMatrix(), this.popProjectionMatrix(e);\r\n }\r\n reset() {\r\n osg.CullVisitor.prototype.reset.call(this),\r\n (this._minNear = this._computedNear),\r\n (this._maxFar = this._computedFar);\r\n }\r\n updateNearFar() {\r\n (this._minNear = Math.min(this._minNear, this._computedNear)),\r\n (this._maxFar = Math.max(this._maxFar, this._computedFar));\r\n }\r\n _handleMainCamera(camera) {\r\n var projection = this.getCurrentProjectionMatrix(),\r\n near = this._computedNear,\r\n far = this._computedFar,\r\n ratio = this._nearFarRatio,\r\n projectionStackTop = this._projectionMatrixStack.getArray()[0];\r\n osg.mat4.copy(projectionStackTop, projection);\r\n this.clampProjectionMatrix(\r\n projectionStackTop,\r\n this._minNear,\r\n this._maxFar,\r\n 1e-5,\r\n );\r\n if (CullVisitor.vrConfig.doVR) {\r\n this.clampProjectionMatrix(\r\n CullVisitor.vrConfig.leftProjection,\r\n near,\r\n far,\r\n ratio,\r\n );\r\n this.clampProjectionMatrix(\r\n CullVisitor.vrConfig.rightProjection,\r\n near,\r\n far,\r\n ratio,\r\n );\r\n }\r\n var nearfar = this._app.globalUniform.uNearFar.getInternalArray();\r\n this.clampProjectionMatrix(projection, near, far, ratio, nearfar);\r\n camera.clampedProjectionMatrix\r\n ? osg.mat4.copy(camera.clampedProjectionMatrix, projection)\r\n : (camera.clampedProjectionMatrix = osg.mat4.clone(projection));\r\n }\r\n popProjectionMatrix(camera) {\r\n if (\r\n true === this._computeNearFar &&\r\n this._computedFar >= this._computedNear\r\n ) {\r\n var isMainCamera = camera === this._app.cameraMain;\r\n (isMainCamera ||\r\n (camera.getReferenceFrame() === osg.Transform.RELATIVE_RF &&\r\n !camera.isRenderToTextureCamera())) &&\r\n this.updateNearFar(),\r\n isMainCamera\r\n ? this._handleMainCamera(camera)\r\n : this.clampProjectionMatrix(\r\n this.getCurrentProjectionMatrix(),\r\n this._computedNear,\r\n this._computedFar,\r\n this._nearFarRatio,\r\n );\r\n }\r\n osg.CullStack.prototype.popProjectionMatrix.call(this);\r\n }\r\n handleCullCallbacksAndTraverse(node) {\r\n node === this._app.nodePostProcessOut\r\n ? (this._separateVR = CullVisitor.vrConfig.doVR)\r\n : node === this._app.cameraEnvironment\r\n ? (this._isEnv = true)\r\n : node === this._app.nodeRootModel && (this._isRootModel = true);\r\n var callback = node.getCullCallback();\r\n (callback && !callback.cull(node, this)) || this.traverse(node),\r\n node === this._app.nodePostProcessOut\r\n ? (this._separateVR = false)\r\n : node === this._app.cameraEnvironment\r\n ? (this._isEnv = false)\r\n : node === this._app.nodeRootModel && (this._isRootModel = false);\r\n }\r\n pushLeaf(geometry, depth) {\r\n let leafs = this._currentStateGraph._leafs;\r\n if (0 === leafs.getLength()) {\r\n this._currentRenderBin.addStateGraph(this._currentStateGraph);\r\n }\r\n let isVR = this._separateVR && this.traversalMask !== PickMask.SHADOW,\r\n leaf = this.createOrReuseRenderLeaf();\r\n leaf.isVR = isVR;\r\n if (isVR) {\r\n let isEnv = this._isEnv,\r\n modelViewMat = this.getCurrentModelViewMatrix(),\r\n viewMat = this.getCurrentViewMatrix();\r\n leaf.leftProjection = CullVisitor.vrConfig.leftProjection;\r\n leaf.rightProjection = CullVisitor.vrConfig.rightProjection;\r\n let leftModelView = leaf.leftModelView || osg.mat4.create(),\r\n rightModelView = leaf.rightModelView || osg.mat4.create();\r\n leaf.leftModelView = isEnv\r\n ? osg.mat4.copy(leftModelView, modelViewMat)\r\n : osg.mat4.multiply(\r\n leftModelView,\r\n CullVisitor.vrConfig.leftOffsetView,\r\n modelViewMat,\r\n );\r\n leaf.rightModelView = isEnv\r\n ? osg.mat4.copy(rightModelView, modelViewMat)\r\n : osg.mat4.multiply(\r\n rightModelView,\r\n CullVisitor.vrConfig.rightOffsetView,\r\n modelViewMat,\r\n );\r\n let leftView = leaf.leftView || osg.mat4.create(),\r\n rightView = leaf.rightView || osg.mat4.create();\r\n leaf.leftView = isEnv\r\n ? osg.mat4.copy(leftView, viewMat)\r\n : osg.mat4.multiply(\r\n leftView,\r\n CullVisitor.vrConfig.leftOffsetView,\r\n viewMat,\r\n );\r\n leaf.rightView = isEnv\r\n ? osg.mat4.copy(rightView, viewMat)\r\n : osg.mat4.multiply(\r\n rightView,\r\n CullVisitor.vrConfig.rightOffsetView,\r\n viewMat,\r\n );\r\n }\r\n leaf.init(\r\n this._currentStateGraph,\r\n geometry,\r\n this.getCurrentProjectionMatrix(),\r\n this.getCurrentViewMatrix(),\r\n this.getCurrentModelViewMatrix(),\r\n this.getCurrentModelMatrix(),\r\n depth,\r\n ),\r\n leafs.push(leaf);\r\n }\r\n updateCalculatedNearFar(matrix, drawable) {\r\n /*\r\n var i = getModelBoxWithoutDisplacement();\r\n if (i && this._isRootModel) {\r\n var n = (0,\r\n s.Z)().scaleEpsilon * i.radius() / t.getBound().radius();\r\n n *= n;\r\n var r = e[0]\r\n , a = e[4]\r\n , l = e[8];\r\n if (r * r + a * a + l * l < n && (r = e[1]) * r + (a = e[5]) * a + (l = e[9]) * l < n && (r = e[2]) * r + (a = e[6]) * a + (l = e[10]) * l < n)\r\n return false\r\n }\r\n */\r\n return osg.CullVisitor.prototype.updateCalculatedNearFar.call(\r\n this,\r\n matrix,\r\n drawable,\r\n );\r\n }\r\n}\r\n\r\nCullVisitor.vrConfig = {\r\n doVR: false,\r\n framebufferWidth: 0,\r\n framebufferHeight: 0,\r\n leftRenderWidth: 0,\r\n rightRenderWidth: 0,\r\n leftRenderHeight: 0,\r\n rightRenderHeight: 0,\r\n rightProjection: osg.mat4.create(),\r\n leftProjection: osg.mat4.create(),\r\n leftOffsetView: osg.mat4.create(),\r\n rightOffsetView: osg.mat4.create(),\r\n};\r\n\r\n\r\nexport default CullVisitor;\r\n","const RenderPassEnum = {\r\n DEFAULT: 1,\r\n EARLYZ_OPAQUE: 2,\r\n EARLYZ_TRANSPARENT: 4,\r\n OPAQUE_SHADING: 8,\r\n TRANSPARENT_SHADING: 16,\r\n REFRACTION: 32,\r\n EXTRA: 64,\r\n SHADOWMAP: 128,\r\n};\r\n\r\nRenderPassEnum.ANY_OPAQUE = RenderPassEnum.EARLYZ_OPAQUE | RenderPassEnum.OPAQUE_SHADING;\r\nRenderPassEnum.ANY_TRANSPARENT = RenderPassEnum.REFRACTION | RenderPassEnum.EARLYZ_TRANSPARENT | RenderPassEnum.TRANSPARENT_SHADING;\r\nexport default RenderPassEnum","import GLState from './GLState.js';\r\nimport osg from \"../osg/osg\";\r\nimport RenderDetail from './RenderDetail.js';\r\nimport RenderPassEnum from './RenderPassEnum.js';\r\n\r\nconst renderLeafDrawGeometry = osg.RenderLeaf.prototype.drawGeometry\r\nconst PBRMaterialAttributeIndex = osg.getOrCreateStateAttributeTypeMemberIndexFromName('PBRMaterial');\r\n\r\nconst drawGeometryImp = function (geometry, state, isTriangles) {\r\n if (!isTriangles)\r\n return (\r\n state.applyAttribute(GLState.CULL_DISABLE),\r\n void renderLeafDrawGeometry.call(geometry, state)\r\n );\r\n var doubleDraw = false;\r\n var RenderInfo = state.getUserData().RenderInfo\r\n if (RenderInfo.currentPass === RenderPassEnum.TRANSPARENT_SHADING) {\r\n var attributeArray = state._attributeArray[PBRMaterialAttributeIndex],\r\n lastApplied = attributeArray ? attributeArray._lastApplied : void 0;\r\n if (lastApplied)\r\n doubleDraw = lastApplied.getCullFace() === osg.CullFace.DISABLE;\r\n }\r\n doubleDraw && state.applyAttribute(GLState.CULL_FRONT);\r\n renderLeafDrawGeometry.call(geometry, state);\r\n if (doubleDraw) {\r\n state.applyAttribute(GLState.CULL_BACK);\r\n geometry._geometry.drawImplementation(state);\r\n }\r\n};\r\n\r\nfunction needDraw(state) {\r\n var t = state._attributeArray[PBRMaterialAttributeIndex],\r\n lastApplied = t ? t._lastApplied : undefined;\r\n if (!lastApplied) return true;\r\n var RenderInfo = state.getUserData().RenderInfo\r\n var curPass = RenderInfo.currentPass;\r\n if (!lastApplied.getDepthWrite() && curPass & RenderPassEnum.ANY_OPAQUE)\r\n return false;\r\n if(lastApplied.getOnlyDepthMaskNoShading() && curPass & RenderPassEnum.OPAQUE_SHADING)\r\n return false\r\n // if (!lastApplied.getCastShadows() && curPass & RenderPassEnum.SHADOWMAP)\r\n // return false;\r\n if (curPass !== RenderPassEnum.EARLYZ_TRANSPARENT) return true;\r\n var blendFunc = GLState.BLEND_SUBSTRACTIVE\r\n state.applyAttribute(blendFunc);\r\n return true;\r\n}\r\n\r\nfunction modifyDrawOpaqueUniform(gl, uniformCache, program, state) {\r\n var opaqueUniform = uniformCache && uniformCache.uDrawOpaque;\r\n if (undefined !== opaqueUniform) {\r\n var stateUserData = state.getUserData()\r\n var RenderInfo = stateUserData.RenderInfo\r\n var app = stateUserData.app \r\n var uniformCacheByInstanceId = stateUserData.uniformCacheByInstanceId\r\n var currentPass = RenderInfo.currentPass,\r\n drawOpaque = app.globalUniform.uDrawOpaque,\r\n valuesArray = drawOpaque.getInternalArray(),\r\n value = currentPass & RenderPassEnum.ANY_TRANSPARENT ? 0 : 1;\r\n valuesArray[0] = value;\r\n drawOpaque.apply(gl, opaqueUniform);\r\n var instanceid = program.getInstanceID();\r\n if(uniformCacheByInstanceId[instanceid] !== value) {\r\n uniformCacheByInstanceId[instanceid] = value\r\n drawOpaque.apply(gl, opaqueUniform)\r\n }\r\n }\r\n}\r\n\r\n// function QVT(graphicContext, uniformCache, geometry) {\r\n// if (geometry._QVT && uniformCache && undefined !== uniformCache.uQVT) {\r\n// GlobalUniform.uQVT.setFloat3(geometry._QVT);\r\n// GlobalUniform.uQVT.apply(graphicContext, uniformCache.uQVT);\r\n// GlobalUniform.uQVS.setFloat3(geometry._QVS);\r\n// GlobalUniform.uQVS.apply(graphicContext, uniformCache.uQVS);\r\n// }\r\n// var listQuantUV = geometry._listQuantUV;\r\n// if (listQuantUV)\r\n// for (var index = 0; index < listQuantUV.length; ++index) {\r\n// const quantUV = listQuantUV[index];\r\n// const uniformName = quantUV.uniformName;\r\n// const cacheValue = uniformCache && uniformCache[uniformName];\r\n// if (undefined !== cacheValue) {\r\n// GlobalUniform[uniformName].setFloat4(quantUV._QUV);\r\n// GlobalUniform[uniformName].apply(graphicContext, cacheValue);\r\n// }\r\n// }\r\n// }\r\n\r\nfunction isPrimitiveTriangles(geometry) {\r\n for (\r\n var primitivelist = geometry.getPrimitiveSetList(),\r\n i = 0,\r\n n = primitivelist.length;\r\n i < n;\r\n ++i\r\n )\r\n if (primitivelist[i].getMode() >= osg.primitiveSet.TRIANGLES) return true;\r\n return false;\r\n}\r\n\r\nosg.RenderLeaf.prototype.drawGeometry = function (state) {\r\n if (needDraw(state)) {\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n\r\n ForceAttribute.depth && state.applyAttribute(ForceAttribute.depth);\r\n ForceAttribute.blend && state.applyAttribute(ForceAttribute.blend);\r\n ForceAttribute.colorMask && state.applyAttribute(ForceAttribute.colorMask);\r\n var graphicContext = state.getGraphicContext(),\r\n program = state.getLastProgramApplied(),\r\n uniformCache = program.getUniformsCache();\r\n var stateUserData = state.getUserData()\r\n !modifyDrawOpaqueUniform(graphicContext, uniformCache, program, state)\r\n // QVT(graphicContext, uniformCache, this._geometry);\r\n\r\n var isTriangles = isPrimitiveTriangles(this._geometry)\r\n // var lastLeaf = RenderInfo.LAST_LEAF;\r\n drawGeometryImp(this, state, isTriangles);\r\n }\r\n};\r\n\r\n\r\n\r\nvar sortBin = function (a, b) {\r\n return a._binNum - b._binNum;\r\n};\r\n\r\nvar getInsertPosition = function (state, previous) {\r\n var sg = previous ? previous._parent : undefined;\r\n var num = 0;\r\n // need to pop back all statesets and matrices.\r\n while (sg) {\r\n if (sg._stateset) num++;\r\n sg = sg._parent;\r\n }\r\n\r\n if (num > 1) num--;\r\n return state.getStateSetStackSize() - num;\r\n};\r\n\r\nconst StateAttributeOverrideOn = osg.StateAttribute.OVERRIDE_ON;\r\n\r\nconst EarlyZStateSet = (function () {\r\n var ss = new osg.StateSet();\r\n ss.setShaderGeneratorName('earlyz', StateAttributeOverrideOn);\r\n // for (var t = MaxTextureUnit(), i = 0; i < t; i++)\r\n // ss.setTextureAttributeAndModes(\r\n // i,\r\n // osg.Texture.textureNull,\r\n // StateAttributeOverrideOn,\r\n // );\r\n return ss;\r\n})();\r\n\r\nconst ClearDepthRGBA = osg.vec4.fromValues(1, 1, 1, 0);\r\nconst clearTranpanrentRGBA = osg.vec4.fromValues(0, 0, 0, 0);\r\nclass RenderStageSplitter extends osg.RenderStage {\r\n constructor(app) {\r\n super();\r\n this._binArraySorted = [];\r\n this._app = app\r\n }\r\n\r\n init() {\r\n osg.RenderStage.prototype.init.call(this);\r\n this._binArraySorted.length = 0; // why\r\n this._renderBufferDepthAttachment = undefined;\r\n return this;\r\n }\r\n\r\n isMainCamera() {\r\n var camera = this.getCamera();\r\n if (camera && this._app.cameraMain === camera) return true;\r\n return false;\r\n }\r\n\r\n isShadowCasterCamera() {\r\n var camera = this.getCamera(),\r\n name = camera && camera.getName();\r\n return !(!name || !name.startsWith('light_shadow_camera'));\r\n }\r\n\r\n sortBinArray() {\r\n var binsArray = this._binArraySorted;\r\n binsArray.length = 0;\r\n\r\n this._bins.forEach(function (key, bin) {\r\n binsArray.push(bin);\r\n });\r\n\r\n binsArray.sort(sortBin);\r\n }\r\n\r\n bindDepthRTT(e) {\r\n this.getCamera().fboDepth.apply(e);\r\n }\r\n\r\n bindTransparencyRTT(e) {\r\n this.getCamera().fboTransparent.apply(e);\r\n }\r\n\r\n bindRefractionRTT(e) {\r\n this.getCamera().fboRefraction.apply(e);\r\n }\r\n\r\n bindOpaqueRTT(e) {\r\n this.getCamera().fboOpaque.apply(e);\r\n }\r\n\r\n bindExtraRTT(e) {\r\n this.getCamera().fboExtra.apply(e);\r\n }\r\n\r\n createFBO(state, texture) {\r\n if (texture) {\r\n var fbo = new osg.FrameBufferObject(),\r\n renderbufferDepthAttachment = this._renderBufferDepthAttachment;\r\n renderbufferDepthAttachment ||\r\n ((renderbufferDepthAttachment = {\r\n attachment: osg.FrameBufferObject.DEPTH_ATTACHMENT,\r\n format: osg.FrameBufferObject.DEPTH_COMPONENT16,\r\n width: texture.getWidth(),\r\n height: texture.getHeight(),\r\n }),\r\n (this._renderBufferDepthAttachment = renderbufferDepthAttachment)),\r\n fbo.setAttachment(renderbufferDepthAttachment);\r\n var colorAttachment = {\r\n attachment: osg.FrameBufferObject.COLOR_ATTACHMENT0,\r\n textureTarget: osg.Texture.TEXTURE_2D,\r\n texture: texture,\r\n };\r\n fbo.setAttachment(colorAttachment);\r\n fbo.apply(state);\r\n return fbo;\r\n }\r\n }\r\n\r\n createCamera2RTT(state) {\r\n var fbo;\r\n\r\n fbo = this.createFBO(state, this.getCamera()._textureOpaque);\r\n this.getCamera().frameBufferObject = fbo;\r\n\r\n fbo = this.createFBO(state, this.getCamera()._textureTransparent);\r\n this.getCamera().frameBufferObjectTransparent = fbo;\r\n }\r\n\r\n clearCameraColorDepth(state) {\r\n state.clearColor(this._app.clearOpaqueRGBA);\r\n state.depthMask(true);\r\n state.clearDepth(this.getClearDepth());\r\n state.clear(osg.Camera.COLOR_BUFFER_BIT | osg.Camera.DEPTH_BUFFER_BIT);\r\n }\r\n\r\n clearCameraColor(state) {\r\n state.clearColor(this._app.clearOpaqueRGBA);\r\n state.clear(osg.Camera.COLOR_BUFFER_BIT);\r\n }\r\n\r\n setClearDepth(depth) {\r\n this._clearDepth = depth;\r\n }\r\n\r\n getClearDepth() {\r\n return this._clearDepth;\r\n }\r\n\r\n isWritingDepth() {\r\n return !!this.getCamera()._textureDepth;\r\n }\r\n\r\n getDoEarlyZ() {\r\n // hastriangles\r\n return true || this.isWritingDepth();\r\n }\r\n\r\n drawExtraBin(state, renderLeaf) {\r\n var bin,\r\n leaf = renderLeaf,\r\n binArraySorted = this._binArraySorted;\r\n for (\r\n let index = 0, sortedLength = binArraySorted.length;\r\n index < sortedLength;\r\n index++\r\n ) {\r\n bin = binArraySorted[index];\r\n if (bin.getBinNumber() >= RenderDetail.EXTRA) {\r\n leaf = bin.draw(state, leaf);\r\n }\r\n }\r\n return leaf;\r\n }\r\n\r\n drawExtra(state, renderLeaf) {\r\n var RenderInfo = state.getUserData().RenderInfo\r\n RenderInfo.currentPass = RenderPassEnum.EXTRA;\r\n var leaf = this.drawExtraBin(state, renderLeaf);\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT;\r\n return leaf;\r\n }\r\n\r\n drawTransparentBin(state, previous) {\r\n var bin\r\n var previousLeaf = previous\r\n var binsorted = this._binArraySorted\r\n var index = 0\r\n var length = binsorted.length\r\n var RenderInfo = state.getUserData().RenderInfo\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n var isEarlyzTransparent = RenderInfo.currentPass === RenderPassEnum.EARLYZ_TRANSPARENT;\r\n for (; index < length;index++) {\r\n var binNum = (bin = binsorted[index]).getBinNumber()\r\n if (binNum !== RenderDetail.TRANSPARENT) {\r\n if (\r\n !isEarlyzTransparent &&\r\n (binNum === RenderDetail.TRANSPARENT_NO_EARLYZ_POST ||\r\n binNum === RenderDetail.TRANSPARENT_NO_EARLYZ_PRE)\r\n ) {\r\n var preDepth = ForceAttribute.depth\r\n ForceAttribute.depth = undefined\r\n previousLeaf = bin.draw(state, previousLeaf)\r\n ForceAttribute.depth = preDepth\r\n }\r\n } else previousLeaf = bin.draw(state, previousLeaf)\r\n }\r\n return previousLeaf\r\n }\r\n\r\n drawOpaqueBin(state, previous) {\r\n var bin,\r\n doearlyz = this.getDoEarlyZ(),\r\n previousLeaf = previous,\r\n binsorted = this._binArraySorted,\r\n ForceAttribute = state.getUserData().ForceAttribute,\r\n RenderInfo = state.getUserData().RenderInfo\r\n // bin = 0 opqque\r\n let index = 0;\r\n for (; index < binsorted.length; index++) {\r\n bin = binsorted[index];\r\n if (bin.getBinNumber() > 0) break;\r\n previousLeaf = bin.draw(state, previousLeaf);\r\n }\r\n // drawleafs\r\n previousLeaf = this.drawLeafs(state, previousLeaf);\r\n\r\n // draw other opaques\r\n var isOpaqueRenderPass = RenderInfo.currentPass === RenderPassEnum.OPAQUE_SHADING;\r\n for (; index < binsorted.length; index++) {\r\n bin = binsorted[index];\r\n var binNumber = bin.getBinNumber();\r\n if (\r\n binNumber === RenderDetail.OPAQUE ||\r\n binNumber === RenderDetail.REFRACTION ||\r\n (doearlyz && binNumber === RenderDetail.TRANSPARENT)\r\n )\r\n previousLeaf = bin.draw(state, previousLeaf);\r\n else if (\r\n isOpaqueRenderPass &&\r\n binNumber === RenderDetail.OPAQUE_NO_EARLYZ\r\n ) {\r\n var oldDepth = ForceAttribute.depth;\r\n ForceAttribute.depth = undefined;\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT;\r\n previousLeaf = bin.draw(state, previousLeaf)\r\n RenderInfo.currentPass = RenderPassEnum.OPAQUE_SHADING\r\n ForceAttribute.depth = oldDepth\r\n }\r\n }\r\n return previousLeaf;\r\n }\r\n\r\n drawOpaqueShading(state, previous) {\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n var RenderInfo = state.getUserData().RenderInfo\r\n RenderInfo.currentPass = RenderPassEnum.OPAQUE_SHADING\r\n ForceAttribute.depth = this.getDoEarlyZ() ? GLState.DEPTH_EQUAL_NO_WRITE : GLState.DEPTH_LESS_WRITE\r\n ForceAttribute.blend = GLState.BLEND_DISABLE\r\n var previous = this.drawOpaqueBin(state, previous);\r\n ForceAttribute.blend = undefined;\r\n ForceAttribute.depth = undefined;\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT;\r\n return previous;\r\n }\r\n\r\n drawEarlyOpaque(state, previous) {\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n var RenderInfo = state.getUserData().RenderInfo\r\n RenderInfo.currentPass = RenderPassEnum.EARLYZ_OPAQUE;\r\n ForceAttribute.depth = GLState.DEPTH_LESS_WRITE;\r\n ForceAttribute.blend = GLState.BLEND_DISABLE;\r\n ForceAttribute.colorMask = this.isWritingDepth()\r\n ? GLState.COLOR_MASK_RGBA\r\n : GLState.COLOR_MASK_NONE;\r\n var previousLeaf = this.drawOpaqueBin(state, previous);\r\n ForceAttribute.colorMask = undefined\r\n ForceAttribute.blend = undefined\r\n ForceAttribute.depth = undefined\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT\r\n return previousLeaf\r\n }\r\n\r\n drawTransparentShading(state, previous) {\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n var RenderInfo = state.getUserData().RenderInfo\r\n RenderInfo.currentPass = RenderPassEnum.TRANSPARENT_SHADING\r\n ForceAttribute.depth = GLState.DEPTH_LEQUAL_NO_WRITE\r\n ForceAttribute.blend = GLState.BLEND_SUBSTRACTIVE\r\n var previousLeaf = this.drawTransparentBin(state, previous)\r\n ForceAttribute.blend = undefined\r\n ForceAttribute.depth = undefined\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT\r\n return previousLeaf\r\n\r\n }\r\n\r\n drawEarlyAlpha(state, previous) {\r\n var ForceAttribute = state.getUserData().ForceAttribute\r\n var RenderInfo = state.getUserData().RenderInfo\r\n RenderInfo.currentPass = RenderPassEnum.EARLYZ_TRANSPARENT\r\n ForceAttribute.depth = GLState.DEPTH_LESS_NO_WRITE\r\n ForceAttribute.colorMask = GLState.COLOR_MASK_ALPHA\r\n var previousLeaf = this.drawTransparentBin(state, previous)\r\n ForceAttribute.colorMask = undefined\r\n ForceAttribute.depth = undefined\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT\r\n return previousLeaf\r\n }\r\n\r\n drawImplementationEditor(state, previous) {\r\n let graphicContext = state.getGraphicContext(),\r\n previousLeaf = previous,\r\n camera = this.getCamera(),\r\n hasCameraDepth = !!camera._textureDepth;\r\n\r\n if (hasCameraDepth) {\r\n this.bindDepthRTT(state);\r\n state.clearColor(ClearDepthRGBA);\r\n } else {\r\n this.bindOpaqueRTT(state);\r\n state.clearColor(this._app.clearOpaqueRGBA);\r\n }\r\n state.depthMask(true);\r\n state.clearDepth(this.getClearDepth());\r\n state.clear(\r\n graphicContext.COLOR_BUFFER_BIT | graphicContext.DEPTH_BUFFER_BIT,\r\n );\r\n\r\n if (this.getDoEarlyZ()) {\r\n var stateInsertPosition = getInsertPosition(state, previous);\r\n state.insertStateSet(stateInsertPosition, EarlyZStateSet),\r\n (previousLeaf = this.drawEarlyOpaque(state, previousLeaf));\r\n\r\n const doEarlyTransparent = hasCameraDepth && camera._textureTransparent;\r\n if (doEarlyTransparent) {\r\n previousLeaf = this.drawEarlyAlpha(state, previousLeaf)\r\n }\r\n //E && E(e),\r\n state.removeStateSet(stateInsertPosition),\r\n //doEarlyTransparent && (b.start(\"EarlyTransparencyCustom\"),\r\n //previousLeaf = this.drawEarlyGround(e, previousLeaf),\r\n //b.end(\"EarlyTransparencyCustom\")),\r\n state.applyAttribute(GLState.COLOR_MASK_RGBA);\r\n }\r\n\r\n if (hasCameraDepth) {\r\n this.bindOpaqueRTT(state);\r\n state.clearColor(this._app.clearOpaqueRGBA);\r\n state.clear(graphicContext.COLOR_BUFFER_BIT);\r\n }\r\n\r\n previousLeaf = this.drawOpaqueShading(state, previousLeaf);\r\n state.clearColor(clearTranpanrentRGBA);\r\n\r\n if (camera._textureTransparent) {\r\n this.bindTransparencyRTT(state);\r\n state.clear(graphicContext.COLOR_BUFFER_BIT);\r\n //previousLeaf = this.drawGroundShading(e, previousLeaf),\r\n previousLeaf = this.drawTransparentShading(state, previousLeaf)\r\n }\r\n\r\n //camera._textureRefraction && (this.bindRefractionRTT(e),\r\n //state.clear(graphicContext.COLOR_BUFFER_BIT),\r\n //previousLeaf = this.drawRefractionShading(e, previousLeaf),\r\n\r\n if (camera._textureExtra) {\r\n this.bindExtraRTT(state);\r\n state.clear(graphicContext.COLOR_BUFFER_BIT);\r\n previousLeaf = this.drawExtra(state, previousLeaf);\r\n }\r\n\r\n return previousLeaf;\r\n }\r\n\r\n drawImplementation(state, preLeaf) {\r\n var ForceAttribute = {\r\n depth: undefined,\r\n blend: undefined,\r\n colorMask: undefined,\r\n }\r\n var RenderInfo = {\r\n LAST_LEAF: undefined,\r\n passTypes: RenderPassEnum,\r\n forceAttribute: ForceAttribute,\r\n currentPass: RenderPassEnum.DEFAULT,\r\n }\r\n var stateUserData = state.getUserData()\r\n if(!stateUserData) {\r\n state.setUserData({\r\n uniformCacheByInstanceId: {},\r\n app: this._app,\r\n ForceAttribute: ForceAttribute,\r\n RenderInfo: RenderInfo\r\n })\r\n }\r\n if (!this.isMainCamera()) {\r\n this.isShadowCasterCamera() &&\r\n (RenderInfo.currentPass = RenderPassEnum.SHADOWMAP);\r\n var leaf = osg.RenderStage.prototype.drawImplementation.call(\r\n this,\r\n state,\r\n preLeaf,\r\n );\r\n RenderInfo.currentPass = RenderPassEnum.DEFAULT;\r\n return leaf;\r\n }\r\n var camera = this.getCamera();\r\n if (!camera._textureOpaque) return preLeaf;\r\n camera.fboOpaque ||\r\n (camera.fboOpaque = this.createFBO(state, camera._textureOpaque)),\r\n camera.fboTransparent ||\r\n (camera.fboTransparent = this.createFBO(\r\n state,\r\n camera._textureTransparent,\r\n )),\r\n camera.fboDepth ||\r\n (camera.fboDepth = this.createFBO(state, camera._textureDepth)),\r\n //camera.fboRefraction || (camera.fboRefraction = this.createFBO(state, camera._textureRefraction)),\r\n camera.fboExtra ||\r\n (camera.fboExtra = this.createFBO(state, camera._textureExtra));\r\n const viewport = this.getViewport();\r\n undefined === viewport &&\r\n console.log('RenderStage does not have a valid viewport');\r\n state.applyAttribute(viewport);\r\n this._scissor && state.applyAttribute(this._scissor);\r\n if (0 !== this._positionedAttribute.getLength()) {\r\n this.applyPositionedAttribute(state, this._positionedAttribute);\r\n }\r\n this.sortBinArray();\r\n preLeaf = this.drawImplementationEditor(state, preLeaf);\r\n return preLeaf;\r\n }\r\n\r\n\r\n}\r\n\r\n\r\nexport default RenderStageSplitter;\r\n","const _LINEAR_TO_SRGB = function (linear) {\r\n var srgb = 0;\r\n return (\r\n linear < 0.0031308\r\n ? linear > 0 && (srgb = 12.92 * linear)\r\n : (srgb = 1.055 * Math.pow(linear, 1 / 2.4) - 0.055),\r\n srgb\r\n );\r\n};\r\n\r\nconst _SRGB_TO_LINEAR = function (srgb) {\r\n var linear = 0;\r\n return (\r\n srgb < 0.04045\r\n ? srgb >= 0 && (linear = srgb * (1 / 12.92))\r\n : (linear = Math.pow((srgb + 0.055) * (1 / 1.055), 2.4)),\r\n linear\r\n );\r\n};\r\n\r\nexport default {\r\n linearToSrgb1: _LINEAR_TO_SRGB,\r\n srgbToLinear1: _SRGB_TO_LINEAR,\r\n linearToSrgb: function (linear, srgb) {\r\n var i = srgb || new Array(linear.length);\r\n return (\r\n (i[0] = _LINEAR_TO_SRGB(linear[0])),\r\n (i[1] = _LINEAR_TO_SRGB(linear[1])),\r\n (i[2] = _LINEAR_TO_SRGB(linear[2])),\r\n i.length > 3 && linear.length > 3 && (i[3] = linear[3]),\r\n i\r\n );\r\n },\r\n srgbToLinear: function (srgb, linear) {\r\n var i = linear || new Array(srgb.length);\r\n return (\r\n (i[0] = _SRGB_TO_LINEAR(srgb[0])),\r\n (i[1] = _SRGB_TO_LINEAR(srgb[1])),\r\n (i[2] = _SRGB_TO_LINEAR(srgb[2])),\r\n i.length > 3 && srgb.length > 3 && (i[3] = srgb[3]),\r\n i\r\n );\r\n },\r\n encodeRGBM: function (color, range, rgbm) {\r\n (rgbm[3] = Math.min(\r\n 1,\r\n Math.max(color[0] / range, rgbm[1] / range, rgbm[2] / range, 1e-6),\r\n )),\r\n (rgbm[3] = Math.ceil(255 * rgbm[3]) / 255);\r\n var n = 1 / (range * rgbm[3]);\r\n return (\r\n (rgbm[0] = color[0] * n),\r\n (rgbm[1] = color[1] * n),\r\n (rgbm[2] = color[2] * n),\r\n rgbm\r\n );\r\n },\r\n decodeRGBM: function (rgbm, range, color) {\r\n var n = range * rgbm[3];\r\n return (\r\n (color[0] = n * color[0]),\r\n (color[1] = n * color[1]),\r\n (color[2] = n * color[2]),\r\n color\r\n );\r\n },\r\n rgbToHex: function (rgb) {\r\n var t = Math.round(255 * rgb.r),\r\n i = Math.round(255 * rgb.g);\r\n return (\r\n '#' +\r\n (16777216 | Math.round(255 * rgb.b) | (i << 8) | (t << 16))\r\n .toString(16)\r\n .substr(1)\r\n );\r\n },\r\n};\r\n","import osg from \"../osg/osg\";\r\nimport osgShader from \"../osgShader/osgShader\";\r\nimport osgUtil from \"../osgUtil/osgUtil\";\r\n\r\nimport RenderStageSplitter from './RenderStage.js';\r\nimport PickMask from './PickMask.js';\r\nimport Config from './Config.js';\r\nimport ColorHelper from './ColorHelper.js';\r\nimport CullVisitor from './CullVisitor.js';\r\nimport dummyTexture from './DummyTexture';\r\n\r\n//const dummyTexture = new osg.Texture()\r\n//dummyTexture.setTextureSize(1, 1)\r\n\r\nconst shaderProcessor = osgShader.NextShaderProcessor;\r\n\r\nconst AddGaussianBlurPass = function(\r\n passArray,\r\n inputName,\r\n outputName,\r\n steps,\r\n needAdjustBlurDir,\r\n) {\r\n const divisor = 2;\r\n const blurX = osg.Uniform.createFloat2(osg.vec2.fromValues(0, 1), 'uBlurDir');\r\n const blurY = osg.Uniform.createFloat2(osg.vec2.fromValues(1, 0), 'uBlurDir');\r\n const shaders = {};\r\n const textureName = inputName;\r\n for (let stepidx = 0; stepidx < steps.length; stepidx++) {\r\n const step = steps[stepidx] + 1,\r\n shaderFile = 'gaussianBlur' + stepidx;\r\n if (!shaderProcessor.hasShader(shaderFile)) {\r\n shaders[shaderFile] = Generate(step, needAdjustBlurDir);\r\n }\r\n passArray.push({\r\n func: {\r\n name: 'gaussianBlur',\r\n file: shaderFile,\r\n },\r\n uniforms: blurX,\r\n textures: {\r\n name: textureName,\r\n uniformName: 'TextureBlurInput',\r\n },\r\n out: {\r\n name: 'TextureBlurTemp' + stepidx,\r\n divisor: divisor,\r\n filter: 'linear',\r\n },\r\n }),\r\n (textureName = outputName + (stepidx + 1));\r\n passArray.push({\r\n func: {\r\n name: 'gaussianBlur',\r\n file: shaderFile,\r\n },\r\n uniforms: blurY,\r\n textures: {\r\n name: 'TextureBlurTemp' + stepidx,\r\n uniformName: 'TextureBlurInput',\r\n },\r\n out: {\r\n name: textureName,\r\n divisor: divisor,\r\n filter: 'linear',\r\n },\r\n });\r\n divisor *= 2;\r\n }\r\n shaderProcessor.addShaders(shaders);\r\n};\r\n\r\nexport default class PostProcessNode extends osg.Node {\r\n constructor(postProcessFeature) {\r\n super();\r\n this.setName('PostProcess - node In')\r\n this._view3d = postProcessFeature\r\n this._camera = postProcessFeature._camera\r\n this._effectiveConfig = postProcessFeature._effectiveConfig\r\n this._app = postProcessFeature._app\r\n this._viewerOSGJS = postProcessFeature._viewerOSGJS\r\n this._model = postProcessFeature.getModel()\r\n //this._hasTriangles = this._viewer.getOrCreateScene().getJSON().faceCount > 0,\r\n //JasetHasTriangles(this._hasTriangles),\r\n this._app.getCamera().getRenderer().setRenderStage(new RenderStageSplitter(this._app))\r\n this._app.getEventEmitter().on('pingPongTexture0', this.onPingPongTexture0.bind(this))\r\n var model = this.getBackgroundModel()\r\n model.bind(\"backgroundUpdated\", this.onBackgroundUpdated, this)\r\n model.bind(\"change:color\", this.onBackgroundColor, this)\r\n \r\n this._composer = undefined\r\n }\r\n\r\n getModel() {\r\n return this._model;\r\n }\r\n\r\n getNodeBackground() {\r\n return this._app.getFeatures().environment.getNode().getBackground();\r\n }\r\n getBackgroundModel() {\r\n return this._app.getFeatures().background.getModel();\r\n }\r\n getBackgroundType() {\r\n return this.getBackgroundModel().get('enable');\r\n }\r\n onPingPongTexture0(toggle) {\r\n this._composer && this._composer.swapFeedbackLoopTextures(toggle);\r\n }\r\n _replaceTexture(texture, from, to) {\r\n var statesetPass = this._composer.getStateSetPass(from);\r\n if (statesetPass) {\r\n var textureunit = statesetPass.getUniform(to);\r\n textureunit &&\r\n statesetPass.setTextureAttributeAndModes(\r\n textureunit.getInternalArray()[0],\r\n texture,\r\n );\r\n }\r\n }\r\n onBackgroundUpdated(texture) {\r\n if (this._composer && 'fixed' === this._effectiveConfig.bgType) {\r\n this._replaceTexture(texture, 'composeFixedBackground', 'TextureFixed');\r\n this._replaceTexture(\r\n texture,\r\n 'composeFixedBackgroundRefraction',\r\n 'TextureFixed',\r\n );\r\n }\r\n }\r\n onBackgroundColor() {\r\n let color = this._app.clearOpaqueRGBA;\r\n if ('color' === this.getBackgroundType()) {\r\n osg.vec3.copy(color, this.getBackgroundModel().get('color')),\r\n color[3] = 1;\r\n if (this._app.globalUniform.uOutputLinear.getInternalArray()[0] === 1) {\r\n ColorHelper.srgbToLinear(color, color);\r\n }\r\n let rgbmRange = this._app.globalUniform.uRGBMRange.getInternalArray()[0];\r\n rgbmRange > 0 && ColorHelper.encodeRGBM(color, rgbmRange, color);\r\n } else osg.vec4.set(color, 0, 0, 0, 0);\r\n\r\n this._app._frameManager.draw();\r\n }\r\n _getSupportedLinearFloatTexture() {\r\n const caps = osg.WebGLCaps.instance();\r\n return 0 === Config.floatRtt ?\r\n osg.Texture.UNSIGNED_BYTE :\r\n caps.hasLinearHalfFloatRTT() ?\r\n osg.Texture.HALF_FLOAT :\r\n this._model.get('webVR') && 2 === Config.floatRtt ?\r\n osg.Texture.UNSIGNED_BYTE :\r\n caps.hasLinearFloatRTT() ?\r\n osg.Texture.FLOAT :\r\n osg.Texture.UNSIGNED_BYTE;\r\n }\r\n _getSupportedFloatTexture() {\r\n const caps = osg.WebGLCaps.instance();\r\n const webVR = false;\r\n return 0 === Config.floatRtt ?\r\n osg.Texture.UNSIGNED_BYTE :\r\n caps.hasLinearHalfFloatRTT() || caps.hasHalfFloatRTT() ?\r\n osg.Texture.HALF_FLOAT :\r\n webVR && 2 === Config.floatRtt ?\r\n osg.Texture.UNSIGNED_BYTE :\r\n caps.hasLinearFloatRTT() || caps.hasFloatRTT() ?\r\n osg.Texture.FLOAT :\r\n osg.Texture.UNSIGNED_BYTE;\r\n }\r\n _updateEffectiveConfig() {\r\n this._effectiveConfig.useTransparency = true;\r\n this._effectiveConfig.useExtra = true;\r\n this._effectiveConfig.useDepth = this._needDepthTexture();\r\n this._effectiveConfig.hasBG = this.getBackgroundType() != 'none'\r\n this._effectiveConfig.useFxaa = true;\r\n this._effectiveConfig.useToneMapping = true;\r\n this._effectiveConfig.bgType = this.getBackgroundType()\r\n this._effectiveConfig.useSsao = (this._model.get(\"ssaoEnable\") && this._model.get(\"ssaoIntensity\") >= .01)\r\n // console.warn('bgType force color');\r\n return this._effectiveConfig;\r\n }\r\n _needDepthTexture() {\r\n var effectiveconfig = this._effectiveConfig;\r\n if (\r\n effectiveconfig.useRefraction ||\r\n effectiveconfig.useSsr ||\r\n effectiveconfig.useDof ||\r\n effectiveconfig.useBloom ||\r\n effectiveconfig.useSharpen ||\r\n effectiveconfig.useSsao ||\r\n effectiveconfig.useSss ||\r\n effectiveconfig.useTaa ||\r\n !effectiveconfig.useFxaa\r\n )\r\n return true;\r\n // if (\r\n // this._viewer.getFeatures().hotspot.getModel().get('hotspots').length > 0\r\n // )\r\n // return true;\r\n var type = this.getBackgroundType();\r\n return 'none' === type || 'fixed' === type //|| this._model.get('webVR');\r\n }\r\n _addInternalTextures(composer, effectiveConfig, srgb) {\r\n composer.addInternalTexture({\r\n name: 'TextureOpaque',\r\n immuable: true,\r\n srgb: srgb,\r\n rgbm: !srgb,\r\n });\r\n composer.setInputTexture('TextureOpaque');\r\n\r\n if (effectiveConfig.useRefraction || effectiveConfig.useSsr)\r\n composer.addInternalTexture({\r\n name: 'TextureToBeRefracted',\r\n divisor: Config.refractionRes,\r\n immuable: true,\r\n reusable: false,\r\n srgb: false,\r\n rgbm: true,\r\n });\r\n\r\n if (effectiveConfig.useRefraction)\r\n composer.addInternalTexture({\r\n name: 'TextureRefraction',\r\n immuable: true,\r\n srgb: false,\r\n rgbm: true,\r\n });\r\n\r\n if (effectiveConfig.useSsr || effectiveConfig.useSsao)\r\n composer.addInternalTexture({\r\n name: 'TextureMipmapDepth',\r\n immuable: true,\r\n reusable: false,\r\n srgb: false,\r\n rgbm: false,\r\n });\r\n\r\n if (effectiveConfig.useDepth)\r\n composer.addInternalTexture({\r\n name: 'TextureDepth',\r\n filter: 'nearest',\r\n immuable: true,\r\n srgb: false,\r\n rgbm: false,\r\n });\r\n\r\n if (effectiveConfig.useTransparency)\r\n composer.addInternalTexture({\r\n name: 'TextureTransparent',\r\n filter: 'nearest',\r\n immuable: true,\r\n type: this._getSupportedFloatTexture(),\r\n rgbm: false,\r\n srgb: false,\r\n });\r\n\r\n if (effectiveConfig.useExtra)\r\n composer.addInternalTexture({\r\n name: 'TextureExtra',\r\n filter: 'nearest',\r\n immuable: true,\r\n srgb: !effectiveConfig.webVR,\r\n rgbm: false,\r\n });\r\n }\r\n\r\n _addSss(passArray, composer) {\r\n var supportLinearFloat = this._getSupportedLinearFloatTexture();\r\n composer.addExternalTexture('TextureSSSKernel', this._view3d._sssTexKernel);\r\n passArray.push({\r\n func: 'sssExtract',\r\n textures: [{\r\n name: '%last',\r\n uniformName: 'TextureSSSColor',\r\n },\r\n 'TextureDepth',\r\n ],\r\n out: {\r\n name: 'TextureSSSExtract',\r\n rgbm: false,\r\n divisor: 2,\r\n type: supportLinearFloat,\r\n filter: 'linear',\r\n },\r\n });\r\n var defines = [];\r\n defines.push('#define SSS_HALF_KERNEL_SIZE ' + Config.sssHalfKernel);\r\n defines.push(\r\n '#define SSS_PROFILE_COUNT ' + this._model.get('sssProfiles').length,\r\n );\r\n defines.push('#define SSS_JITTER ' + Config.sssJitter.toExponential());\r\n var sssByteRange = this._model.useSSSLookupFloat() ?\r\n '1.0' :\r\n this._model.getSSSWeightRange().toExponential();\r\n defines.push('#define SSS_BYTE_RANGE ' + sssByteRange);\r\n var blurdirUniform = osg.Uniform.createFloat2(\r\n osg.vec2.fromValues(0, 1),\r\n 'uBlurDir',\r\n );\r\n passArray.push({\r\n func: 'sssBlur',\r\n header: defines,\r\n textures: [{\r\n name: 'TextureSSSExtract',\r\n uniformName: 'TextureSSSBlur',\r\n },\r\n 'TextureDepth',\r\n 'TextureSSSKernel',\r\n ],\r\n uniforms: blurdirUniform,\r\n out: {\r\n name: 'TextureSSSBlur1',\r\n divisor: 2,\r\n type: supportLinearFloat,\r\n rgbm: false,\r\n filter: 'linear',\r\n },\r\n });\r\n var blurDir = osg.Uniform.createFloat2(\r\n osg.vec2.fromValues(1, 0),\r\n 'uBlurDir',\r\n );\r\n passArray.push({\r\n func: 'sssBlur',\r\n header: defines,\r\n textures: [{\r\n name: 'TextureSSSBlur1',\r\n uniformName: 'TextureSSSBlur',\r\n },\r\n 'TextureDepth',\r\n 'TextureSSSKernel',\r\n ],\r\n uniforms: blurDir,\r\n out: {\r\n name: 'TextureSSSBlur2',\r\n divisor: 2,\r\n rgbm: true,\r\n filter: 'linear',\r\n },\r\n });\r\n passArray.push({\r\n func: 'sssCombine',\r\n textures: [{\r\n name: 'TextureSSSBlur2',\r\n uniformName: 'TextureSSSBlur',\r\n },\r\n {\r\n name: '%last',\r\n uniformName: 'TextureSSSColor',\r\n },\r\n 'TextureDepth',\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n _packMipmapDepth(passArray) {\r\n let firstDepthUniform0 = osg.Uniform.createInt(1, 'uFirstDepth');\r\n let firstDepthUniform1 = osg.Uniform.createInt(0, 'uFirstDepth');\r\n for (let mipIdx = 1; mipIdx <= 5; mipIdx++) {\r\n let curMipIdx = 1 << (mipIdx + 1),\r\n inputTextureDepth =\r\n 1 === mipIdx ? 'TextureDepth' : 'TextureDepth' + (mipIdx - 1),\r\n outputTextureDepth = 'TextureDepth' + mipIdx;\r\n passArray.push({\r\n func: 'depthMipmap',\r\n textures: [{\r\n name: inputTextureDepth,\r\n uniformName: 'TextureDepth',\r\n }, ],\r\n uniforms: 1 === mipIdx ? firstDepthUniform0 : firstDepthUniform1,\r\n out: {\r\n name: outputTextureDepth,\r\n divisor: curMipIdx,\r\n filter: 'linear',\r\n },\r\n });\r\n }\r\n passArray.push({\r\n func: 'packMipmapDepth',\r\n textures: [{\r\n name: 'TextureDepth',\r\n uniformName: 'TextureDepth0',\r\n },\r\n 'TextureDepth1',\r\n 'TextureDepth2',\r\n 'TextureDepth3',\r\n 'TextureDepth4',\r\n 'TextureDepth5',\r\n ],\r\n out: {\r\n name: 'TextureMipmapDepth',\r\n filter: 'linear',\r\n },\r\n });\r\n }\r\n _addSsao(passArray) {\r\n var glslExtension = [\r\n ['#extension GL_OES_standard_derivatives : enable']\r\n ];\r\n Config.ssaoNormal && glslExtension.push('#define SSAO_NORMAL'),\r\n glslExtension.push('#define MOBILE');\r\n\r\n passArray.push({\r\n func: 'ssaoExtract',\r\n header: glslExtension,\r\n textures: 'TextureMipmapDepth',\r\n out: {\r\n name: 'TextureSsaoExtract',\r\n filter: 'linear',\r\n },\r\n });\r\n passArray.push({\r\n func: {\r\n name: 'ssaoBlurH',\r\n file: 'ssaoBlur.glsl',\r\n },\r\n header: '#define SSAO_BLUR_H',\r\n textures: {\r\n name: 'TextureSsaoExtract',\r\n uniformName: 'TextureBlurInput',\r\n },\r\n out: {\r\n name: 'TextureSsaoBlurH',\r\n filter: 'nearest',\r\n },\r\n });\r\n passArray.push({\r\n func: {\r\n name: 'ssaoBlurV',\r\n file: 'ssaoBlur.glsl',\r\n },\r\n header: '#define SSAO_BLUR_V',\r\n textures: [{\r\n name: '%last',\r\n filter: 'linear',\r\n },\r\n {\r\n name: 'TextureSsaoBlurH',\r\n uniformName: 'TextureBlurInput',\r\n },\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n _addCombineOpacity(passArray) {\r\n passArray.push({\r\n func: 'combineOpacity',\r\n textures: [{\r\n name: '%last',\r\n filter: 'nearest',\r\n },\r\n 'TextureTransparent',\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n _packMipmapColor(passArray, effectiveConfig, composer) {\r\n var inputName = this._addFixedBackgroundRefraction(\r\n passArray,\r\n effectiveConfig,\r\n composer,\r\n );\r\n AddGaussianBlurPass(\r\n passArray,\r\n inputName,\r\n 'TextureRefractionBlur', [3, 5, 7, 9, 11, 13, 15],\r\n true,\r\n );\r\n passArray.push({\r\n func: 'packMipmapRefraction',\r\n textures: [{\r\n name: inputName,\r\n uniformName: 'TextureRefractionBlur0',\r\n },\r\n 'TextureRefractionBlur1',\r\n 'TextureRefractionBlur2',\r\n 'TextureRefractionBlur3',\r\n 'TextureRefractionBlur4',\r\n 'TextureRefractionBlur5',\r\n 'TextureRefractionBlur6',\r\n 'TextureRefractionBlur7',\r\n ],\r\n out: {\r\n name: 'TextureToBeRefracted',\r\n filter: 'linear',\r\n },\r\n });\r\n return passArray.length;\r\n }\r\n _addRefraction(passArray) {\r\n passArray.push({\r\n func: 'combineRefraction',\r\n textures: ['%last', 'TextureRefraction'],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n _addDof(passArray) {\r\n const dofRes = Config.dofRes;\r\n passArray.push({\r\n func: 'dofCoC',\r\n textures: 'TextureDepth',\r\n out: {\r\n name: 'TextureDofCoC',\r\n divisor: dofRes,\r\n filter: 'nearest',\r\n },\r\n });\r\n passArray.push({\r\n func: {\r\n name: 'dofNearDilateH',\r\n file: 'dofNearDilate.glsl',\r\n },\r\n textures: ['TextureDofCoC', 'TextureDepth'],\r\n out: {\r\n name: 'TextureDofNearDilateH',\r\n divisor: dofRes,\r\n filter: 'linear',\r\n },\r\n });\r\n passArray.push({\r\n func: {\r\n name: 'dofNearDilateV',\r\n file: 'dofNearDilate.glsl',\r\n },\r\n textures: [{\r\n name: 'TextureDofNearDilateH',\r\n uniformName: 'TextureDofCoC',\r\n },\r\n 'TextureDepth',\r\n ],\r\n out: {\r\n name: 'TextureDofNearDilateV',\r\n divisor: dofRes,\r\n filter: 'nearest',\r\n },\r\n });\r\n let supportFloatTexture =\r\n this._getSupportedFloatTexture() === osg.Texture.HALF_FLOAT;\r\n let define = supportFloatTexture ? '#define COLOR_WITH_COC' : '';\r\n let textures = ['%last'];\r\n\r\n supportFloatTexture &&\r\n textures.push({\r\n name: 'TextureDofNearDilateV',\r\n uniformName: 'TextureDofCoC',\r\n });\r\n\r\n passArray.push({\r\n func: 'dofDownsampleColor',\r\n header: define,\r\n textures: textures,\r\n out: {\r\n name: 'TextureDofDownsampleColor',\r\n divisor: dofRes,\r\n filter: 'nearest',\r\n type: supportFloatTexture ?\r\n osg.Texture.HALF_FLOAT : osg.Texture.UNSIGNED_BYTE,\r\n },\r\n });\r\n\r\n textures = [{\r\n name: 'TextureDofDownsampleColor',\r\n uniformName: 'TextureDofColor',\r\n rgbm: !supportFloatTexture,\r\n }, ];\r\n\r\n supportFloatTexture ||\r\n a.push({\r\n name: 'TextureDofNearDilateV',\r\n uniformName: 'TextureDofCoC',\r\n });\r\n\r\n passArray.push({\r\n func: 'dofBlurCircular',\r\n header: define,\r\n textures: textures,\r\n out: {\r\n name: 'TextureDofBlurCircular',\r\n divisor: dofRes,\r\n filter: 'linear',\r\n rgbm: true,\r\n },\r\n });\r\n\r\n passArray.push({\r\n func: 'dofCombine',\r\n textures: [{\r\n name: '%last',\r\n filter: 'linear',\r\n },\r\n 'TextureDofBlurCircular',\r\n 'TextureDofNearDilateV',\r\n 'TextureDepth',\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n _addBloom(passes, effectiveConfig) {\r\n let defines,\r\n textures = ['%last'];\r\n if (effectiveConfig.hasBG) {\r\n (defines = '#define HAS_BACKGROUND'), textures.push('TextureDepth');\r\n }\r\n\r\n passes.push({\r\n func: 'bloomExtract',\r\n textures: textures,\r\n header: defines,\r\n out: {\r\n name: 'TextureBloomExtract',\r\n filter: 'linear',\r\n },\r\n });\r\n AddGaussianBlurPass(passes, 'TextureBloomExtract', 'TextureBloomBlur', [\r\n 3,\r\n 5,\r\n 7,\r\n 9,\r\n 11,\r\n ]);\r\n passes.push({\r\n func: 'bloomCombine',\r\n textures: [{\r\n name: '%last',\r\n },\r\n 'TextureBloomBlur1',\r\n 'TextureBloomBlur2',\r\n 'TextureBloomBlur3',\r\n 'TextureBloomBlur4',\r\n 'TextureBloomBlur5',\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n\r\n _addMergeable(passes, effectiveConfig) {\r\n if (effectiveConfig.useChromaticAberration)\r\n passes.push({\r\n func: 'chromaticAberration',\r\n textures: [{\r\n name: '%last',\r\n filter: 'nearest',\r\n }, ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n if (effectiveConfig.useColorBalance)\r\n passes.push({\r\n func: 'colorBalance',\r\n textures: [{\r\n name: '%last',\r\n filter: 'nearest',\r\n }, ],\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n\r\n if (effectiveConfig.useToneMapping) {\r\n let textures = [{\r\n name: '%last',\r\n filter: 'nearest',\r\n }, ],\r\n defines = '';\r\n\r\n if (\r\n 'fixed' === effectiveConfig.bgType &&\r\n !effectiveConfig.useRefraction &&\r\n !effectiveConfig.useSsr\r\n ) {\r\n (defines = '#define HAS_FIXED_BACKGROUND'),\r\n textures.push('TextureDepth');\r\n }\r\n\r\n passes.push({\r\n func: 'toneMapping',\r\n header: defines,\r\n textures: textures,\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (effectiveConfig.webVR && effectiveConfig.useExtra) {\r\n passes.push({\r\n func: 'veilVr',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n filter: 'nearest',\r\n },\r\n collapsible: true,\r\n });\r\n passes.push({\r\n func: 'composeExtra',\r\n header: '#define LINEAR_EXTRA',\r\n textures: ['%last', 'TextureExtra'],\r\n out: {\r\n name: '%next',\r\n filter: 'nearest',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n }\r\n\r\n _addSuperSample(passes, effects) {\r\n if (!effects.hasBG) {\r\n var textures = ['%last', 'TextureDepth'];\r\n if (effects.useRefraction) textures.push('TextureRefraction');\r\n passes.push({\r\n func: 'setDepthAlpha',\r\n header: effects.useRefraction ?\r\n '#define REFRACTION_FORCE_ALPHA_ONE' : '',\r\n textures: textures,\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n if (effects.AR) return;\r\n }\r\n if (effects.useTaa) {\r\n let defines = [];\r\n effects.useTaaTransparent && defines.push('#define TAA_TRANSPARENT');\r\n defines.push('#define FEEDBACK_MIN ' + Config.taaFeedbackMin);\r\n defines.push('#define FEEDBACK_MAX ' + Config.taaFeedbackMax);\r\n CullVisitor.vrConfig.doVR && defines.push('#define VR_ENABLED');\r\n passes.push({\r\n func: 'supersampleTaa',\r\n textures: [{\r\n name: '%last',\r\n filter: 'linear',\r\n rgbm: false,\r\n srgb: true,\r\n },\r\n '%previous',\r\n 'TextureDepth',\r\n ],\r\n header: defines,\r\n out: {\r\n name: '%next',\r\n filter: 'linear',\r\n },\r\n });\r\n } else\r\n passes.push({\r\n func: 'supersample',\r\n textures: [{\r\n name: '%last',\r\n filter: 'linear',\r\n rgbm: false,\r\n srgb: true,\r\n },\r\n '%previous',\r\n ],\r\n out: {\r\n name: '%next',\r\n filter: 'linear',\r\n },\r\n });\r\n }\r\n _addFinalPass(passes, effect) {\r\n let defines = [],\r\n textures = [{\r\n name: '%last',\r\n filter: 'linear',\r\n srgb: true,\r\n rgbm: false,\r\n }, ];\r\n if (effect.useDistortionVR) defines.push('#define VR_DISTORTION');\r\n\r\n //postProcessAscii && i.push(\"#define ASCII_FOOL\"),\r\n\r\n if (effect.useFxaa) {\r\n passes.push({\r\n func: 'fxaa',\r\n header: defines,\r\n textures: textures,\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n } else {\r\n passes.push({\r\n func: 'passThrough',\r\n header: defines,\r\n textures: textures,\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n\r\n if (effect.useSharpen) {\r\n let defines = [];\r\n let textures = ['%last'];\r\n effect.hasBG &&\r\n (defines.push('#define HAS_BACKGROUND'), textures.push('TextureDepth'));\r\n passes.push({\r\n func: 'sharpen',\r\n header: defines,\r\n textures: textures,\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (effect.useVignette) {\r\n passes.push({\r\n func: 'vignette',\r\n textures: [{\r\n name: '%last',\r\n filter: 'nearest',\r\n }, ],\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (effect.useGrain) {\r\n passes.push({\r\n func: 'grain',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (effect.useDof) {\r\n passes.push({\r\n func: 'dofCross',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (effect.webVR) {\r\n passes.push({\r\n func: 'fadeVr',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n } else {\r\n effect.useExtra &&\r\n passes.push({\r\n func: 'composeExtra',\r\n textures: ['%last', 'TextureExtra'],\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n\r\n if (!effect.hasBG) {\r\n passes.push({\r\n func: 'finalPremultAlpha',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n }\r\n _addFixedBackground(passes, effects, composer) {\r\n if ('fixed' === effects.bgType) {\r\n var backgroundTexture =\r\n this.getNodeBackground().getBackground() || dummyTexture;\r\n backgroundTexture.divisor = -1;\r\n composer.addExternalTexture('TextureFixed', backgroundTexture);\r\n\r\n let textures = ['%last', 'TextureFixed', 'TextureDepth'],\r\n defines = [];\r\n\r\n if (effects.useRefraction) {\r\n textures.push('TextureRefraction');\r\n defines.push('#define REFRACTION_COMPOSITING_EXCLUSION');\r\n }\r\n\r\n passes.push({\r\n func: 'composeFixedBackground',\r\n header: defines,\r\n textures: textures,\r\n uniforms: [this._app.backgroundUniform.scale],\r\n out: {\r\n name: '%next',\r\n },\r\n collapsible: true,\r\n });\r\n }\r\n }\r\n _addFixedBackgroundRefraction(passArray, effectiveConfig, composer) {\r\n if (!effectiveConfig.useRefraction || 'fixed' !== effectiveConfig.bgType)\r\n return '%last';\r\n var backgroundTexture =\r\n this.getNodeBackground().getBackground() || dummyTexture;\r\n backgroundTexture.divisor = -1;\r\n composer.addExternalTexture('TextureFixed', backgroundTexture);\r\n passArray.push({\r\n func: {\r\n name: 'composeFixedBackgroundRefraction',\r\n file: 'composeFixedBackground.glsl',\r\n },\r\n textures: ['%last', 'TextureFixed', 'TextureDepth'],\r\n uniforms: [this._app.backgroundUniform.scale],\r\n out: {\r\n name: 'TextureWithBackground',\r\n },\r\n });\r\n return 'TextureWithBackground';\r\n }\r\n _addPassThrough(passes) {\r\n passes.push({\r\n func: 'passThrough',\r\n textures: '%last',\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n }\r\n _createComposer() {\r\n let effects = this._updateEffectiveConfig();\r\n let composer = this._composer || new osgUtil.ComposerPostProcess();\r\n if (this._composer === undefined) this._initComposer(composer);\r\n composer.clear();\r\n let passArray = [];\r\n let needsPackDepthMipmap =\r\n (effects.useSsr && Config.depthMipmap) || effects.useSsao;\r\n let needsPackColorMipmap = effects.useSsr || effects.useRefraction;\r\n let mipmapPassCount = 0;\r\n\r\n if (needsPackDepthMipmap) this._packMipmapDepth(passArray);\r\n if (effects.useSsao) this._addSsao(passArray);\r\n if (effects.useSss) this._addSss(passArray, composer);\r\n if (effects.useTransparency) this._addCombineOpacity(passArray);\r\n if (needsPackColorMipmap) {\r\n mipmapPassCount = this._packMipmapColor(passArray, effects, composer);\r\n }\r\n if (effects.useRefraction)\r\n this._addRefraction(passArray, effects, composer);\r\n\r\n if (effects.useDof) this._addDof(passArray);\r\n\r\n if (effects.useBloom) this._addBloom(passArray, effects);\r\n \r\n this._addMergeable(passArray, effects),\r\n this._addFixedBackground(passArray, effects, composer),\r\n mipmapPassCount > 0 &&\r\n passArray.length === mipmapPassCount &&\r\n this._addPassThrough(passArray);\r\n\r\n var hasNoPass = 0 === passArray.length;\r\n\r\n this._addSuperSample(passArray, effects),\r\n this._addFinalPass(passArray, effects),\r\n this._addInternalTextures(composer, effects, hasNoPass),\r\n composer.build(passArray),\r\n this._assignInternalTextureToCamera(),\r\n this._app.globalUniform.uOutputLinear.setInt(hasNoPass ? 0 : 1),\r\n this._app.globalUniform.uRGBMRange.setFloat(hasNoPass ? -1 : 7); // this._model.get(\"rgbmDefault\")),\r\n this.onBackgroundColor();\r\n\r\n if (effects.useRefraction || effects.useSsr) {\r\n let stateset = this.getOrCreateStateSet();\r\n let refractedTex = composer.getInternalTexture('TextureToBeRefracted');\r\n stateset.setTextureAttributeAndModes(5, refractedTex);\r\n stateset.addUniform(osg.Uniform.createInt(5, 'uTextureToBeRefracted'));\r\n refractedTex = Config.depthMipmap ?\r\n composer.getInternalTexture('TextureMipmapDepth') :\r\n composer.getInternalTexture('TextureDepth');\r\n stateset.setTextureAttributeAndModes(4, refractedTex);\r\n stateset.addUniform(osg.Uniform.createInt(4, 'uTextureMipmapDepth'));\r\n }\r\n }\r\n _assignInternalTextureToCamera() {\r\n let composer = this._composer,\r\n effects = this._effectiveConfig,\r\n camera = this._camera;\r\n camera._textureOpaque = composer.getInternalTexture('TextureOpaque');\r\n effects.useDepth &&\r\n (camera._textureDepth = composer.getInternalTexture('TextureDepth'));\r\n effects.useTransparency &&\r\n (camera._textureTransparent = composer.getInternalTexture(\r\n 'TextureTransparent',\r\n ));\r\n effects.useRefraction &&\r\n (camera._textureRefraction = composer.getInternalTexture(\r\n 'TextureRefraction',\r\n ));\r\n effects.useExtra &&\r\n (camera._textureExtra = composer.getInternalTexture('TextureExtra'));\r\n }\r\n _resizeMipmapHeight(composer, textureName, passName) {\r\n var texture = composer.getInternalTexture(textureName);\r\n if (texture) {\r\n var width = composer._screenWidth,\r\n height = composer._screenHeight,\r\n texWidth = composer._getTextureSize(width, texture.divisor),\r\n texHeight = composer._getTextureSize(height, 0.5 * texture.divisor);\r\n texture.setTextureSize(texWidth, texHeight);\r\n var pass = composer.getStateSetPass(passName);\r\n if (pass) {\r\n pass.getUniform('uTextureOutputSize').getInternalArray()[1] = texHeight;\r\n for (\r\n var cameras = composer.getCameras(), index = 0; index < cameras.length;\r\n ++index\r\n ) {\r\n var camera = cameras[index];\r\n if (camera.getName() === textureName)\r\n return void camera\r\n .getViewport()\r\n .setViewport(0, 0, texWidth, texHeight);\r\n }\r\n }\r\n }\r\n }\r\n _hookComposerResize(composer) {\r\n var scope = this,\r\n composerPrototype = osgUtil.ComposerPostProcess.prototype;\r\n composer.resizeRatio = function(xViewport, yViewport, xTexture, yTexture) {\r\n composerPrototype.resizeRatio.call(\r\n composer,\r\n xViewport,\r\n yViewport,\r\n xTexture,\r\n yTexture,\r\n );\r\n scope._resizeMipmapHeight(\r\n composer,\r\n 'TextureToBeRefracted',\r\n 'packMipmapRefraction',\r\n ),\r\n scope._resizeMipmapHeight(\r\n composer,\r\n 'TextureMipmapDepth',\r\n 'packMipmapDepth',\r\n );\r\n };\r\n }\r\n _initComposer(composer) {\r\n composer.setScreenSize(\r\n this._viewerOSGJS.getCanvasWidth(),\r\n this._viewerOSGJS.getCanvasHeight(),\r\n );\r\n composer.setMethodWrapUV(1, 1);\r\n this._hookComposerResize(composer);\r\n this._app\r\n .getEventEmitter()\r\n .on('resizeCanvas', composer.resize.bind(composer));\r\n this._app\r\n .getEventEmitter()\r\n .on('resizeRatio', composer.resizeRatio.bind(composer));\r\n composer.setNodeMask(PickMask.NO_PICK_NO_SHADOW);\r\n composer.setName('PostProcess - Composer');\r\n this.addChild(composer);\r\n this._composer = composer;\r\n var statset = composer.getOrCreateStateSet();\r\n for (var key in this._app.postProcessUniform)\r\n statset.addUniform(this._app.postProcessUniform[key]);\r\n }\r\n resetCameraAttachments() {\r\n var camera = this._camera;\r\n camera.resetAttachments();\r\n if (camera.fboOpaque) {\r\n camera.fboOpaque.reset();\r\n camera.fboOpaque = undefined;\r\n }\r\n if (camera.fboTransparent) {\r\n camera.fboTransparent.reset();\r\n camera.fboTransparent = undefined;\r\n }\r\n if (camera.fboRefraction) {\r\n camera.fboRefraction.reset();\r\n camera.fboRefraction = undefined;\r\n }\r\n if (camera.fboDepth) {\r\n camera.fboDepth.reset();\r\n camera.fboDepth = undefined;\r\n }\r\n if (camera.fboExtra) {\r\n camera.fboExtra.reset(), (camera.fboExtra = undefined);\r\n }\r\n camera.attachRenderBuffer(\r\n osg.FrameBufferObject.DEPTH_ATTACHMENT,\r\n osg.FrameBufferObject.DEPTH_COMPONENT16,\r\n );\r\n }\r\n createPathStandard() {\r\n this._createComposer();\r\n this.resetCameraAttachments();\r\n }\r\n}","import osg from \"../../osg/osg\";\r\nimport osgUtil from \"../../osgUtil/osgUtil\";\r\n\r\nimport CullVisitor from '../CullVisitor';\r\n// import EventEmitter3 from 'EventEmitter3';\r\nimport PostProcessNode from '../PostProcessNode';\r\nimport Config from '../Config';\r\nimport {Model} from 'backbone'\r\n\r\n\r\nclass PostProcessCallback {\r\n constructor(feature) {\r\n this.RESIZE_OBSERVABLE = null\r\n this.CLIENT_WIDTH\r\n this.CLIENT_HEIGHT\r\n this._dirty = true\r\n this._postProcessFeature = feature\r\n this._effectiveConfig = feature._effectiveConfig;\r\n this._app = feature._app;\r\n this._viewerOSGJS = feature._viewerOSGJS;\r\n // this._model = viewerApp.getModel();\r\n let dofTransition = true; // dofTransition;\r\n this._interpolatorDofFocusPoint = new osgUtil.DelayInterpolator(\r\n 3,\r\n dofTransition ? 0.15 : 1,\r\n );\r\n this._interpolatorDofBlurNear = new osgUtil.DelayInterpolator(\r\n 1,\r\n dofTransition ? 0.15 : 1,\r\n );\r\n this._interpolatorDofBlurFar = new osgUtil.DelayInterpolator(\r\n 1,\r\n dofTransition ? 0.15 : 1,\r\n );\r\n this._interpolatorDofCross = new osgUtil.DelayInterpolator(\r\n 1,\r\n dofTransition ? 0.08 : 1,\r\n );\r\n this._interpolatorDofCross._epsilon = -0.01;\r\n this._dofInitialized = false;\r\n this._dofAutoFocus = false;\r\n this._currentEye = osg.vec3.create();\r\n this._lastEye = osg.vec3.create();\r\n this._currentRot = osg.quat.create();\r\n this._lastRot = osg.quat.create();\r\n this._dofLastPos = osg.vec3.create();\r\n this._dofLastFocal = 0;\r\n this._firstFrame = true;\r\n this._cullConfig = CullVisitor.vrConfig;\r\n this._skipTaaFrames = 0;\r\n this._lastUpdateTime = this._viewerOSGJS\r\n .getFrameStamp()\r\n .getSimulationTime();\r\n this._width = -1;\r\n this._height = -1;\r\n let dirtyBound = this.dirty.bind(this);\r\n this.canvasRatioModel = new Model({viewerToCanvasRatio:1})\r\n /*\r\n model.bind(\"change:hasTransparency\", i),\r\n model.bind(\"change:hasExtra\", i),\r\n model.on(\"change:hasScattering\", i),\r\n model.on(\"change:hasRefraction\", i),\r\n materialManager.then(function () {\r\n this.getBackgroundModel().bind(\"change:enable\", i)\r\n }.bind(this)),\r\n */\r\n this.getBackgroundModel().bind(\"change\", this.dirty.bind(this))\r\n this._hookViewerCheckNeedToDoFrame();\r\n this._hookViewerFrame();\r\n this._hookViewerComputeCanvasSize()\r\n this._app.getEventEmitter().on('resetTaa', this.onResetTaa.bind(this));\r\n Config.dofCircle || (this.showDofCross = function() {});\r\n }\r\n dirty() {\r\n this._dirty = true;\r\n //bh = true\r\n }\r\n onResetTaa() {\r\n this._skipTaaFrames = 2;\r\n }\r\n getMainCamera() {\r\n return this._postProcessFeature._camera;\r\n }\r\n getNodeIn() {\r\n return this._postProcessFeature._nodeIn;\r\n }\r\n getCurrentComposer() {\r\n return this._postProcessFeature._nodeIn._composer;\r\n }\r\n getBackgroundModel() {\r\n return this._app.getFeatures().background.getModel();\r\n }\r\n updateTargetDofBlurNear() {\r\n this._interpolatorDofBlurNear.setTarget(this._model.get('dofBlurNear'));\r\n }\r\n updateTargetDofBlurFar() {\r\n this._interpolatorDofBlurFar.setTarget(this._model.get('dofBlurFar'));\r\n }\r\n getClampedProjectionMatrix() {\r\n let cam = this.getMainCamera();\r\n return cam.clampedProjectionMatrix || cam.getProjectionMatrix();\r\n }\r\n onEffectChanged() {\r\n this._app._frameManager.draw();\r\n return this.getNodeIn().createPathStandard();\r\n }\r\n _toggleComposerCameras(flag) {\r\n this._app.getSuperSample().setSwitch(flag);\r\n let mask = flag ? -1 : 0;\r\n this.getMainCamera().setNodeMask(mask);\r\n let composer = this.getCurrentComposer(),\r\n cameras = composer ? composer.getCameras() : undefined;\r\n if (undefined !== cameras) {\r\n for (let index = 0; index < cameras.length - 1; index++)\r\n cameras[index].setNodeMask(mask);\r\n }\r\n }\r\n _hookViewerCheckNeedToDoFrame() {\r\n let viewerOSG = this._viewerOSGJS;\r\n let viewerOSGCheckNeedToDoFrameBound = viewerOSG.checkNeedToDoFrame.bind(\r\n viewerOSG,\r\n );\r\n let scope = this;\r\n viewerOSG.checkNeedToDoFrame = function() {\r\n this._requestContinousUpdate && scope._app._frameManager.draw();\r\n let viewerNeedDoFrame = viewerOSGCheckNeedToDoFrameBound();\r\n if (viewerNeedDoFrame) return true;\r\n // if (finalPassNeedsUpdate) {\r\n // scope._toggleComposerCameras(false);\r\n // return true;\r\n // } else {\r\n scope._toggleComposerCameras(true);\r\n return false;\r\n // }\r\n };\r\n }\r\n _hookViewerFrame() {\r\n let mainCamera = this.getMainCamera(),\r\n viewer = this._viewerOSGJS,\r\n supersample = this._app.getSuperSample(),\r\n vrMirror = Config.vrMirror,\r\n scope = this,\r\n frameBound = viewer.frame.bind(viewer);\r\n viewer.frame = function (t, o) {\r\n frameBound(t, o);\r\n scope._app._frameManager.setShadowForcedUpdate(false);\r\n mainCamera.setNodeMask(-1);\r\n if (scope._hmd && scope._hmd.isPresenting && vrMirror) {\r\n supersample.setSwitch(false);\r\n mainCamera.setNodeMask(0);\r\n scope.getCamera().getRenderer().draw();\r\n }\r\n };\r\n }\r\n _hookViewerComputeCanvasSize() {\r\n this._resizeCanvasTimeout = -1;\r\n this._doResizeCanvas = false;\r\n this._overrideCanvasWidth = -1;\r\n this._overrideCanvasHeight = -1;\r\n this._app\r\n .getEventEmitter()\r\n .on('resizeViewer', this._onResizeCanvas.bind(this));\r\n this._app\r\n .getEventEmitter()\r\n .on('resizeViewerOnNextFrame', this._onForceResizeCanvas.bind(this));\r\n this._cbEnableResizeCanvas = this._enableResizeCanvas.bind(this);\r\n let viewerOSGJS = this._viewerOSGJS,\r\n canvas = this._app.getCanvas();\r\n this._originalCanvasResize = viewerOSGJS.computeCanvasSize.bind(\r\n viewerOSGJS,\r\n canvas,\r\n );\r\n viewerOSGJS.computeCanvasSize = this._computeCanvasSize.bind(\r\n viewerOSGJS,\r\n canvas,\r\n this,\r\n );\r\n }\r\n _onResizeCanvas(width, height) {\r\n this._overrideCanvasWidth = width;\r\n this._overrideCanvasHeight = height;\r\n this._app._frameManager.draw();\r\n }\r\n _onForceResizeCanvas(width, height) {\r\n this._enableResizeCanvas();\r\n this._onResizeCanvas(width, height);\r\n }\r\n _enableResizeCanvas() {\r\n this._doResizeCanvas = true;\r\n }\r\n _resetResizeCanvas() {\r\n this._doResizeCanvas = false\r\n window.clearTimeout(this._resizeCanvasTimeout);\r\n }\r\n _computeCanvasSize(canvas, postProcessFeatureCallback) {\r\n let overrideW = postProcessFeatureCallback._overrideCanvasWidth,\r\n overrideH = postProcessFeatureCallback._overrideCanvasHeight;\r\n if (overrideW > 0) {\r\n let flag = false;\r\n if (this._canvasWidth !== overrideW) {\r\n (canvas.width = overrideW),\r\n (this._canvasWidth = overrideW),\r\n (flag = true);\r\n }\r\n if (this._canvasHeight !== overrideH) {\r\n (canvas.height = overrideH),\r\n (this._canvasHeight = overrideH),\r\n (flag = true);\r\n }\r\n return flag;\r\n }\r\n\r\n if(postProcessFeatureCallback._doResizeCanvas) {\r\n postProcessFeatureCallback._postProcessFeature.canvasRatioModel.set('viewerToCanvasRatio', 1)\r\n postProcessFeatureCallback._resetResizeCanvas();\r\n return postProcessFeatureCallback._originalCanvasResize();\r\n }\r\n let supportOffscreen = typeof OffscreenCanvas !== 'undefined'\r\n\r\n if (supportOffscreen && canvas instanceof OffscreenCanvas) {\r\n this.CLIENT_WIDTH = canvas.width;\r\n this.CLIENT_HEIGHT = canvas.height;\r\n } else if (window.ResizeObserver) {\r\n \r\n if (!this.RESIZE_OBSERVABLE) {\r\n this.RESIZE_OBSERVABLE = new window.ResizeObserver(() => {\r\n this.CLIENT_WIDTH = canvas.clientWidth\r\n this.CLIENT_HEIGHT = canvas.clientHeight\r\n })\r\n this.RESIZE_OBSERVABLE.observe(canvas)\r\n this.CLIENT_WIDTH = canvas.clientWidth\r\n this.CLIENT_HEIGHT = canvas.clientHeight\r\n }\r\n } else {\r\n this.CLIENT_WIDTH = canvas.clientWidth;\r\n this.CLIENT_HEIGHT = canvas.clientHeight;\r\n }\r\n var canvasRatio =\r\n Math.max(1, Math.floor(this.CLIENT_WIDTH * this._devicePixelRatio)) /\r\n Math.max(1, Math.floor(this.CLIENT_HEIGHT * this._devicePixelRatio)) /\r\n (this._canvasWidth / this._canvasHeight);\r\n\r\n if (canvasRatio === postProcessFeatureCallback._postProcessFeature.canvasRatioModel.get(\"viewerToCanvasRatio\"))\r\n {\r\n return false;\r\n }\r\n postProcessFeatureCallback._postProcessFeature.canvasRatioModel.set(\"viewerToCanvasRatio\", canvasRatio),\r\n postProcessFeatureCallback._resetResizeCanvas();\r\n postProcessFeatureCallback._resizeCanvasTimeout = window.setTimeout(\r\n postProcessFeatureCallback._cbEnableResizeCanvas,\r\n Config.resizeTimeout,\r\n );\r\n return false;\r\n }\r\n updateDirtyEffect() {\r\n let width = this._viewerOSGJS.getCanvasWidth();\r\n let height = this._viewerOSGJS.getCanvasHeight();\r\n (this._width && this._height) || (this._width = this._height = -1);\r\n if (this._dirty) {\r\n this.onEffectChanged();\r\n this._dirty = false;\r\n }\r\n if (width !== this._width || height !== this._height) {\r\n this._app.getEventEmitter().trigger('resizeCanvas', width, height);\r\n this.getCurrentComposer().resize(width, height)\r\n // const vp = this.getMainCamera().getViewport();\r\n // vp.setViewport(0, 0, width, height);\r\n this.getNodeIn().resetCameraAttachments(),\r\n (this._width = width),\r\n (this._height = height),\r\n //vh = true,\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n\r\n updateNearFarRatio() {\r\n return;\r\n let features = this._app.getFeatures();\r\n let ratio = features.camera.getModel().get('nearFarRatio');\r\n this.getMainCamera().setNearFarRatio(ratio);\r\n }\r\n\r\n updateGlobalTexUniforms() {\r\n let featureManager = this._app.getFeaturesManager(),\r\n textureSize = this._app.globalUniform.uGlobalTexSize.getInternalArray(),\r\n textureRatio = this._app.globalUniform.uGlobalTexRatio.getInternalArray(),\r\n halton = this._app.globalUniform.uHalton.getInternalArray();\r\n this._app.globalUniform.uPreviousGlobalTexSize.setFloat2(textureSize)\r\n this._app.globalUniform.uPreviousGlobalTexRatio.setFloat2(textureRatio)\r\n this._app.globalUniform.uPreviousHalton.setFloat4(halton);\r\n let viewport = featureManager.getViewport3d();\r\n textureSize[0] = viewport.width()\r\n textureSize[1] = viewport.height()\r\n let composer = this.getCurrentComposer();\r\n textureRatio[0] = composer.getGlobalXRatio()\r\n textureRatio[1] = composer.getGlobalYRatio()\r\n composer.getInternalTexture('TextureToBeRefracted');\r\n }\r\n\r\n _shadowJitterUpdate(frame) {\r\n\r\n let frameMod = 1 + frame;\r\n this._app.globalUniform.uStaticFrameNumShadow0.setFloat(frameMod),\r\n this._app.globalUniform.uStaticFrameNumShadow1.setFloat(frameMod),\r\n this._app.globalUniform.uStaticFrameNumShadow2.setFloat(frameMod),\r\n this._app.globalUniform.uStaticFrameNumShadow3.setFloat(frameMod);\r\n \r\n }\r\n\r\n updateSsao() {\r\n\r\n if (this._postProcessFeature.model.get(\"ssaoEnable\") && this._postProcessFeature.model.get(\"ssaoIntensity\") >= .01) {\r\n\r\n var nearfar = this._app.globalUniform.uNearFar.getInternalArray();\r\n if (!(nearfar[0] > nearfar[1])) {\r\n var viewport = this._app.getFeaturesManager().getViewport3d()\r\n , projMat = this.getClampedProjectionMatrix()\r\n , n = 1 === projMat[15] ? 1 : 2 / projMat[5]\r\n , r = -2 * Math.tan(.5 * n);\r\n this._app.postProcessUniform.uSsaoProjectionScale.setFloat(viewport.height() / r);\r\n var projInfo = this._app.postProcessUniform.uSsaoProjectionInfo.getInternalArray();\r\n projInfo[0] = -2 / (viewport.width() * projMat[0]),\r\n projInfo[1] = -2 / (viewport.height() * projMat[5]),\r\n projInfo[2] = (1 - projMat[8]) / projMat[0],\r\n projInfo[3] = (1 - projMat[9]) / projMat[5]\r\n }\r\n }\r\n }\r\n\r\n updateGlobalUniforms(framestamp) {\r\n this.updateNearFarRatio();\r\n this.updateGlobalTexUniforms();\r\n this._app.globalUniform.uTimeViewer.setFloat(framestamp.getSimulationTime() / 1e3);\r\n //let bounding = Bounding.getModelBoxWithDisplacement();\r\n //GlobalUniform.uBoxRadius.setFloat(t ? bounding.radius() : 1),\r\n this._app.globalUniform.uPixelRatio.setFloat2(this._app._canvasPixelRatio.getPixelRatio());\r\n let supersample = this._app.getSuperSample();\r\n let framemod =\r\n (framestamp.getFrameNumber() + supersample.getFrameNumber()) % 16;\r\n this._shadowJitterUpdate(framemod);\r\n this._app.globalUniform.uFrameMod.setFloat(framemod);\r\n let needsSetFramemod =\r\n supersample.isEnabled() ||\r\n this._app.postProcessUniform.uTaaEnabled.getInternalArray()[0];\r\n this._app.globalUniform.uFrameModTaaSS.setFloat(needsSetFramemod ? framemod : 0);\r\n let reprojectMatrix = this._app.globalUniform.uReprojectViewProj.getInternalArray(),\r\n prevProjection = this._app.globalUniform.uPreviousProjection.getInternalArray(),\r\n invViewMatrix = this._app.globalUniform.uPreviousViewInvView.getInternalArray(),\r\n viewMatrix = this._app.getCamera().getViewMatrix(),\r\n projectionMatrix = this._cullConfig.doVR ?\r\n this._cullConfig.leftProjection :\r\n this.getClampedProjectionMatrix();\r\n\r\n if (this._tmpView) {\r\n osg.mat4.invert(invViewMatrix, viewMatrix);\r\n osg.mat4.mul(invViewMatrix, this._tmpView, invViewMatrix);\r\n osg.mat4.mul(reprojectMatrix, this._tmpProjection, invViewMatrix);\r\n osg.mat4.copy(prevProjection, this._tmpProjection);\r\n osg.mat4.copy(this._tmpView, viewMatrix);\r\n osg.mat4.copy(this._tmpProjection, projectionMatrix);\r\n } else {\r\n (this._tmpView = osg.mat4.clone(viewMatrix)),\r\n (this._tmpProjection = osg.mat4.clone(projectionMatrix)),\r\n osg.mat4.copy(reprojectMatrix, projectionMatrix);\r\n }\r\n }\r\n cull(e, t) {\r\n t.traverse(e);\r\n let frameStamp = t.getFrameStamp();\r\n this.updateSsao(frameStamp)\r\n this.updateDirtyEffect();\r\n this.updateGlobalUniforms(frameStamp);\r\n return false;\r\n\r\n /*\r\n if (t.traverse(e),\r\n !this._model.get(\"postProcessReady\"))\r\n return false;\r\n let i = t.getFrameStamp();\r\n return this.updateTAA(i),\r\n this.updateSSS(i),\r\n \r\n this.updateGrain(i),\r\n this.updateDof(i),\r\n this.updateFade(i),\r\n this.updateVeil(i),\r\n this.updateDirtyEffect(),\r\n this.updateGlobalUniforms(i),\r\n false \r\n */\r\n }\r\n}\r\n\r\n//FeatureName: \"postProcess\"\r\nexport default class PostProcessFeature {\r\n constructor(app) {\r\n this._app = app;\r\n this.canvasRatioModel = new Model({viewerToCanvasRatio:1})\r\n this.canvasRatioModel.on(\r\n 'change:viewerToCanvasRatio',\r\n this._onViewerToCanvasRatio,\r\n this\r\n )\r\n\r\n const get = (name) => {\r\n if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))\r\n return decodeURIComponent(name[1]);\r\n }\r\n var ua = navigator.userAgent.toLowerCase();\r\n var isAndroid = ua.indexOf(\"android\") > -1; //&& ua.indexOf(\"mobile\");\r\n\r\n const forceEnable = get('ssao') == '1' \r\n\r\n this.model = new Model({\r\n \"toneMappingExposure\": 1,\r\n \"toneMappingBrightness\": 0,\r\n \"toneMappingContrast\": 0,\r\n \"toneMappingSaturation\": 1,\r\n \"toneMappingMethod\":1,\r\n \"ssaoRadius\":4,\r\n \"ssaoIntensity\":0.5,\r\n \"ssaoBias\":0.8,\r\n \"ssaoEnable\": false// forceEnable || !isAndroid\r\n })\r\n this.model.on('change:toneMappingExposure', this.onToneMappingExposureChanged, this);\r\n this.model.on('change:toneMappingBrightness',this.onToneMappingBrightnessChanged, this);\r\n this.model.on('change:toneMappingContrast', this.onToneMappingContrastChanged, this);\r\n this.model.on('change:toneMappingSaturation', this.onToneMappingSaturationChanged, this);\r\n this.model.on('change:toneMappingMethod', this.onToneMappingMethodChanged, this);\r\n //let model = this.model;\r\n // let model = new EventEmitter3();\r\n // this.model = model;\r\n // this._model = model;\r\n // model.on('change:webVR', this.dirty, this),\r\n // model.on('change:distortVR', this.dirty, this),\r\n // model.on('change:enable', this.dirty, this),\r\n // model.on('change:grainEnable', this.checkGrainEnable, this),\r\n // model.on('change:sharpenEnable', this.checkSharpenEnable, this),\r\n // model.on(\r\n // 'change:chromaticAberrationEnable',\r\n // this.checkChromaticAberrationEnable,\r\n // this,\r\n // ),\r\n // model.on('change:vignetteEnable', this.checkVignetteEnable, this),\r\n // model.on('change:bloomEnable', this.checkBloomEnable, this),\r\n // model.on('change:dofEnable', this.checkDofEnable, this),\r\n // model.on('change:toneMappingEnable', this.dirty, this),\r\n // model.on('change:colorBalanceEnable', this.dirty, this),\r\n this.model.on('change:ssaoEnable', this.checkSsaoEnable, this)\r\n this.model.on('change:ssaoIntensity', this.onSsaoIntensity, this)\r\n this.model.on('change:ssaoRadius', this.onSsaoRadius, this)\r\n this.model.on('change:ssaoBias', this.onSsaoBias, this)\r\n // model.on('change:ssrEnable', this.checkSsrEnable, this),\r\n // model.on('change:taaEnable', this.checkTaaEnable, this),\r\n // model.on('change:taaTransparent', this.checkTaaTransparentEnable, this),\r\n // model.on('change:distortion', this.onDistortionChanged, this),\r\n // model.on('change:projectionLeft', this.onProjectionLeftChanged, this),\r\n // model.on('change:unprojectionLeft', this.onUnprojectionLeftChanged, this),\r\n // model.on('change:grainFactor', this.onGrainFactor, this),\r\n // model.on('change:sharpenFactor', this.onSharpenFactor, this),\r\n // model.on(\r\n // 'change:chromaticAberrationFactor',\r\n // this.onChromaticAberrationFactor,\r\n // this,\r\n // ),\r\n // model.on('change:vignetteAmount', this.onVignetteLensChanged, this),\r\n // model.on('change:vignetteHardness', this.onVignetteLensChanged, this),\r\n // model.on('change:bloomFactor', this.onBloomFactorChanged, this),\r\n // model.on('change:bloomThreshold', this.onBloomThresholdChanged, this),\r\n // model.on('change:bloomRadius', this.onBloomRadiusChanged, this),\r\n \r\n // model.on('change:colorBalanceLow', this.onColorBalanceShiftChanged, this),\r\n // model.on('change:colorBalanceMid', this.onColorBalanceShiftChanged, this),\r\n // model.on(\r\n // 'change:colorBalanceHigh',\r\n // this.onColorBalanceShiftChanged,\r\n // this,\r\n // ),\r\n // model.on('change:dofFocusPoint', this.onDofFocusPoint, this),\r\n // model.on('change:dofBlurNear', this.onDofBlurNear, this),\r\n // model.on('change:dofBlurFar', this.onDofBlurFar, this),\r\n // model.on('change:ssrFactor', this.onSsrFactor, this),\r\n // model.on('change', GlobalSetter.draw),\r\n this._effectiveConfig = {};\r\n this._viewerOSGJS = this._app.getViewerOSGJS();\r\n this._sssTexKernel = new osg.Texture();\r\n this._sssTexKernel.divisor = -1;\r\n this._camera = this._createMainCamera();\r\n this._nodeIn = new PostProcessNode(this);\r\n this._nodeOut = this._createNodeOut();\r\n this._nodeIn.addChild(this._camera);\r\n this._camera.addChild(this._nodeOut);\r\n this._callbackPostProcess = new PostProcessCallback(this);\r\n this._nodeIn.setCullCallback(this._callbackPostProcess);\r\n this._initUniforms();\r\n this._app.getEventEmitter().bind('resizeCanvas', this._updateViewports, this)\r\n }\r\n\r\n _onViewerToCanvasRatio () {\r\n this._updateViewports()\r\n this._app._frameManager.draw()\r\n }\r\n _updateViewports () {\r\n var features = this._app.getFeatures(),\r\n camera = this._app.getCamera(),\r\n ppvp = features.postProcess.getCamera().getViewport(),\r\n camvp = camera.getViewport(),\r\n camW = camvp.width(),\r\n camH = camvp.height()\r\n\r\n ppvp.setViewport(0, 0, camW, camH)\r\n var ratio = this.canvasRatioModel.get('viewerToCanvasRatio')\r\n var proj = camera.getProjectionMatrix()\r\n proj[0] = (proj[5] * camH) / (camW * ratio)\r\n }\r\n\r\n getModel() {\r\n return this.model;\r\n }\r\n\r\n dirty() {\r\n this._callbackPostProcess.dirty();\r\n }\r\n\r\n _initUniforms() {\r\n let attrs = this.model.attributes;\r\n for (let attr in attrs) this.model.trigger('change:' + attr);\r\n }\r\n\r\n _createNodeOut() {\r\n let node = new osg.Node();\r\n return (\r\n node.setName('PostProcess - node Out'),\r\n (this._app.nodePostProcessOut = node),\r\n node\r\n );\r\n }\r\n\r\n _createMainCamera() {\r\n let camera = new osg.Camera(),\r\n width = this._viewerOSGJS.getCanvasWidth(),\r\n height = this._viewerOSGJS.getCanvasHeight();\r\n return (\r\n camera.setViewport(new osg.Viewport(0, 0, width, height)),\r\n camera.setName('PostProcess - MainCamera'),\r\n camera.setRenderOrder(osg.Camera.PRE_RENDER, 0),\r\n camera.attachRenderBuffer(\r\n osg.FrameBufferObject.DEPTH_ATTACHMENT,\r\n osg.FrameBufferObject.DEPTH_COMPONENT16,\r\n ),\r\n (this._app.cameraMain = camera),\r\n camera\r\n );\r\n }\r\n\r\n methodToInt(toneMapMode) {\r\n return 'reinhard' === toneMapMode ? 1 : 'filmic' === toneMapMode ? 2 : 0;\r\n }\r\n\r\n checkGrainEnable() {\r\n this._effectiveConfig.useGrain !== this.model.isEffectiveGrain() &&\r\n this.dirty();\r\n }\r\n\r\n checkSharpenEnable() {\r\n this._effectiveConfig.useSharpen !== this.model.isEffectiveSharpen() &&\r\n this.dirty();\r\n }\r\n\r\n checkChromaticAberrationEnable() {\r\n this._effectiveConfig.useChromaticAberration !==\r\n this.model.isEffectiveChromaticAberration() && this.dirty();\r\n }\r\n\r\n checkVignetteEnable() {\r\n this._effectiveConfig.useVignette !== this.model.isEffectiveVignette() &&\r\n this.dirty();\r\n }\r\n\r\n checkBloomEnable() {\r\n this._effectiveConfig.useBloom !== this.model.isEffectiveBloom() &&\r\n this.dirty();\r\n }\r\n\r\n checkDofEnable() {\r\n this._effectiveConfig.useDof !== this.model.isEffectiveDof() &&\r\n this.dirty();\r\n }\r\n\r\n checkSsaoEnable() {\r\n\r\n this._effectiveConfig.useSsao !== (this.model.get(\"ssaoEnable\") && this.model.get(\"ssaoIntensity\") >= .01) &&\r\n this.dirty();\r\n }\r\n\r\n checkSsrEnable() {\r\n this._effectiveConfig.useSsr !== this.model.isEffectiveSsr() &&\r\n this.dirty();\r\n }\r\n\r\n checkTaaEnable() {\r\n this._effectiveConfig.useTaa !== this.model.get('taaEnable') &&\r\n this.dirty();\r\n }\r\n\r\n checkTaaTransparentEnable() {\r\n this._effectiveConfig.useTaaTransparent !==\r\n (this.model.get('taaEnable') && this.model.get('taaTransparent')) &&\r\n this.dirty();\r\n }\r\n\r\n onDistortionChanged() {\r\n this._app.postProcessUniform.uDistortion.setFloat2(this.model.get('distortion'));\r\n }\r\n\r\n onProjectionLeftChanged() {\r\n this._app.postProcessUniform.uProjectionLeft.setFloat4(\r\n this.model.get('projectionLeft'),\r\n );\r\n }\r\n\r\n onUnprojectionLeftChanged() {\r\n this._app.postProcessUniform.uUnprojectionLeft.setFloat4(\r\n this.model.get('unprojectionLeft'),\r\n );\r\n }\r\n\r\n onGrainFactor() {\r\n this._app.postProcessUniform.uGrainFactor.setFloat(this.model.get('grainFactor')),\r\n this.checkGrainEnable();\r\n }\r\n\r\n onSharpenFactor() {\r\n this._app.postProcessUniform.uSharpFactor.setFloat(this.model.get('sharpenFactor')),\r\n this.checkSharpenEnable();\r\n }\r\n\r\n onChromaticAberrationFactor() {\r\n this._app.postProcessUniform.uChromaFactor.setFloat(\r\n this.model.get('chromaticAberrationFactor'),\r\n ),\r\n this.checkChromaticAberrationEnable();\r\n }\r\n\r\n onVignetteLensChanged() {\r\n let lensRadius = this._app.postProcessUniform.uLensRadius.getInternalArray(),\r\n amount = this.model.get('vignetteAmount'),\r\n hardness = this.model.get('vignetteHardness');\r\n (lensRadius[0] = 2 - amount - hardness),\r\n (lensRadius[1] = hardness - amount),\r\n this.checkVignetteEnable();\r\n }\r\n\r\n onBloomFactorChanged() {\r\n this._app.postProcessUniform.uBloomFactor.setFloat(this.model.get('bloomFactor')),\r\n this.checkBloomEnable();\r\n }\r\n\r\n onBloomThresholdChanged() {\r\n this._app.postProcessUniform.uBloomThreshold.setFloat(\r\n this.model.get('bloomThreshold'),\r\n ),\r\n this.checkBloomEnable();\r\n }\r\n\r\n onBloomRadiusChanged() {\r\n this._app.postProcessUniform.uBloomRadius.setFloat(this.model.get('bloomRadius')),\r\n this.checkBloomEnable();\r\n }\r\n\r\n onColorBalanceShiftChanged() {\r\n this._app.postProcessUniform.uColorBalanceLow.setFloat3(\r\n this.model.get('colorBalanceLow'),\r\n ),\r\n this._app.postProcessUniform.uColorBalanceMid.setFloat3(\r\n this.model.get('colorBalanceMid'),\r\n ),\r\n this._app.postProcessUniform.uColorBalanceHigh.setFloat3(\r\n this.model.get('colorBalanceHigh'),\r\n );\r\n }\r\n \r\n onToneMappingExposureChanged() {\r\n this._app.postProcessUniform.uToneExposure.setFloat(this.model.get(\"toneMappingExposure\"));\r\n }\r\n\r\n onToneMappingBrightnessChanged() {\r\n this._app.postProcessUniform.uToneBrightness.setFloat(this.model.get(\"toneMappingBrightness\"));\r\n }\r\n\r\n onToneMappingContrastChanged() {\r\n this._app.postProcessUniform.uToneContrast.setFloat(this.model.get(\"toneMappingContrast\"));\r\n }\r\n\r\n onToneMappingSaturationChanged() {\r\n this._app.postProcessUniform.uToneSaturation.setFloat(this.model.get(\"toneMappingSaturation\"));\r\n }\r\n\r\n onToneMappingMethodChanged() {\r\n this._app.postProcessUniform.uToneMethod.setInt(this.model.get(\"toneMappingMethod\"));\r\n }\r\n\r\n onDofFocusPoint() {\r\n this._callbackPostProcess.updateDofFocusPoint();\r\n }\r\n\r\n onDofBlurNear() {\r\n this._callbackPostProcess.updateTargetDofBlurNear(), this.checkDofEnable();\r\n }\r\n\r\n onDofBlurFar() {\r\n this._callbackPostProcess.updateTargetDofBlurFar(), this.checkDofEnable();\r\n }\r\n\r\n hideDofCross() {\r\n //this._callbackPostProcess.hideDofCross();\r\n }\r\n\r\n onSsaoRadius() {\r\n this._app.postProcessUniform.uSsaoRadius.setFloat(this.model.get('ssaoRadius')),\r\n this.checkSsaoEnable();\r\n }\r\n\r\n onSsaoIntensity() {\r\n this._app.postProcessUniform.uSsaoIntensity.setFloat(\r\n this.model.get('ssaoIntensity'),\r\n ),\r\n this.checkSsaoEnable();\r\n }\r\n\r\n onSsaoBias() {\r\n this._app.postProcessUniform.uSsaoBias.setFloat(this.model.get('ssaoBias'));\r\n }\r\n\r\n onSsrFactor() {\r\n this._app.globalUniform.uSsrFactor.setFloat(this.model.get('ssrFactor')),\r\n this.checkSsrEnable();\r\n }\r\n\r\n getNodeIn() {\r\n return this._nodeIn;\r\n }\r\n\r\n getNodeOut() {\r\n return this._nodeOut;\r\n }\r\n\r\n getCamera() {\r\n return this._camera;\r\n }\r\n\r\n getCurrentComposer() {\r\n return this._nodeIn._composer;\r\n }\r\n\r\n prepareForScreenShot() {\r\n this._app.globalUniform.uSSAARestart.setFloat(1), this.hideDofCross();\r\n }\r\n\r\n resetAfterScreenShot() {\r\n this._app.globalUniform.uSSAARestart.setFloat(0);\r\n }\r\n}","import GLState from './GLState.js';\r\nimport osg from \"../osg/osg\"\r\nimport TextureCubeMap from './TextureCubeMap';\r\nimport RenderDetail from './RenderDetail';\r\nimport ShaderMaker from './ShaderMaker'\r\nconst backgroundEnv_vert = 'attribute vec3 Vertex;\\nuniform mat4 uModelViewMatrix;\\nuniform mat4 uProjectionMatrix;\\n\\nuniform vec4 uHalton;\\nuniform vec2 uGlobalTexSize;\\nuniform vec2 uGlobalTexRatio;\\n\\nvarying vec3 vLocalVertex;\\n\\nvoid main(void)\\n{\\n vLocalVertex = Vertex.rgb;\\n\\n mat4 projectionMatrix = uProjectionMatrix;\\n vec2 halt = uGlobalTexRatio.xy * uHalton.xy / uGlobalTexSize.xy;\\n projectionMatrix[2][0] += halt.x;\\n projectionMatrix[2][1] += halt.y;\\n\\n gl_Position = (projectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0))).xyww;\\n}\\n';\r\nconst backgroundEnv_frag = 'varying vec3 vLocalVertex;\\n\\n// common stuffs\\nuniform int uOutputLinear;\\nuniform float uRGBMRange;\\n\\nuniform float uEnvironmentExposure;\\nuniform float uBackgroundExposure;\\n\\nuniform vec3 uDiffuseSPH[9];\\nuniform samplerCube uTexture0;\\nuniform float uSize;\\nuniform int uAmbient;\\n\\nuniform float uFrameModTaaSS;\\n\\n#pragma include \"utils/functions.glsl\"\\n#pragma include \"utils/cubemap.glsl\"\\n#pragma include \"utils/rand.glsl\"\\n\\n// sph env\\nvec3 evaluateDiffuseSphericalHarmonics(const in vec3 s[9], const in vec3 n) {\\n // https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\\n vec3 result = (s[0]+s[1]*n.y+s[2]*n.z+s[3]*n.x+s[4]*n.y*n.x+s[5]*n.y*n.z+s[6]*(3.0*n.z*n.z-1.0)+s[7]*(n.z*n.x)+s[8]*(n.x*n.x-n.y*n.y));\\n return max(result, vec3(0.0));\\n}\\n\\nvoid main(void) {\\n\\n vec3 color;\\n if (uAmbient == 1) {\\n vec3 normal = normalize(vLocalVertex + mix(-0.5/255.0, 0.5/255.0, pseudoRandom(gl_FragCoord.xy))*2.0);\\n // vec3 normal = normalize(vLocalVertex + (interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS) - 0.5) * 0.4);\\n color = evaluateDiffuseSphericalHarmonics(uDiffuseSPH, normal);\\n } else {\\n color = textureCubeFixed(uTexture0, normalize(vLocalVertex), uSize);\\n }\\n\\n color *= uEnvironmentExposure * uBackgroundExposure;\\n\\n if (uOutputLinear == 0 ) color = linearTosRGB(color);\\n\\n gl_FragColor = encodeRGBM(color, uRGBMRange);\\n}\\n' \r\nexport default class BackgroundNode extends osg.Node {\r\n constructor(app) {\r\n super();\r\n this._geometry = osg.createTexturedBoxGeometry(0, 0, 0, 5, 5, 5);\r\n this._show = 'COLOR';\r\n this._bgEnv = null;\r\n this._bgFixed = null;\r\n this._texRatio = 1;\r\n this._canvasWidth = 1;\r\n this._canvasHidth = 1;\r\n this._app = app\r\n this.init()\r\n this.hide();\r\n }\r\n\r\n init() {\r\n let geom = this._geometry,\r\n stateset = geom.getOrCreateStateSet();\r\n stateset.setAttributeAndModes(\r\n GLState.DEPTH_LEQUAL_BACKGROUND_NO_WRITE,\r\n osg.StateAttribute.PROTECTED,\r\n );\r\n stateset.setRenderBinDetails(RenderDetail.BACKGROUND, 'RenderBin');\r\n stateset.setAttributeAndModes(\r\n \r\n ShaderMaker.getOrCreateShader(\r\n backgroundEnv_vert,\r\n backgroundEnv_frag,\r\n 'environment-background',\r\n 'Environment',\r\n )\r\n );\r\n stateset.setTextureAttributeAndModes(0, TextureCubeMap.dummyTexture);\r\n for (var key in this._app.backgroundUniform)\r\n stateset.addUniform(this._app.backgroundUniform[key]);\r\n this.addChild(geom);\r\n }\r\n\r\n rescale(width, height) {\r\n width && (this._canvasWidth = width);\r\n height && (this._canvasHeight = height);\r\n let aspect = this._canvasWidth / this._canvasHeight,\r\n scaleArray = this._app.backgroundUniform.scale.getInternalArray();\r\n\r\n aspect >= this._texRatio ?\r\n ((scaleArray[0] = 1), (scaleArray[1] = this._texRatio / aspect)) :\r\n ((scaleArray[0] = aspect / this._texRatio), (scaleArray[1] = 1));\r\n }\r\n\r\n getBackground() {\r\n return this._bgFixed;\r\n }\r\n\r\n getEnvironment() {\r\n return this._bgEnv;\r\n }\r\n\r\n hide() {\r\n (this._show = 'NONE'), this._update();\r\n }\r\n\r\n showColor() {\r\n (this._show = 'COLOR'), this._update();\r\n }\r\n\r\n showEnvironment() {\r\n (this._show = 'ENV'), this._update();\r\n }\r\n\r\n setEnvironment(bgEnv, size) {\r\n this._bgEnv = bgEnv;\r\n undefined !== size && this._app.backgroundUniform.size.setFloat(size), this._update();\r\n }\r\n\r\n setExposure(exposure) {\r\n this._app.backgroundUniform.backgroundExposure.setFloat(exposure);\r\n }\r\n\r\n showAmbient() {\r\n this._show = 'AMBIENT';\r\n this._update();\r\n }\r\n\r\n showBackground() {\r\n this._show = 'FIXED';\r\n this._update();\r\n }\r\n\r\n setBackground(bgFixed) {\r\n this._texRatio = bgFixed.getWidth() / bgFixed.getHeight();\r\n this._bgFixed = bgFixed;\r\n this._update();\r\n }\r\n\r\n _update() {\r\n this._app._frameManager.draw();\r\n if ('ENV' === this._show || 'AMBIENT' === this._show) {\r\n this._geometry.setNodeMask(-1)\r\n this._app.backgroundUniform.ambient.getInternalArray()[0] = 'AMBIENT' === this._show\r\n if(this._bgEnv && 'ENV' === this._show) {\r\n this._geometry.getOrCreateStateSet().setTextureAttributeAndModes(0, this._bgEnv);\r\n }\r\n \r\n } else {\r\n this._geometry.setNodeMask(0);\r\n }\r\n }\r\n}","import osg from '../osg/osg';\r\n\r\nclass TextureEnvironment extends osg.Texture {\r\n constructor(tex, channel) {\r\n super();\r\n this._textureNull = undefined;\r\n this._texture = tex\r\n this._channel = channel || 'Specular'\r\n this._isCubemap = false\r\n this._hash = 'Specular' === channel\r\n ? 'EnvSpec'\r\n : 'SpecularPBR' === channel\r\n ? 'EnvSpecPBR'\r\n : 'EnvBRDF'\r\n }\r\n getUniformName(name) {\r\n return 'uTextureEnvironment' + this.getChannel() + name;\r\n }\r\n getOrCreateUniforms() {\r\n var uniforms = TextureEnvironment.uniforms;\r\n var channel = this.getChannel();\r\n if (uniforms[channel]) return uniforms[channel];\r\n var tex = this._texture;\r\n return (uniforms[channel] = {\r\n size: osg.Uniform.createFloat2(\r\n [tex.getWidth(), tex.getHeight()],\r\n this.getUniformName('TextureSize'),\r\n ),\r\n });\r\n }\r\n setIsCubemap(isCubemap) {\r\n this._isCubemap = isCubemap;\r\n }\r\n getIsCubemap() {\r\n return this._isCubemap;\r\n }\r\n getTexture() {\r\n return this._texture;\r\n }\r\n getChannel() {\r\n return this._channel;\r\n }\r\n cloneType() {\r\n return new TextureEnvironment(new osg.Texture());\r\n }\r\n getHash() {\r\n return this._hash;\r\n }\r\n updateLodRange(e) {\r\n var uniforms = this.getOrCreateUniforms();\r\n var i = Math.log(this._texture.getWidth()) / Math.LN2; // 8\r\n var n = i - Math.log(e) / Math.LN2; // 8 - 5\r\n if (uniforms.lodRange) {\r\n let uniformLodRange = uniforms.lodRange.getInternalArray();\r\n uniformLodRange[0] = i;\r\n uniformLodRange[1] = n;\r\n } else\r\n uniforms.lodRange = osg.Uniform.createFloat2(\r\n [i, n],\r\n this.getUniformName('LodRange'),\r\n );\r\n }\r\n apply(state, textureunit) {\r\n let tex = this._texture;\r\n undefined !== tex && tex.apply(state);\r\n let uniformSize = this.getOrCreateUniforms(\r\n textureunit,\r\n ).size.getInternalArray();\r\n (uniformSize[0] = tex.getWidth()), (uniformSize[1] = tex.getHeight());\r\n }\r\n\r\n releaseGLObjects(){\r\n this._texture.releaseGLObjects()\r\n }\r\n}\r\nosg.objectLibraryClass(\r\n TextureEnvironment.prototype,\r\n 'osgEditor',\r\n 'TextureEnvironment',\r\n);\r\nosg.setTypeID(TextureEnvironment);\r\nTextureEnvironment.prototype.attributeType = 'Texture';\r\nTextureEnvironment.prototype.channelType = [\r\n 'Specular',\r\n 'SpecularPBR',\r\n 'IntegrateBRDF',\r\n];\r\n\r\nTextureEnvironment.uniforms = {};\r\n\r\nexport default TextureEnvironment;\r\n","import BackgroundNode from './BackgroundNode.js';\r\nimport osg from \"../osg/osg\";\r\n\r\nimport Config from './Config.js';\r\nimport MaxTextureUnit from './MaxTextureUnit.js';\r\n\r\nimport PickMask from './PickMask.js';\r\nimport TextureEnvironment from './TextureEnvironment';\r\nimport EditorLight from './EditorLight';\r\nimport GeometryCreator from './GeometryCreator'\r\nimport MaterialUtils from './material/MaterialUtils';\r\nclass EnvironmentNode extends osg.Node {\r\n constructor(app) {\r\n super();\r\n this.getOrCreateStateSet();\r\n this._enable = false;\r\n this._app = app\r\n this._isPBR = false\r\n this._textureSpecular = undefined\r\n this._textureSpecularUnit = MaterialUtils.ENV_SPECUAR_TEXTURE_UNIT\r\n this._textureSpecularPBR = undefined;\r\n this._textureIntegrateBRDF = undefined;\r\n this._textureSpecularPBRUnit = MaterialUtils.ENV_SPECUAR_TEXTURE_UNIT;\r\n this._textureIntegrateBRDFUnit = MaterialUtils.ENV_BRDF_TEXTURE_UNIT;\r\n this._nodeBackground = new BackgroundNode(app);\r\n this._adjustRotation = osg.mat4.fromXRotation(\r\n osg.mat4.create(),\r\n Math.PI / 2,\r\n );\r\n this._root = new osg.MatrixTransform();\r\n osg.mat4.multiply(this._root.getMatrix(), this._root.getMatrix(), this._adjustRotation);\r\n this._defaultExposure = 1\r\n this._lightProbes = [];\r\n var envLight = this._app._features.lighting.createLight('Environment', 3, EditorLight.DIRECTION);\r\n this._light = envLight.light\r\n this._mtLight = envLight.node\r\n this._shadow = envLight.shadowMap\r\n this._mtLight.addChild(envLight.lightSource)\r\n this._lightIntensity = 1\r\n this._lightShadowEnabled = false\r\n this._shadowBias = 0.005\r\n this._shadowedScene = undefined\r\n this._lightNodeRoot = new osg.MatrixTransform()\r\n this._lightNodeRoot.setName('Env Lighting - Light')\r\n osg.mat4.copy(this._lightNodeRoot.getMatrix(), this._root.getMatrix())\r\n this._lightNodeRoot.addChild(this._mtLight)\r\n this.addUpdateCallback(this)\r\n // Ti.Z.bind(\"change:mask\", this.updateLightShadow, this)\r\n }\r\n\r\n getBackground() {\r\n return this._nodeBackground;\r\n }\r\n\r\n enable() {\r\n this._enable = true;\r\n this.setTexturesStateSet();\r\n this._app._frameManager.draw();\r\n }\r\n\r\n disable() {\r\n this._enable = false;\r\n this.removeTexturesStateSet();\r\n this._app._frameManager.draw();\r\n }\r\n\r\n setBackgroundExposure(exposure) {\r\n this._nodeBackground.setExposure(exposure)\r\n this._app._frameManager.draw();\r\n }\r\n\r\n setBackgroundTexture(bgEnv, size) {\r\n this._nodeBackground.setEnvironment(bgEnv, size)\r\n this._app._frameManager.draw();\r\n }\r\n\r\n createCameraNode() {\r\n var perspectResult = {}\r\n var scope = this\r\n var tempMat = osg.mat4.create()\r\n var envTransformUniform = this._app.envUniform.environmentTransform.getInternalArray()\r\n var camera = new osg.Camera();\r\n camera.setName('Environment - Camera');\r\n camera.setCullCallback(\r\n new (function () {\r\n this.cull = function (camera, cullvisitor) {\r\n osg.mat4.getPerspective(\r\n perspectResult,\r\n scope._mainCamera.getProjectionMatrix(),\r\n );\r\n osg.mat4.perspective(\r\n cullvisitor.getCurrentProjectionMatrix(),\r\n (perspectResult.fovy * Math.PI) / 180,\r\n perspectResult.aspectRatio,\r\n 1,\r\n 1e3,\r\n );\r\n osg.mat4.copy(\r\n cullvisitor.getCurrentModelViewMatrix(),\r\n scope._mainCamera.getViewMatrix(),\r\n );\r\n osg.mat4.setTranslation(\r\n cullvisitor.getCurrentModelViewMatrix(),\r\n osg.vec3.ZERO,\r\n );\r\n var curModelView = cullvisitor.getCurrentModelViewMatrix();\r\n osg.mat4.multiply(tempMat, curModelView, scope._root.getMatrix());\r\n osg.mat3.fromMat4(envTransformUniform, tempMat);\r\n osg.mat3.transpose(envTransformUniform, envTransformUniform);\r\n return true;\r\n };\r\n })(),\r\n );\r\n camera.setReferenceFrame(osg.Transform.ABSOLUTE_RF);\r\n this._app.cameraEnvironment = camera;\r\n return camera;\r\n }\r\n\r\n init(mainCam, shadowedScene) {\r\n this._mainCamera = mainCam\r\n this._shadowedScene = shadowedScene\r\n this._shadowedScene.addChild(this._lightNodeRoot);\r\n for (var key in this._app.envUniform)\r\n this.getStateSet().addUniform(this._app.envUniform[key]);\r\n var camNode = this.createCameraNode();\r\n camNode.setNodeMask(PickMask.NO_PICK_NO_SHADOW)\r\n this.addChild(camNode)\r\n camNode.addChild(this._root);\r\n this._root.addChild(this._nodeBackground);\r\n this.updateTextureUnits();\r\n this.updateLightShadow();\r\n }\r\n\r\n setLightShadowEnabled(flag) {\r\n (this._lightShadowEnabled = flag && Config.shadow),\r\n this.updateLightShadow();\r\n }\r\n\r\n setLightIntensity(intensity) {\r\n this._lightIntensity = intensity\r\n this.updateLightColorAndIntensity();\r\n this._app._frameManager.draw();\r\n }\r\n\r\n setShadowBias(bias) {\r\n this._shadowBias = bias;\r\n if (this._shadow) {\r\n this._shadow.setBias(bias);\r\n this._shadow.requestRedraw();\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n\r\n setLightProbes(probe) {\r\n this._lightProbes = probe\r\n this.updateLightShadow();\r\n }\r\n\r\n removeTexturesStateSet() {\r\n var ss = this.getStateSet();\r\n ss &&\r\n (this._isPBR\r\n ? (this._textureSpecularPBR &&\r\n ss.removeTextureAttribute(\r\n this._textureSpecularPBRUnit,\r\n this._textureSpecularPBR.getTypeMember(),\r\n ),\r\n this._textureIntegrateBRDF &&\r\n ss.removeTextureAttribute(\r\n this._textureIntegrateBRDFUnit,\r\n this._textureIntegrateBRDF.getTypeMember(),\r\n ))\r\n : this._textureSpecular &&\r\n ss.removeTextureAttribute(\r\n this._textureSpecularUnit,\r\n this._textureSpecular.getTypeMember(),\r\n ));\r\n }\r\n\r\n setTexturesStateSet() {\r\n var ss = this.getStateSet();\r\n ss &&\r\n (this._isPBR\r\n ? (this._textureSpecularPBR &&\r\n ss.setTextureAttributeAndModes(\r\n this._textureSpecularPBRUnit,\r\n this._textureSpecularPBR,\r\n ),\r\n this._textureIntegrateBRDF &&\r\n ss.setTextureAttributeAndModes(\r\n this._textureIntegrateBRDFUnit,\r\n this._textureIntegrateBRDF,\r\n ))\r\n : this._textureSpecular &&\r\n ss.setTextureAttributeAndModes(\r\n this._textureSpecularUnit,\r\n this._textureSpecular,\r\n ));\r\n }\r\n\r\n updateLightColorAndIntensity() {\r\n if (this._light && 0 !== this._lightProbes.length) {\r\n var exposureRate = this._app.envUniform.exposure.getInternalArray()[0] / this._defaultExposure\r\n var lightProbeColor = this._lightProbes[0].color;\r\n osg.vec3.normalize(lightProbeColor, lightProbeColor)\r\n osg.vec3.scale(this._light.getDiffuse(), lightProbeColor, this._lightIntensity * exposureRate);\r\n }\r\n }\r\n\r\n setDefaultExposure(defaultExposure) {\r\n this._defaultExposure = defaultExposure;\r\n }\r\n\r\n setExposure(exposure) {\r\n this._app.envUniform.exposure.setFloat(exposure);\r\n this.updateLightColorAndIntensity();\r\n }\r\n\r\n updateLightFromProbes() {\r\n var dir = this._lightProbes[0].direction\r\n var eyeup = Math.abs(dir[2]) > 0.999 ? osg.vec3.fromValues(0, 1, 0) : osg.vec3.fromValues(0, 0, 1)\r\n var lightMatrix = this._mtLight.getMatrix();\r\n osg.mat4.lookAtDirection(lightMatrix, osg.vec3.ZERO, dir, eyeup);\r\n osg.mat4.invert(lightMatrix, lightMatrix);\r\n this.updateLightColorAndIntensity();\r\n Config.debugEnvShadow && this._debugShadow();\r\n }\r\n\r\n _debugShadow() {\r\n if (!this._debugDone) {\r\n this._debugDone = true;\r\n var axis = osg.createAxisGeometry()\r\n var transform = new osg.MatrixTransform();\r\n transform.setMatrix(\r\n osg.mat4.fromScaling(osg.mat4.create(), [100, 100, -500]),\r\n );\r\n osg.mat4.setTranslation(transform.getMatrix(), [0, 0, 500]);\r\n transform.addChild(axis);\r\n var dirGeom = new GeometryCreator.createDirectionalGeometry(5);\r\n transform.addChild(dirGeom);\r\n transform.setNodeMask(PickMask.NO_PICK_NO_SHADOW);\r\n this._mtLight.addChild(transform);\r\n }\r\n }\r\n\r\n isUsingLightShadow() {\r\n return this._lightShadowEnabled && this._lightProbes.length > 0\r\n }\r\n\r\n updateLightShadow() {\r\n if (this._shadowedScene) {\r\n var useShadow = this.isUsingLightShadow();\r\n this._light.setEnabled(useShadow);\r\n this._app._features.lighting.removeShadowMap(this._shadowedScene, this._shadow);\r\n if (useShadow) {\r\n var maxTextureUnit = MaxTextureUnit();\r\n if ((Config.shadowAtlas && maxTextureUnit > 12) || maxTextureUnit > 12){\r\n this._app._features.lighting.addShadowMap(this._shadowedScene, this._shadow);\r\n }\r\n \r\n this._shadow.setBias(this._shadowBias);\r\n osg.mat4.copy(this._lightNodeRoot.getMatrix(), this._root.getMatrix());\r\n this.updateLightFromProbes();\r\n this._shadow.requestRedraw();\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n }\r\n\r\n update(node, updateVisitor) {\r\n if(node.getNumChildrenRequiringUpdateTraversal() > 0)\r\n updateVisitor.traverse(node);\r\n if (!this._light || !this._shadow) return false;\r\n const featureManager = this._app.getFeaturesManager();\r\n featureManager &&\r\n featureManager.getShadowForcedUpdate() &&\r\n this._shadow.requestRedraw();\r\n return false;\r\n }\r\n\r\n updateShadow() {\r\n this._light && this._shadow && this._shadow.requestRedraw();\r\n }\r\n\r\n updateRotation(rotation) {\r\n osg.mat4.fromZRotation(this._root.getMatrix(), -rotation);\r\n osg.mat4.multiply(\r\n this._root.getMatrix(),\r\n this._root.getMatrix(),\r\n this._adjustRotation,\r\n );\r\n osg.mat4.copy(this._lightNodeRoot.getMatrix(), this._root.getMatrix());\r\n this._shadow && this._shadow.requestRedraw();\r\n }\r\n\r\n setDiffuseSPH(sph) {\r\n for (\r\n var sphValues = this._app.envUniform.diffuseSPH.getInternalArray(),\r\n i = 1 / (2 * Math.sqrt(Math.PI)),\r\n n = -0.5 * Math.sqrt(3 / Math.PI),\r\n r = -n,\r\n a = n,\r\n o = 0.5 * Math.sqrt(15 / Math.PI),\r\n s = -o,\r\n u = 0.25 * Math.sqrt(5 / Math.PI),\r\n l = s,\r\n h = 0.25 * Math.sqrt(15 / Math.PI),\r\n c = [\r\n i,\r\n i,\r\n i,\r\n n,\r\n n,\r\n n,\r\n r,\r\n r,\r\n r,\r\n a,\r\n a,\r\n a,\r\n o,\r\n o,\r\n o,\r\n s,\r\n s,\r\n s,\r\n u,\r\n u,\r\n u,\r\n l,\r\n l,\r\n l,\r\n h,\r\n h,\r\n h,\r\n ],\r\n d = 0;\r\n d < 27;\r\n ++d\r\n )\r\n sphValues[d] = sph[d] * c[d];\r\n }\r\n\r\n setSpecularTexture(texture) {\r\n if(this._enable){\r\n this._textureSpecular = new TextureEnvironment(texture, 'Specular')\r\n this._textureSpecular.setIsCubemap(true)\r\n this.updateTextureUnits()\r\n this._app.envUniform.textureSpecular.setInt(this._textureSpecularUnit)\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n\r\n setSpecularPBRTexture(texture, logrange) {\r\n if (this._enable) {\r\n this._textureSpecularPBR = new TextureEnvironment(texture, 'SpecularPBR');\r\n let isCubemap = 'TextureCubeMap' === texture.className();\r\n this._textureSpecularPBR.setIsCubemap(isCubemap);\r\n this._textureSpecularPBR.updateLodRange(logrange);\r\n this.updateTextureUnits();\r\n this._app.envUniform.textureSpecularPBR.setInt(this._textureSpecularPBRUnit);\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n\r\n setIntegrateBRDFTexture(texture) {\r\n if (this._enable) {\r\n this._textureIntegrateBRDF = new TextureEnvironment(\r\n texture,\r\n 'IntegrateBRDF',\r\n );\r\n this.updateTextureUnits();\r\n this._app.envUniform.textureIntegrateBRDF.setInt(this._textureIntegrateBRDFUnit);\r\n this._app._frameManager.draw();\r\n }\r\n }\r\n\r\n updateTextureUnits() {\r\n this.setTexturesStateSet();\r\n }\r\n\r\n setIsPBR(ispbr) {\r\n this._isPBR = ispbr;\r\n }\r\n}\r\nexport default EnvironmentNode;\r\n","import CreatePromise from '../CreatePromise.js';\r\nimport osg from \"../../osg/osg\";\r\nimport osgViewer from \"../../osgViewer/osgViewer\";\r\nimport Config from '../Config';\r\nimport MaxTextureUnit from '../MaxTextureUnit';\r\nimport EnvironmentNode from '../EnvironmentNode';\r\nimport ResourceManager from '../ResourceManager'\r\nimport { Model } from 'backbone'\r\n// import TextureEnvironment from '../TextureEnvironment';\r\nconst tempMat1 = osg.mat4.create();\r\nconst tempMat2 = osg.mat4.create();\r\n\r\nexport default class Environment {\r\n constructor(app) {\r\n this._app = app;\r\n this._inputManager = this._app.getInputManager();\r\n this._nodeEnvironment = new EnvironmentNode(this._app);\r\n this._nodeEnvironment.setName('Feature - Environment');\r\n this._backgroundLoaded = {};\r\n this.model = new Model({\r\n \"enable\": true,\r\n \"shadowEnable\": true,\r\n \"shadowBias\": 0.0052,\r\n \"lightIntensity\": 0.877,\r\n \"blurLevel\": 0.1,\r\n \"exposure\": 1,\r\n \"backgroundExposure\": 1,\r\n \"rotation\": 0,\r\n 'env': null\r\n })\r\n this.model.bind(\"change:enable\", this.onEnableChanged, this)\r\n this.model.bind(\"change:exposure\", this.onExposureChanged, this)\r\n this.model.bind(\"change:backgroundExposure\", this.onExposureChanged, this)\r\n this.model.bind(\"change:rotation\", this.onRotationChanged, this)\r\n // this.model.bind(\"change:uid\", this.onUIDChanged, this)\r\n this.model.bind(\"updateBackground\", this.onBackgroundEnableChanged, this)\r\n this.model.bind(\"change:blur\", this.onBlurChanged, this)\r\n this.model.bind(\"change:env\", this.onEnvironmentChanged, this)\r\n this.model.bind(\"change\", this._app._frameManager.draw.bind(this._app._frameManager))\r\n this._resourceDefer = CreatePromise();\r\n // this.options.context.getScene().addResourcePromise(this._resourceDefer)\r\n this.model.bind(\"change:shadowEnable\", this.onShadowEnable, this)\r\n this.model.bind(\"change:shadowBias\", this.onShadowBiasChanged, this)\r\n this.model.bind(\"change:lightIntensity\", this.onLightIntensityChanged, this)\r\n\r\n this.initEnvironment();\r\n this.initRotateEnvironment();\r\n }\r\n\r\n getModel() {\r\n return this.model\r\n }\r\n\r\n getBackgroundEnableType() {\r\n\r\n var backgroundFeature = this._app.getFeatures().background;\r\n return backgroundFeature ? backgroundFeature.getModel().get('enable') : \"none\"\r\n }\r\n\r\n isBackgroundEnvironment() {\r\n return 'environment' === this.getBackgroundEnableType();\r\n }\r\n\r\n initEnvironment() {\r\n this.onRotationChanged();\r\n this.onExposureChanged();\r\n this.onEnableChanged();\r\n // this.model.get(\"enable\") || F.Z.resolveDataSizeEnvironment(0)\r\n }\r\n\r\n initRotateEnvironment() {\r\n if (this._app.getViewerOSGJS()) {\r\n this._rotEnv = false\r\n this.lastCanvasX = 0\r\n this._app._featureEventManager.initEnvironment(this)\r\n }\r\n }\r\n\r\n startRotate(e) {\r\n (this._rotEnv = true),\r\n (this.lastCanvasX = e.canvasX),\r\n this._inputManager.setEnable(osgViewer.InputGroups.MANIPULATORS, false);\r\n }\r\n\r\n _computeDelta(event) {\r\n this._app._frameManager.draw();\r\n var delta = (event.canvasX - this.lastCanvasX) / 100;\r\n return (this.lastCanvasX = event.canvasX), delta;\r\n }\r\n\r\n rotateEnv(event, delta) {\r\n if (this._rotEnv) {\r\n delta || (delta = this._computeDelta(event));\r\n var i = (this.model.get(\"rotation\") + delta) % (2 * Math.PI);\r\n this.model.set(\"rotation\", i < 0 ? i + 2 * Math.PI : i)\r\n }\r\n }\r\n\r\n rotateLight(event, delta) {\r\n if (this._rotEnv) {\r\n delta || (delta = this._computeDelta(event));\r\n var lighting = this._app._features.lighting;\r\n if (lighting) {\r\n var center = this._app\r\n .getFeaturesManager()\r\n .getWorldNode()\r\n .getMinimumBound()\r\n .center();\r\n osg.mat4.fromZRotation(tempMat1, -delta % (2 * Math.PI)),\r\n osg.vec3.negate(center, center),\r\n osg.mat4.multiply(\r\n tempMat1,\r\n tempMat1,\r\n osg.mat4.fromTranslation(tempMat2, center),\r\n ),\r\n osg.vec3.negate(center, center),\r\n osg.mat4.multiply(\r\n tempMat1,\r\n osg.mat4.fromTranslation(tempMat2, center),\r\n tempMat1,\r\n );\r\n for (\r\n var lights = lighting.getModel().get('lights'),\r\n i = 0,\r\n o = lights.length;\r\n i < o;\r\n ++i\r\n ) {\r\n var light = lights[i];\r\n if (false/*!light.isAttachedToCamera()*/) {\r\n var matrix = light.get('matrix');\r\n osg.mat4.multiply(matrix, tempMat1, matrix), light.dirty();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n rotateEnvAndLight(event) {\r\n if (this._rotEnv) {\r\n var t = this._computeDelta(event);\r\n this.rotateEnv(event, t), this.rotateLight(event, t);\r\n }\r\n }\r\n endRotate() {\r\n this._rotEnv &&\r\n ((this._rotEnv = false),\r\n this._inputManager.setEnable(osgViewer.InputGroups.MANIPULATORS, true));\r\n }\r\n onUIDChanged() {\r\n // this.model.updateEnvironmentConfig(),\r\n this.onEnvironmentChanged();\r\n this.onBackgroundEnableChanged();\r\n }\r\n getRotating() {\r\n return this._rotEnv;\r\n }\r\n\r\n getNode() {\r\n return this._nodeEnvironment;\r\n }\r\n getNodeEnvironment() {\r\n return this._nodeEnvironment;\r\n }\r\n getResourceManager() {\r\n return null; //this._resourceManager || s.Z.instance\r\n }\r\n onEnableChanged() {\r\n if (this.model.get(\"enable\")) {\r\n this._nodeEnvironment.enable()\r\n this._nodeEnvironment.setLightShadowEnabled(\r\n this.model.get(\"shadowEnable\")\r\n );\r\n this._nodeEnvironment.setLightIntensity(\r\n this.model.get(\"lightIntensity\")\r\n );\r\n this._nodeEnvironment.setShadowBias(this.model.get(\"shadowBias\"));\r\n } else {\r\n this._nodeEnvironment.disable();\r\n this._nodeEnvironment.setLightShadowEnabled(false);\r\n }\r\n\r\n this.onEnvironmentChanged();\r\n }\r\n onShadowEnable() {\r\n var lights = this.getEnvironment().lights;\r\n if (\r\n this.model.get(\"shadowEnable\") ||\r\n (lights && 0 !== lights.length)\r\n ) {\r\n this._nodeEnvironment.setLightShadowEnabled(\r\n this.model.get(\"shadowEnable\")\r\n );\r\n } else {\r\n this.model.set(\"shadowEnable\", false)\r\n }\r\n }\r\n onShadowBiasChanged() {\r\n this._nodeEnvironment.setShadowBias(this.model.get(\"shadowBias\"));\r\n }\r\n onLightIntensityChanged() {\r\n this._nodeEnvironment.setLightIntensity(\r\n this.model.get(\"lightIntensity\")\r\n );\r\n }\r\n onExposureChanged() {\r\n this._nodeEnvironment.setExposure(this.model.get(\"exposure\"));\r\n this._nodeEnvironment.setBackgroundExposure(this.model.get(\"backgroundExposure\"));\r\n }\r\n onRotationChanged() {\r\n this._nodeEnvironment.updateRotation(this.model.get(\"rotation\"));\r\n }\r\n\r\n onBlurChanged() {\r\n // this.abortLastDownloadEnv(),\r\n this.isBackgroundEnvironment() && this.setBackgroundTexture();\r\n }\r\n onBackgroundEnableChanged() {\r\n var backgroundType = this.getBackgroundEnableType();\r\n 'environment' === backgroundType\r\n ? this.setBackgroundTexture()\r\n : 'ambient' === backgroundType && this.setBackgroundAmbient();\r\n }\r\n\r\n onEnvironmentChanged() {\r\n var envModel = this.getEnvironment();\r\n if (envModel) {\r\n // this._onlyLowRes = true\r\n var texturePromises = this.setEnvironment(envModel);\r\n P.all(texturePromises).then(() => {\r\n this._resourceDefer.resolve();\r\n });\r\n }\r\n }\r\n getEnvironment() {\r\n return this.model.get('env');\r\n }\r\n getName() {\r\n return 'Environment3D';\r\n }\r\n // abortLastDownloadEnv() {\r\n // for (var e = this.model.get(\"uid\"), t = this.model.get(\"blur\"), i = this.getResourceManager()._resourceLoader._processing, n = 0, r = i.length; n < r; ++n) {\r\n // var a = i[n]\r\n // , o = a.getXHR();\r\n // o && (void 0 !== a._envUID && a._envUID !== e && o.abort(),\r\n // void 0 !== a._envBlur && a._envBlur !== t && o.abort())\r\n // }\r\n // }\r\n setEnvironment(model) {\r\n // this.abortLastDownloadEnv();\r\n var texturesPromises = [];\r\n var isPBR = true;\r\n this._nodeEnvironment.setIsPBR(isPBR);\r\n this._nodeEnvironment.setDiffuseSPH(model.diffuseSPH);\r\n var probes = model.lights || [];\r\n this._nodeEnvironment.setLightProbes(probes);\r\n if (this.model.get(\"shadowEnable\")) {\r\n this.model.set(\"shadowEnable\", probes.length > 0)\r\n this._nodeEnvironment.setDefaultExposure(1 /*model.get(\"brightness\")*/);\r\n }\r\n if (isPBR) {\r\n this.setEnvironmentPBR(model, texturesPromises);\r\n } else {\r\n this.setEnvironmentOld(model, texturesPromises);\r\n // this.setProgress(texturesPromises.slice(), 'environment');\r\n }\r\n\r\n if (this.isBackgroundEnvironment())\r\n texturesPromises.push(this.setBackgroundTexture());\r\n return texturesPromises;\r\n }\r\n findTexture(textures, config) {\r\n return textures.find((texture) => {\r\n var match = true;\r\n if (config.encoding && texture.encoding !== config.encoding) {\r\n match = false;\r\n }\r\n if (config.type && texture.type !== config.type) {\r\n match = false;\r\n }\r\n if (config.format && texture.format !== config.format) {\r\n match = false;\r\n }\r\n return match;\r\n });\r\n }\r\n\r\n setEnvironmentPBR(model, texturesPromises) {\r\n var envNode = this._nodeEnvironment,\r\n envModelTextures = model.textures,\r\n textureLodSupported = false;\r\n if (osg.WebGLCaps.instance().getWebGLExtension('EXT_shader_texture_lod'))\r\n textureLodSupported = true;\r\n // textureLodSupported = false\r\n Config.panorama && (textureLodSupported = false);\r\n var textureModel = this.findTexture(envModelTextures, {\r\n encoding: 'luv',\r\n type: 'specular_ue4',\r\n format: textureLodSupported ? 'cubemap' : 'panorama',\r\n }),\r\n imageModel = this.getImageRes(textureModel),\r\n textureConfig = {\r\n cubemap: textureLodSupported,\r\n panoramaLUV: !textureLodSupported,\r\n cubemapLUV: textureLodSupported,\r\n size: imageModel.width,\r\n minFilter: textureLodSupported\r\n ? osg.Texture.LINEAR_MIPMAP_LINEAR\r\n : osg.Texture.LINEAR,\r\n magFilter: osg.Texture.LINEAR,\r\n wrapS: osg.Texture.CLAMP_TO_EDGE,\r\n wrapT: osg.Texture.CLAMP_TO_EDGE,\r\n transferToGPU: true,\r\n internalFormat: osg.Texture.RGBA,\r\n };\r\n var textureRes = ResourceManager.getInstance().getOrCreateTexture(imageModel.file, textureConfig);\r\n // this.markLastXHR(this.model.get(\"uid\")),\r\n textureRes.texture.setFlipY(!textureLodSupported)\r\n envNode.setSpecularPBRTexture(textureRes.texture, textureModel.limitSize);\r\n var texturePromise = this.getPromiseTexture(textureRes);\r\n texturePromise.then(\r\n envNode.setSpecularPBRTexture.bind(\r\n envNode,\r\n textureRes.texture,\r\n textureModel.limitSize,\r\n ) \r\n ).then(()=>{\r\n this._app._frameManager.draw()\r\n })\r\n texturesPromises.push(texturePromise);\r\n\r\n var maxUnit = MaxTextureUnit();\r\n if (maxUnit > 8) {\r\n var textureModel = this.findTexture(envModelTextures, {\r\n type: 'brdf_ue4',\r\n });\r\n imageModel = this.getImageRes(textureModel);\r\n textureConfig = {\r\n integrateBRDFLUV: true,\r\n minFilter: osg.Texture.NEAREST,\r\n magFilter: osg.Texture.NEAREST,\r\n wrapS: osg.Texture.CLAMP_TO_EDGE,\r\n wrapT: osg.Texture.CLAMP_TO_EDGE,\r\n transferToGPU: true,\r\n internalFormat: osg.Texture.RGBA,\r\n };\r\n\r\n var textureRes = ResourceManager.getInstance().getOrCreateTexture(imageModel.file, textureConfig);\r\n // this.markLastXHR(this.model.get(\"uid\")),\r\n textureRes.texture.setFlipY(false);\r\n envNode.setIntegrateBRDFTexture(textureRes.texture);\r\n var texturePromise = this.getPromiseTexture(textureRes);\r\n texturePromise.then(\r\n envNode.setIntegrateBRDFTexture.bind(envNode, textureRes.texture),\r\n );\r\n texturesPromises.push(texturePromise);\r\n }\r\n }\r\n getBackgroundResource(envModelTextures, options, blur) {\r\n var imageModel,\r\n textureModel = this.findTexture(envModelTextures, {\r\n encoding: 'luv',\r\n type: 'background',\r\n format: 'cubemap',\r\n });\r\n var imageModel = blur\r\n ? this.getClosestBlur(textureModel, blur)\r\n : this.getImageRes(textureModel, 512);\r\n options.cubemap = true;\r\n options.cubemapLUV = true;\r\n options.size = imageModel.width;\r\n options.minFilter = osg.Texture.LINEAR;\r\n options.magFilter = osg.Texture.LINEAR;\r\n options.wrapS = osg.Texture.CLAMP_TO_EDGE;\r\n options.wrapT = osg.Texture.CLAMP_TO_EDGE;\r\n options.transferToGPU = true;\r\n options.internalFormat = osg.Texture.RGBA;\r\n\r\n return imageModel;\r\n }\r\n setEnvironmentOld(e, t) {\r\n // var i = this._nodeEnvironment\r\n // , n = {}\r\n // , r = this.getBackgroundResource(e.get(\"textures\"), n)\r\n // , a = this.getResourceManager().getOrCreateTexture(r.file, n);\r\n // this.markLastXHR(this.model.get(\"uid\")),\r\n // this._onlyLowRes && i.setSpecularTexture(a.texture);\r\n // var o = this.getPromiseTexture(a);\r\n // o.then(i.setSpecularTexture.bind(i, a.texture)),\r\n // F.Z.resolveDataSizeEnvironment(r.sizeCompressed),\r\n // t.push(o)\r\n }\r\n setBackgroundTexture() {\r\n\r\n var envModel = this.getEnvironment();\r\n var options = {};\r\n var imageModel = this.getBackgroundResource(envModel[\"textures\"], options /*this.model.get(\"blur\")*/);\r\n var loadedBackground = this._backgroundLoaded;\r\n // if (this.getRequestLowRes()) {\r\n // if (n[i.file])\r\n // return n[i.file].promise;\r\n // i = this.getBackgroundResource(e.get(\"textures\"), t, 1)\r\n // }\r\n var nodeEnv = this._nodeEnvironment\r\n var res = ResourceManager.getInstance().getOrCreateTexture(imageModel.file, options);\r\n // this.markLastXHR(this.model.get(\"uid\"), 0.1 /*this.model.get(\"blur\")*/);\r\n var promise = this.getPromiseTexture(res);\r\n promise.then((function() {\r\n nodeEnv.setBackgroundTexture(res.texture, imageModel.width),\r\n loadedBackground[imageModel.file] = res\r\n }\r\n ))\r\n // this.setProgress(promise, \"background\"),\r\n return promise;\r\n }\r\n setProgress(e, t) {\r\n // var i = this._viewer.setFakeSecondaryProgress.bind(this._viewer, e, t);\r\n // F.Z.getHighResLoaded().then(i)\r\n }\r\n setBackgroundAmbient() {\r\n var envModel = this.getEnvironment();\r\n if (envModel) {\r\n this._nodeEnvironment.setDiffuseSPH(envModel.diffuseSPH);\r\n return CreatePromise().resolve();\r\n } else {\r\n return CreatePromise().reject(new Error());\r\n }\r\n }\r\n // markLastXHR(e, t) {\r\n // var i = this.getResourceManager()._resourceLoader._processing;\r\n // if (i.length > 0) {\r\n // var n = i[i.length - 1];\r\n // n._envUID = e,\r\n // void 0 === t || this.getRequestLowRes() || (n._envBlur = t)\r\n // }\r\n // }\r\n getPromiseTexture(textureRes) {\r\n return textureRes.promise;\r\n }\r\n // getRequestLowRes() {\r\n // return this._onlyLowRes && !(0,u.Z)().preload\r\n // }\r\n getImageRes(textureModel, Resolution) {\r\n //todo download\r\n return textureModel.images[0];\r\n // var i = new Oo.Z(textureModel);\r\n // if (this.getRequestLowRes())\r\n // return i.findImageSmallest();\r\n // var Resolution = void 0 !== Resolution ? Resolution : 1 / 0;\r\n // return i.findImageNearestPowerOfTwoUpToResolution(Resolution, Resolution)\r\n }\r\n getClosestBlur(textureModel, blur) {\r\n var images = textureModel.images;\r\n var level = 0;\r\n var maxSetp = 1 / 0;\r\n for (i = 0, length = images.length; i < length; ++i) {\r\n var step = Math.abs(images[i].blur - blur);\r\n if (step < maxSetp) {\r\n level = i;\r\n maxSetp = step;\r\n }\r\n }\r\n return images[level];\r\n }\r\n}\r\n","import osg from \"../../osg/osg\";\r\nimport { Model } from 'backbone'\r\nimport ResourceManager from '../ResourceManager';\r\n// import EventEmitter3 from 'EventEmitter3';\r\nexport default class Background {\r\n constructor(app) {\r\n this._app = app;\r\n this.model = new Model({\r\n \"enable\": \"color\",\r\n \"color\": [\r\n 0.93,\r\n 0.93,\r\n 0.93\r\n ],\r\n 'fixed': null//'http://editor-light.oss-cn-chengdu.aliyuncs.com/model/27fdde00-8b9c-11eb-8668-b36cbb09fada/27fdde01-8b9c-11eb-8668-b36cbb09fada/bb791e30-8b9f-11eb-a2a5-b33c96c065a2.jpeg'\r\n })\r\n this.model.bind(\"change:enable\", this.onEnableChanged, this)\r\n // this.model.bind(\"change:webVR\", this.onEnableChanged, this)\r\n this.model.bind(\"change:fixed\", this.onBackgroundChanged, this)\r\n this.model.bind(\"change\", this._app._frameManager.draw.bind(this._app._frameManager))\r\n var environmentFeature = app.getFeatures().environment;\r\n if (environmentFeature) {\r\n // this._resourceDefer = CreatePromise()\r\n // appviewer.getScene().addResourcePromise(this._resourceDefer.promise)\r\n this._modelEnvironment = environmentFeature.getModel()\r\n this._nodeBackground = environmentFeature\r\n .getNodeEnvironment()\r\n .getBackground();\r\n this._nodeBackground.addUpdateCallback(this);\r\n //F.Z.getMaterial().then(this.onEnableChanged.bind(this))\r\n this.onEnableChanged();\r\n this._viewer = app.getViewerOSGJS();\r\n }\r\n }\r\n\r\n getModel() {\r\n return this.model\r\n }\r\n getNode() {\r\n return this._nodeBackground;\r\n }\r\n getResourceManager() {\r\n return this._resourceManager || s.Z.instance;\r\n }\r\n onBackgroundChanged() {\r\n var url = this.model.get('fixed');\r\n if (url) {\r\n return this.getResources(url);\r\n }\r\n }\r\n\r\n getResources(url) {\r\n var option = {\r\n minFilter: osg.Texture.LINEAR,\r\n magFilter: osg.Texture.LINEAR,\r\n transferToGPU: true,\r\n convertNPOT: false,\r\n internalFormat: osg.Texture.RGB,\r\n };\r\n\r\n var textureRes = ResourceManager.getInstance().getOrCreateTexture(\r\n url,\r\n option,\r\n );\r\n textureRes.promise.then(() => {\r\n this._nodeBackground.setBackground(textureRes.texture)\r\n this._nodeBackground.rescale(this._viewWidth, this._viewHeight)\r\n this.model.trigger('backgroundUpdated', textureRes.texture)\r\n 'fixed' === this.model.get('enable') && this._nodeBackground.showBackground();\r\n this._app._frameManager.draw()\r\n });\r\n\r\n return textureRes.promise;\r\n }\r\n onEnableChanged() {\r\n var type = this.model.get('enable');\r\n 'color' === type\r\n ? this._nodeBackground.showColor()\r\n : 'fixed' === type\r\n ? this._nodeBackground.getBackground()\r\n ? this._nodeBackground.showBackground()\r\n : void 0 !== this.model.get('fixed') && this.onBackgroundChanged()\r\n : 'environment' === type\r\n ? (this._modelEnvironment.trigger('updateBackground'),\r\n this._nodeBackground.showEnvironment())\r\n : 'ambient' === type\r\n ? (this._modelEnvironment.trigger('updateBackground'),\r\n this._nodeBackground.showAmbient())\r\n : 'none' === type && this._nodeBackground.hide(),\r\n this._resourceDefer &&\r\n (this._resourceDefer.resolve(), (this._resourceDefer = void 0));\r\n }\r\n requireBiggerTexture() {\r\n\r\n return true;\r\n }\r\n update() {\r\n if (\"fixed\" !== this.model.get('enable'))\r\n return true;\r\n var e = this._viewer.getCamera().getViewport()\r\n , t = e.width()\r\n , i = e.height();\r\n return this._viewWidth === t && this._viewHeight === i || (this._viewWidth = t,\r\n this._viewHeight = i,\r\n true === this.requireBiggerTexture() && this.onBackgroundChanged(),\r\n this._nodeBackground.rescale(t, i)),\r\n true\r\n }\r\n\r\n}\r\n","let pixels = new Uint8Array(4 * 300 * 150) //default canvas size\r\nlet canvasSrc = document.createElement('canvas')\r\nlet canvasDSt = document.createElement('canvas')\r\n\r\nconst drawCallBack = function (state, width, height, canvas) {\r\n canvas || (canvas = canvasDSt)\r\n if (canvasSrc.width !== width || canvasSrc.height !== height) {\r\n canvas.width = width\r\n canvas.height = height\r\n canvasSrc.width = width\r\n canvasSrc.height = height\r\n pixels = new Uint8Array(4 * width * height)\r\n }\r\n \r\n const gl = state.getGraphicContext()\r\n if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE)\r\n return console.error('FRAMEBUFFER status invalid.')\r\n gl.flush()\r\n gl.finish()\r\n gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels)\r\n let contextSrc = canvasSrc.getContext('2d')\r\n let imageDataSrc = contextSrc.getImageData(0, 0, width, height)\r\n imageDataSrc.data.set(pixels), contextSrc.putImageData(imageDataSrc, 0, 0)\r\n var contextDst = canvas.getContext('2d')\r\n contextDst.clearRect(0, 0, width, height)\r\n contextDst.fillStyle = 'transparent'\r\n contextDst.fillRect(0, 0, width, height)\r\n contextDst.save()\r\n contextDst.globalCompositeOperation = 'copy'\r\n contextDst.scale(1, -1)\r\n contextDst.drawImage(canvasSrc, 0, 0, width, height, 0, -height, width, height)\r\n contextDst.restore()\r\n return canvas\r\n}\r\n\r\n\r\nconst drawFunc = function (osgViewer) {\r\n osgViewer.getScene().updateSceneGraph(osgViewer.getUpdateVisitor())\r\n const renderer = osgViewer.getCamera().getRenderer()\r\n renderer.cull(), renderer.draw()\r\n}\r\n\r\nexport default class ScreenShot {\r\n constructor() {}\r\n\r\n getScreenShot (width, height, app) {\r\n let superSample = app.getSuperSample()\r\n let osgViewer = app.getViewerOSGJS()\r\n if(!width || !height) {\r\n width = osgViewer.getCanvasWidth()\r\n height = osgViewer.getCanvasHeight()\r\n }\r\n let features = app.getFeatures()\r\n let camera = osgViewer.getCamera()\r\n let gizmo = app.getFeaturesManager().getNodeGizmo()\r\n let oldMask;\r\n if(gizmo && gizmo.getNodeMask) {\r\n oldMask = gizmo.getNodeMask()\r\n gizmo.setNodeMask(0)\r\n }\r\n\r\n for (var feature in features) {\r\n features[feature].prepareForScreenShot && features[feature].prepareForScreenShot()\r\n }\r\n \r\n app.getEventEmitter().trigger('resizeViewer', width, height)\r\n osgViewer.updateViewport()\r\n app._frameManager.setPoseForScreenshot(true)\r\n osgViewer.checkNeedToDoFrame()\r\n drawFunc(osgViewer)\r\n camera.setFinalDrawCallback(function (state) {\r\n superSample.isEnabled() || drawCallBack(state, width, height)\r\n })\r\n if (superSample.canBeEnabled()) {\r\n \r\n for (superSample.forceEnable(); superSample.isEnabled();) {\r\n superSample.updateFrame()\r\n drawFunc(osgViewer)\r\n }\r\n }\r\n else {\r\n drawFunc(osgViewer)\r\n }\r\n app._frameManager.setPoseForScreenshot(false)\r\n camera.setFinalDrawCallback()\r\n for (var feature in features) {\r\n features[feature].resetAfterScreenShot && features[feature].resetAfterScreenShot()\r\n }\r\n if(oldMask && gizmo){\r\n gizmo.setNodeMask(oldMask) \r\n }\r\n app.getEventEmitter().trigger('resizeViewerOnNextFrame', -1, -1)\r\n osgViewer.updateViewport()\r\n app.getFeatures().postProcess.canvasRatioModel.trigger('change:viewerToCanvasRatio')\r\n return canvasDSt\r\n }\r\n}\r\n\r\n\r\n\r\n","import { concat } from 'lodash'\r\nimport osg from '../osg/osg'\r\nimport StateAttribute from '../osg/StateAttribute'\r\nimport StateAttributeRegister from './StateAttributeRegister'\r\n\r\nexport default class StickerAttribute extends StateAttribute {\r\n constructor() {\r\n super()\r\n this._attributeEnable = false\r\n this._hitPoint = osg.vec3.create()\r\n this._hitNormal = osg.vec3.create()\r\n }\r\n\r\n getHash() {\r\n return this.getType() + (this.isEnabled ? 1 : 0) + this._feature._stickers.length\r\n }\r\n\r\n cloneType() {\r\n return new StickerAttribute()\r\n }\r\n\r\n setEnabled(enable) {\r\n this._attributeEnable = enable\r\n }\r\n\r\n isEnabled() {\r\n return this._attributeEnable\r\n }\r\n\r\n getOrCreateUniforms() {\r\n const attribute = StickerAttribute\r\n\r\n const stNum = this._feature._stickers.length\r\n if (attribute.uniforms[stNum]) return attribute.uniforms[stNum]\r\n\r\n const uniformMap = attribute.uniforms[stNum] = {}\r\n\r\n uniformMap['uHighlight'] = osg.Uniform.createFloatArray('uHighlight', stNum)\r\n uniformMap['uMat'] = osg.Uniform.createMat3Array('uMat', stNum)\r\n uniformMap['uT'] = osg.Uniform.createMat4Array('uT', stNum)\r\n uniformMap['uBoundSphere'] = osg.Uniform.createFloat4Array('uBoundSphere', stNum)\r\n uniformMap['uPos'] = osg.Uniform.createFloat3Array('uPos', stNum)\r\n uniformMap['uNormal'] = osg.Uniform.createFloat3Array('uNormal', stNum)\r\n uniformMap['uVisible'] = osg.Uniform.createFloatArray('uVisible', stNum)\r\n\r\n uniformMap['uAnchors'] = osg.Uniform.createFloatArray('uAnchors', 8)\r\n return uniformMap\r\n }\r\n\r\n\r\n apply() {\r\n if (!this.isEnabled() || this._feature._stickers.length == 0) return\r\n const uniformMap = this.getOrCreateUniforms()\r\n\r\n this._feature._stickers.forEach((s, i) => { \r\n \r\n let data = uniformMap['uHighlight']._data \r\n const highlight = s.getHighlight()\r\n if (highlight) uniformMap['uAnchors']._data.set(s._anchors.flat(1))\r\n data.set([highlight ? 1 : 0], i)\r\n\r\n data = uniformMap['uMat']._data \r\n data.set(s.getInvTransform(), i * 9)\r\n\r\n data = uniformMap['uT']._data \r\n data.set(s.getInvQuatMat(), i * 16) \r\n \r\n data = uniformMap['uBoundSphere']._data \r\n const bs = s.getBoundingSphere() \r\n data.set([...bs.center(), bs.radius()], i * 4)\r\n\r\n data = uniformMap['uPos']._data\r\n data.set(s.getWorldPos(), i * 3)\r\n\r\n data = uniformMap['uNormal']._data \r\n data.set(s.getWorldNormal(), i * 3)\r\n\r\n data = uniformMap['uVisible']._data\r\n data.set([s.getVisible() ? 1.0 : 0.0], i)\r\n })\r\n\r\n \r\n }\r\n}\r\n\r\nStickerAttribute.uniforms = {}\r\n\r\nStateAttributeRegister(StickerAttribute, StickerAttribute.prototype, 'osgEditor', 'StickerAttribute')\r\n","import osg from '../../osg/osg'\r\nimport StickerAttribute from '../StickerAttribute'\r\nimport MaterialUtils from '../material/MaterialUtils'\r\nimport ResourceManager from '../ResourceManager'\r\nimport lodash, { takeRightWhile } from 'lodash'\r\n\r\nlet tempWorldPosition = osg.vec3.create()\r\nlet tempWorldNormal = osg.vec3.create()\r\nlet tempN = osg.vec3.create()\r\nlet tempVec2 = osg.vec2.create()\r\nlet tempBoundingSphere = new osg.BoundingSphere()\r\nlet tempMat3 = osg.mat3.create()\r\n// const uBoundingSphere = osg.Uniform.createFloat4('uBoundSphere')\r\n\r\nclass Sticker {\r\n constructor(id, texture, [ref0, ref1], gbp) {\r\n this._state = 'idle'\r\n this._visible = true\r\n this._id = id\r\n this._highlight = false\r\n this._invTransform = osg.mat3.create()\r\n this._invQuatMat = osg.mat4.create()\r\n this._texture = texture\r\n this._originalImage = texture.getImage().getImage()\r\n this._boundingSphere = new osg.BoundingSphere()\r\n this._globalBoundingSphere = new osg.BoundingSphere()\r\n this._globalBoundingSphere.copy(gbp)\r\n this._scale = [1, 1]\r\n this._mirror = [1.0, 1.0]\r\n this._rotation = 0\r\n this._worldPos = osg.vec3.create()\r\n this._worldNormal = osg.vec3.create()\r\n this._anchors = [\r\n [0, 1],\r\n [1, 1],\r\n [1, 0],\r\n [0, 0]\r\n ]\r\n this._ref0 = osg.vec3.copy(osg.vec3.create(), ref0)\r\n this._ref1 = osg.vec3.copy(osg.vec3.create(), ref1)\r\n this._useGBP = false\r\n this._dirty = true\r\n this._canvas = document.createElement('canvas')\r\n }\r\n\r\n toJson() {\r\n const invTransform = this.getInvTransform()\r\n const invQuatMat = this.getInvQuatMat()\r\n const boundingSphere = this.getBoundingSphere()\r\n const worldPos = this.getWorldPos()\r\n const worldNormal = this.getWorldNormal()\r\n return {\r\n config: {\r\n boundingSphere: [...boundingSphere.center(), boundingSphere.radius()],\r\n invTransform,\r\n invQuatMat,\r\n worldPos,\r\n worldNormal,\r\n anchors: this._anchors,\r\n ref0: this._ref0,\r\n ref1: this._ref1 \r\n },\r\n id: this._id,\r\n visible: this._visible,\r\n img: this._originalImage.src,\r\n scale: this.getScale(),\r\n mirror: this.getMirror(),\r\n rotation: this.getRotation()\r\n }\r\n }\r\n\r\n fromJson(json) {\r\n const renderData = json.config\r\n const bs = renderData.boundingSphere\r\n this._boundingSphere.set((bs[0], bs[1], bs[2]), bs[3])\r\n\r\n osg.mat3.copy(this._invTransform, renderData.invTransform)\r\n osg.mat4.copy(this._invQuatMat, renderData.invQuatMat)\r\n osg.vec3.copy(this._worldPos, renderData.worldPos)\r\n osg.vec3.copy(this._worldNormal, renderData.worldNormal)\r\n\r\n this._anchors = lodash.cloneDeep(renderData.anchors)\r\n this._renderWithAnchor(1)\r\n\r\n osg.vec2.copy(this._ref0, renderData.ref0)\r\n osg.vec2.copy(this._ref1, renderData.ref1)\r\n\r\n osg.vec2.copy(this._scale, json.scale)\r\n osg.vec2.copy(this._mirror, json.mirror)\r\n this._rotation = json.rotation\r\n\r\n this._dirty = false\r\n this._visible = json.visible\r\n }\r\n\r\n getVisible() {\r\n return this._visible\r\n }\r\n\r\n setVisible(flag) {\r\n this._visible = flag\r\n }\r\n\r\n setAnchors(anchors) {\r\n this._anchors = anchors\r\n }\r\n\r\n ref0() {\r\n return this._ref0\r\n }\r\n\r\n ref1() {\r\n return this._ref1\r\n }\r\n\r\n getScale() {\r\n return osg.vec2.clone(this._scale)\r\n }\r\n\r\n setScale(scale) {\r\n osg.vec2.copy(this._scale, scale)\r\n this._dirty = true\r\n }\r\n\r\n getMirror() {\r\n return osg.vec2.clone(this._mirror)\r\n }\r\n\r\n setMirror(mirror) {\r\n osg.vec2.copy(this._mirror, mirror)\r\n this._dirty = true\r\n }\r\n\r\n getRotation() {\r\n return this._rotation\r\n }\r\n\r\n setRotation(rotation) {\r\n this._rotation = rotation\r\n this._dirty = true\r\n }\r\n\r\n get state() {\r\n return this._state\r\n }\r\n\r\n set state(state) {\r\n this._state = state\r\n }\r\n\r\n getHighlight() {\r\n return this._highlight\r\n }\r\n\r\n getBoundingSphere() {\r\n if (this._useGBP) return this._globalBoundingSphere\r\n const a = this.ref0() //[0, -10, 10]\r\n const b = this.ref1() //[0, 141, 100]\r\n\r\n const dir = osg.vec3.create()\r\n osg.vec3.sub(dir, b, a)\r\n osg.vec3.normalize(dir, dir)\r\n\r\n const p = this._worldPos\r\n let pt\r\n\r\n const dot = osg.vec3.dot(osg.vec3.subtract(osg.vec3.create(), p, a), dir)\r\n if (dot < 0) {\r\n pt = a\r\n } else {\r\n let d = Math.abs(dot)\r\n if (d > osg.vec3.distance(a, b)) {\r\n pt = b\r\n } else {\r\n pt = osg.vec3.scaleAndAdd(osg.vec3.create(), a, dir, d)\r\n }\r\n }\r\n\r\n //this._boundingSphere.copy(bs.sort( (a, b) => {return osg.vec3.distance(this._worldPos, a.center()) - osg.vec3.distance(this._worldPos, b.center())} )[0])\r\n const r = osg.vec3.distance(pt, p)\r\n // uBoundingSphere.setFloat4([...pt, r])\r\n this._boundingSphere.set(pt, r)\r\n\r\n return this._boundingSphere\r\n }\r\n\r\n setBoundingSphere(bs) {\r\n this._boundingSphere.copy(bs)\r\n }\r\n\r\n setHighlight(highlight) {\r\n this._highlight = highlight\r\n }\r\n\r\n getInvTransform() {\r\n return this.updateInvTransform()\r\n }\r\n\r\n _getDynamicScale() {\r\n return (\r\n 40 /\r\n osg.vec3.length(\r\n osg.vec3.subtract(\r\n tempWorldPosition,\r\n this._worldPos,\r\n this.getBoundingSphere().center()\r\n )\r\n )\r\n )\r\n }\r\n\r\n updateInvTransform() {\r\n if (!this._dirty) return this._invTransform\r\n this._dirty = true\r\n let [sx, sy] = this._scale\r\n let mirror = this._mirror\r\n let mapAspectX = 1\r\n let mapAspectY = 1\r\n if (this._originalImage) {\r\n let mapWidth = this._originalImage.width\r\n let mapHeight = this._originalImage.height\r\n if (mapWidth > mapHeight) {\r\n mapAspectY = mapHeight / mapWidth\r\n } else {\r\n mapAspectX = mapWidth / mapHeight\r\n }\r\n }\r\n let dynamicScale = this._getDynamicScale()\r\n sx *= mirror[0] * mapAspectX * dynamicScale\r\n sy *= mirror[1] * mapAspectY * dynamicScale\r\n let rotation = (this._rotation * Math.PI) / 180\r\n osg.mat3.identity(this._invTransform)\r\n osg.mat3.translate(this._invTransform, this._invTransform, [0, Math.PI * 0.5])\r\n osg.mat3.rotate(this._invTransform, this._invTransform, rotation)\r\n osg.mat3.scale(this._invTransform, this._invTransform, [sx, sy])\r\n osg.mat3.translate(this._invTransform, this._invTransform, [-0.5, -0.5])\r\n osg.mat3.invert(this._invTransform, this._invTransform)\r\n return this._invTransform\r\n }\r\n\r\n getInvQuatMat() {\r\n return this._invQuatMat\r\n }\r\n\r\n getWorldPos() {\r\n return this._worldPos\r\n }\r\n\r\n getWorldNormal() {\r\n return this._worldNormal\r\n }\r\n\r\n rotationTo = (function () {\r\n var tmpvec3 = osg.vec3.create()\r\n var xUnitVec3 = osg.vec3.fromValues(1, 0, 0)\r\n var yUnitVec3 = osg.vec3.fromValues(0, -1, 0)\r\n\r\n return function (out, a, b) {\r\n var dot = osg.vec3.dot(a, b)\r\n //console.log(dot)\r\n if (dot < -0.999999) {\r\n osg.vec3.cross(tmpvec3, xUnitVec3, a)\r\n if (osg.vec3.length(tmpvec3) < 0.000001) osg.vec3.cross(tmpvec3, yUnitVec3, a)\r\n osg.vec3.normalize(tmpvec3, tmpvec3)\r\n osg.quat.setAxisAngle(out, tmpvec3, Math.PI)\r\n return out\r\n } else if (dot > 0.999999) {\r\n out[0] = 0\r\n out[1] = 0\r\n out[2] = 0\r\n out[3] = 1\r\n return out\r\n } else {\r\n osg.vec3.cross(tmpvec3, a, b)\r\n out[0] = tmpvec3[0]\r\n out[1] = tmpvec3[1]\r\n out[2] = tmpvec3[2]\r\n out[3] = 1 + dot\r\n return osg.quat.normalize(out, out)\r\n }\r\n }\r\n })()\r\n\r\n updatePosition(worldPos, worldNormal) {\r\n osg.vec3.copy(this._worldPos, worldPos)\r\n osg.vec3.copy(this._worldNormal, worldNormal)\r\n osg.vec3.subtract(tempN, worldPos, this.getBoundingSphere().center())\r\n osg.vec3.normalize(tempN, tempN)\r\n let quatFromXtoTarget = osg.quat.create()\r\n const zaxis = osg.vec3.fromValues(0, 0, 1)\r\n const axis = osg.vec3.fromValues(1, 0, 0)\r\n let cross1 = osg.vec3.cross(osg.vec3.create(), tempN, zaxis)\r\n let cross2 = osg.vec3.cross(osg.vec3.create(), axis, cross1)\r\n\r\n // console.log(osg.vec3.cross(osg.vec3.create(), [1, 0, 0], tempN)) //osg.vec3.normalize(osg.vec3.create(), [-1, 0.01, 0])))\r\n //console.log(cross)\r\n //console.log(111111, cross[1])\r\n //console.log(222222, osg.vec3.normalize(cross, cross)[1])\r\n\r\n let projectXY = osg.vec3.fromValues(tempN[0], tempN[1], 0)\r\n osg.vec3.normalize(projectXY, projectXY)\r\n\r\n this.rotationTo(quatFromXtoTarget, axis, projectXY)\r\n let turnup = this.rotationTo(osg.quat.create(), projectXY, tempN)\r\n osg.quat.multiply(quatFromXtoTarget, turnup, quatFromXtoTarget)\r\n\r\n let dot = osg.vec3.dot(axis, tempN)\r\n let angle = Math.acos(dot)\r\n if (cross2[2] < 0) {\r\n angle = Math.PI * 2.0 - angle\r\n osg.vec3.negate(cross2, cross2)\r\n }\r\n\r\n //osg.quat.setAxisAngle(quatFromXtoTarget, cross2, angle)\r\n //this.rotationTo(quatFromXtoTarget, osg.vec3.normalize(axis, axis), tempN)\r\n\r\n osg.mat4.fromQuat(this._invQuatMat, quatFromXtoTarget)\r\n osg.mat4.invert(this._invQuatMat, this._invQuatMat)\r\n\r\n this.updateInvTransform() // dynamic scale\r\n }\r\n\r\n getUV(uv, n) {\r\n osg.vec3.normalize(n, n)\r\n uv[0] = Math.atan2(n[1], n[0])\r\n uv[1] = Math.PI - Math.acos(n[2])\r\n return uv\r\n }\r\n\r\n transferToUVSpace(pos) {\r\n let boundingSphere = this.getBoundingSphere()\r\n let d = osg.vec3.subtract(osg.vec3.create(), pos, boundingSphere.center())\r\n let n = osg.vec3.transformMat4(d, d, this._invQuatMat)\r\n this.getUV(tempVec2, n)\r\n osg.vec2.transformMat3(tempVec2, tempVec2, this._invTransform)\r\n return tempVec2\r\n }\r\n\r\n selectAndActiveAnchor(pos) {\r\n let uv = this.transferToUVSpace(pos)\r\n let temp = osg.vec2.create()\r\n const index = this._anchors.findIndex(\r\n (offset) => osg.vec2.length(osg.vec2.sub(temp, uv, offset)) < 0.08\r\n )\r\n this._activeAnchor = index\r\n return this._activeAnchor\r\n }\r\n\r\n render(step = 1) {\r\n const img = this._originalImage\r\n const corners = this._corners\r\n let lerp = (p1, p2, t) => {\r\n return [p1[0] + (p2[0] - p1[0]) * t, p1[1] + (p2[1] - p1[1]) * t]\r\n }\r\n\r\n var p1,\r\n p2,\r\n p3,\r\n p4,\r\n y1c,\r\n y2c,\r\n y1n,\r\n y2n,\r\n w = img.width - 1,\r\n h = img.height - 1\r\n\r\n const c = this._canvas\r\n c.width = w\r\n c.height = h\r\n let ctx = c.getContext('2d')\r\n ctx.clearRect(0, 0, c.width, c.height)\r\n for (let y = 0; y < h; y += step) {\r\n for (let x = 0; x < w; x += step) {\r\n y1c = lerp(corners[0], corners[3], y / h)\r\n y2c = lerp(corners[1], corners[2], y / h)\r\n y1n = lerp(corners[0], corners[3], (y + step) / h)\r\n y2n = lerp(corners[1], corners[2], (y + step) / h)\r\n\r\n p1 = lerp(y1c, y2c, x / w)\r\n p2 = lerp(y1c, y2c, (x + step) / w)\r\n p3 = lerp(y1n, y2n, (x + step) / w)\r\n p4 = lerp(y1n, y2n, x / w)\r\n\r\n ctx.drawImage(\r\n img,\r\n x,\r\n y,\r\n step,\r\n step,\r\n p1[0],\r\n p1[1],\r\n Math.ceil(Math.max(step, Math.abs(p2[0] - p1[0]), Math.abs(p4[0] - p3[0]))) + 1,\r\n Math.ceil(Math.max(step, Math.abs(p1[1] - p4[1]), Math.abs(p2[1] - p3[1]))) + 1\r\n )\r\n }\r\n }\r\n this._texture.setImage(c)\r\n }\r\n\r\n _renderWithAnchor(step) {\r\n // just left bottom\r\n let w = this._texture.getWidth()\r\n let h = this._texture.getHeight()\r\n\r\n this._corners = this._anchors.map((anchor) => [anchor[0] * w, (1 - anchor[1]) * h])\r\n\r\n /*\r\n // bl\r\n x *= w\r\n y = h * (1 - y)\r\n \r\n this._corners = [\r\n { x: 0, y: 0 }, // upper left\r\n { x: w, y: 0 }, // upper right\r\n { x: w, y: h }, // bottom right\r\n { x: x, y: y } // bottom left\r\n ] \r\n */\r\n this.render(step)\r\n }\r\n\r\n updateAnchor(pos, step = 1) {\r\n if (this._activeAnchor == -1) return\r\n let [x, y] = this.transferToUVSpace(pos)\r\n osg.vec2.copy(this._anchors[this._activeAnchor], [x, y])\r\n\r\n this._renderWithAnchor(step)\r\n }\r\n}\r\nconst MAX_STICKERS_NUM = 4\r\n\r\nexport default class StickerFeature {\r\n constructor(app) {\r\n this._app = app\r\n this._app._featureEventManager.initSticker(this)\r\n this._previousDraggingPoint = osg.vec3.create()\r\n\r\n this._stickerTextures = []\r\n\r\n /*\r\n */\r\n\r\n //this._stickerTextures = [new osg.Texture(), new osg.Texture(), new osg.Texture(), new osg.Texture()]\r\n\r\n this._stickerAttribute = new StickerAttribute()\r\n this._stickerAttribute.setEnabled(true)\r\n\r\n this._app.getRootModel().getOrCreateStateSet().setAttributeAndModes(this._stickerAttribute)\r\n\r\n //this._uCornerUV = osg.Uniform.createFloat2Array('uCornerUV')\r\n //this._app.getRootModel().getOrCreateStateSet().addUniform(this._uCornerUV)\r\n\r\n this._uHighlight = osg.Uniform.createFloat('uHighlight')\r\n // this._app.getRootModel().getOrCreateStateSet().addUniform(this._uHighlight)\r\n\r\n this._boundingSphere = new osg.BoundingSphere()\r\n\r\n // this._app.getRootModel().getOrCreateStateSet().addUniform(uBoundingSphere)\r\n\r\n this._uMat = osg.Uniform.createMat3('uMat')\r\n //this._app.getRootModel().getOrCreateStateSet().addUniform(this._uMat)\r\n\r\n this._uT = osg.Uniform.createMat4('uT')\r\n //this._app.getRootModel().getOrCreateStateSet().addUniform(this._uT)\r\n\r\n this._invTransform = osg.mat3.create()\r\n this._invQuatMat = osg.mat4.create()\r\n\r\n this._selected = false\r\n\r\n this._enable = true\r\n\r\n this._stickers = []\r\n\r\n this._stickerAttribute._feature = this\r\n this._activeSticker = null\r\n this._maximumSelectedNum = 1\r\n this._setupStickersByModelsBound = this.setup.bind(this)\r\n }\r\n\r\n setHighlight(enable) {\r\n this._uHighlight.setFloat(enable ? 1.0 : 0.0)\r\n }\r\n\r\n calculateReferPoints() {\r\n const box = this._app.getRootModel().getBoundingBox()\r\n const yw = box.yMax() - box.yMin()\r\n const xw = box.xMax() - box.xMin()\r\n const zw = box.zMax() - box.zMin()\r\n const startPt = osg.vec3.create()\r\n const endPt = osg.vec3.create()\r\n startPt.set([0, 0 - yw * 0.05, yw / 10])\r\n endPt.set([0, 0 + yw * 0.4, box.zMin() + zw - yw * 0.3])\r\n\r\n //const a = this.ref0() //[0, -10, 10]\r\n //const b = this.ref1() //[0, 141, 100]\r\n\r\n return [startPt, endPt]\r\n }\r\n\r\n setup(json) {\r\n const images = json.map((data) => data.img.url)\r\n const imagesP = images.map((img) => ResourceManager.getInstance().loadImage(img, {}))\r\n Promise.all(imagesP).then((images) => {\r\n this._stickers = images.map((img, idx) => {\r\n const j = json[idx]\r\n const config = j.config\r\n const texture = this._createTexture()\r\n texture.setImage(img)\r\n const sticker = new Sticker(\r\n j.id,\r\n texture,\r\n [config.ref0, config.ref1],\r\n this._app.getRootModel().getBoundingSphere()\r\n )\r\n sticker.fromJson(j)\r\n return sticker\r\n })\r\n this._updateStickerSlot()\r\n })\r\n }\r\n\r\n isInUnitSquare([x, y]) {\r\n return 0.0 <= x && x <= 1.0 && 0.0 <= y && y <= 1.0\r\n }\r\n\r\n pick(x, y, worldPosition, worldNormal) {\r\n const hit = this._app.pick(x, y, () => {}, true)\r\n if (!hit) return false\r\n\r\n const worldT = osg.computeLocalToWorld(hit._nodePath)\r\n osg.mat3.normalFromMat4(tempMat3, worldT)\r\n osg.vec3.transformMat4(worldPosition, hit._localIntersectionPoint, worldT)\r\n osg.vec3.transformMat3(worldNormal, hit._localIntersectionNormal, tempMat3)\r\n return true\r\n }\r\n\r\n getStickers() {\r\n return this._stickers\r\n }\r\n\r\n getStickerById(id) {\r\n return this._stickers.find((sticker) => sticker._id == id)\r\n }\r\n\r\n removeSticker(id) {\r\n const index = this._stickers.findIndex((d) => d._id === id)\r\n if (index > -1) {\r\n this._stickers.splice(index, 1)\r\n this._updateStickerSlot()\r\n return true\r\n }\r\n return false\r\n }\r\n\r\n _createTexture() {\r\n let option = {\r\n minFilter: osg.Texture.LINEAR,\r\n magFilter: osg.Texture.LINEAR,\r\n internalFormat: osg.Texture.RGBA\r\n }\r\n const texture = new osg.Texture()\r\n texture.setMinFilter(option.minFilter)\r\n texture.setMagFilter(option.magFilter)\r\n if (option.minFilter === osg.Texture.LINEAR_MIPMAP_LINEAR && option.anisotropy)\r\n texture.setMaxAnisotropy(16)\r\n texture.setInternalFormat(option.internalFormat)\r\n return texture\r\n }\r\n\r\n _updateStickerSlot() {\r\n for (let i = 0; i < this._stickers.length; i++) {\r\n const texture = this._stickers[i]._texture\r\n this._app\r\n .getRootModel()\r\n .getOrCreateStateSet()\r\n .setTextureAttributeAndModes(MaterialUtils.STICKER_TEXTURE_UNIT + i, texture)\r\n }\r\n }\r\n\r\n updateStickerPosition(sticker, x, y) {\r\n const worldPos = osg.vec3.create()\r\n const worldNormal = osg.vec3.create()\r\n const hit = this.pick(x, y, worldPos, worldNormal)\r\n if (!hit) return false \r\n sticker.updatePosition(worldPos, worldNormal)\r\n return true\r\n }\r\n\r\n addSticker({ id, img, x, y }) {\r\n if (this._stickers.length >= MAX_STICKERS_NUM) return\r\n\r\n const worldPos = osg.vec3.create()\r\n const worldNormal = osg.vec3.create()\r\n const hit = this.pick(x, y, worldPos, worldNormal)\r\n if (!hit) return false \r\n\r\n const check = this.getStickerById(id)\r\n if (check) {\r\n console.error('existed sticker id')\r\n return false\r\n }\r\n ResourceManager.getInstance()\r\n .loadImage(img, {})\r\n .then((img) => {\r\n const texture = this._createTexture()\r\n texture.setImage(img)\r\n const sticker = new Sticker(\r\n id,\r\n texture,\r\n this.calculateReferPoints(),\r\n this._app.getRootModel().getBoundingSphere()\r\n )\r\n sticker.updatePosition(worldPos, worldNormal)\r\n this._stickers.push(sticker)\r\n this._updateStickerSlot()\r\n this._app.redraw() \r\n })\r\n\r\n return true\r\n }\r\n\r\n doubleclick(event) {\r\n return\r\n const img =\r\n Math.random() < 0.5\r\n ? 'http://192.168.110.33:8080/logo.png'\r\n : 'http://192.168.110.33:8080/logo1.png'\r\n this.addSticker({\r\n id: Date().toString(),\r\n img: img,\r\n x: event.canvasX,\r\n y: event.canvasY\r\n })\r\n }\r\n\r\n hitStickersByPos(worldPos) {\r\n const stickers = []\r\n for (let i = 0; i < this._stickers.length; i++) {\r\n const sticker = this._stickers[i]\r\n const uv = sticker.transferToUVSpace(worldPos)\r\n if (this.isInUnitSquare(uv)) {\r\n stickers.push(sticker)\r\n }\r\n }\r\n return stickers\r\n }\r\n\r\n setActiveSticker(sticker) {\r\n if (sticker && !sticker.getVisible()) return\r\n this._activeSticker && this._activeSticker.setHighlight(false)\r\n this._activeSticker = sticker\r\n this._activeSticker && sticker.setHighlight(true)\r\n this._app.emit('StickerFeature:ActiveSticker', sticker ? sticker._id : null)\r\n this._app.redraw()\r\n }\r\n\r\n singleclick(event, delta) {\r\n const hit = this.pick(\r\n event.canvasX,\r\n event.canvasY,\r\n tempWorldPosition,\r\n tempWorldNormal,\r\n tempN\r\n ) \r\n if (!hit) {\r\n this.setActiveSticker(null)\r\n } else { \r\n const stickers = this.hitStickersByPos(tempWorldPosition)\r\n if (stickers.length > 0) {\r\n this.setActiveSticker(stickers[0])\r\n }\r\n }\r\n this._app.redraw()\r\n }\r\n\r\n mousedown(event) {\r\n if (!this._enable || !this._activeSticker) return\r\n\r\n const hit = this.pick(\r\n event.canvasX,\r\n event.canvasY,\r\n tempWorldPosition,\r\n tempWorldNormal,\r\n tempN\r\n )\r\n if (!hit) {\r\n return\r\n }\r\n\r\n const archerIndex = this._activeSticker.selectAndActiveAnchor(tempWorldPosition)\r\n\r\n if (archerIndex > -1) {\r\n this._activeSticker.state = 'dragging_anchor'\r\n } else {\r\n const stickers = this.hitStickersByPos(tempWorldPosition)\r\n if (stickers.indexOf(this._activeSticker) == -1) return\r\n this._activeSticker.state = 'dragging'\r\n }\r\n\r\n this.enableManipulator(false)\r\n\r\n osg.vec3.copy(this._previousDraggingPoint, tempWorldPosition)\r\n }\r\n\r\n mouseup(event, delta) {\r\n if (this._activeSticker && this._activeSticker.state.indexOf('dragging') > -1) {\r\n if (this._activeSticker.state == 'dragging_anchor') {\r\n this._activeSticker.render(1)\r\n }\r\n this._activeSticker.state = 'idle'\r\n this.enableManipulator(true)\r\n this._app.redraw()\r\n }\r\n }\r\n\r\n enableManipulator(enable) {\r\n const manipulator = this._app?._switchManipulator\r\n manipulator.getCurrentManipulator().setEnable(enable)\r\n }\r\n\r\n mousemove(event, delta) {\r\n if (!this._activeSticker || this._activeSticker.state == 'idle') return\r\n\r\n const hit = this.pick(\r\n event.canvasX,\r\n event.canvasY,\r\n tempWorldPosition,\r\n tempWorldNormal\r\n )\r\n if (!hit) return\r\n\r\n if (this._activeSticker.state == 'dragging')\r\n this._activeSticker.updatePosition(tempWorldPosition, tempWorldNormal)\r\n else if (this._activeSticker.state == 'dragging_anchor') {\r\n this._app.emit('StickerFeature:DraggingAnchor', this._activeSticker._id)\r\n this._activeSticker.updateAnchor(tempWorldPosition, 8)\r\n this._app.redraw()\r\n }\r\n this._app.redraw()\r\n }\r\n}\r\n","import { vec3 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\n\r\nimport Target from './target';\r\nimport channelType from './channelType';\r\n\r\nvar Channel = {};\r\n\r\n// channel {\r\n// keys: [],\r\n// times: [],\r\n// type: enum,\r\n// target: targetName\r\n// }\r\n// init a channel with extra field\r\n// start, end, duration\r\nvar initChannel = function(type, keys, times, targetName, channelName, channel) {\r\n var start = times[0];\r\n var end = times[times.length - 1];\r\n channel.start = start;\r\n channel.keys = keys;\r\n channel.end = end;\r\n channel.times = times;\r\n channel.type = type;\r\n channel.duration = end - start;\r\n channel.target = targetName;\r\n channel.name = channelName;\r\n return channel;\r\n};\r\n\r\nvar createVec3Channel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(channelType.Vec3, keys, times, targetName, channelName, chan || {});\r\n};\r\n\r\nvar createFloatChannel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(channelType.Float, keys, times, targetName, channelName, chan || {});\r\n};\r\n\r\nvar createQuatChannel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(channelType.Quat, keys, times, targetName, channelName, chan || {});\r\n};\r\n\r\nvar createQuatSlerpChannel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(channelType.QuatSlerp, keys, times, targetName, channelName, chan || {});\r\n};\r\n\r\nvar createFloatCubicBezierChannel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(\r\n channelType.FloatCubicBezier,\r\n keys,\r\n times,\r\n targetName,\r\n channelName,\r\n chan || {}\r\n );\r\n};\r\n\r\nvar createVec3CubicBezierChannel = function(keys, times, targetName, channelName, chan) {\r\n return initChannel(\r\n channelType.Vec3CubicBezier,\r\n keys,\r\n times,\r\n targetName,\r\n channelName,\r\n chan || {}\r\n );\r\n};\r\n\r\n// channel contains {\r\n// keys: [],\r\n// times: [],\r\n// start: 0.0,\r\n// end: 1.0,\r\n// }\r\n// return {\r\n// channel: channel,\r\n// value: vec3.create(),\r\n// targetID: int,\r\n// key: 0,\r\n// t: 0, //global start time\r\n// }\r\n\r\nvar Float = {\r\n create: function() {\r\n return 0;\r\n }\r\n};\r\nvar Vec3 = {\r\n create: function() {\r\n return vec3.create32();\r\n }\r\n};\r\nvar Quat = {\r\n create: function() {\r\n return quat.create32();\r\n }\r\n};\r\n\r\nvar createInstanceChannelType = function(operator, channel) {\r\n return {\r\n channel: channel,\r\n value: operator.create(),\r\n targetID: Target.InvalidTargetID,\r\n weight: 1.0,\r\n key: 0,\r\n start: 0.0,\r\n end: 0.0\r\n };\r\n};\r\n\r\nvar createInstanceVec3Channel = function(channel) {\r\n return createInstanceChannelType(Vec3, channel);\r\n};\r\n\r\nvar createInstanceQuatChannel = function(channel) {\r\n return createInstanceChannelType(Quat, channel);\r\n};\r\n\r\nvar createInstanceFloatChannel = function(channel) {\r\n return createInstanceChannelType(Float, channel);\r\n};\r\n\r\nvar createInstanceFloatCubicBezierChannel = function(channel) {\r\n return createInstanceChannelType(Float, channel);\r\n};\r\n\r\nvar createInstanceVec3CubicBezierChannel = function(channel) {\r\n return createInstanceChannelType(Vec3, channel);\r\n};\r\n\r\n// create an instance channel from type\r\nvar createInstanceChannel = function(channel) {\r\n return Channel[channel.type](channel);\r\n};\r\n\r\n// animations instances\r\n/*\r\n\r\n |-----------------| anim0 (channel0_0, channel0_1 )\r\n |--------------| anim1 (channel1_0, channel1_1, channel1_2 )\r\n\r\n // si triage a cause de la priorité\r\n // iterate on priority\r\n // and for animations of the same priority\r\n\r\n\r\n // init d'une animation\r\n\r\n // init du manager\r\n // createInstanceAnimation pour chaque animations\r\n // createInstanceChannels pour chaque animation\r\n\r\n // initChannelTargetID pour toute les animations du manager\r\n // id -> targetName\r\n\r\n\r\n // get target for an animation to push on target list ( to blend )\r\n var targets = {};\r\n for ( var i = 0 ; i < channels.length; i++ ) {\r\n var target = channels[i].target;\r\n targets[target].push( channels[i] );\r\n }\r\n\r\n\r\n // pour l'instant on ignore les pb d'organisation de priorité\r\n //\r\n // target X : [\r\n // ChannelAnima0_0\r\n // ChannelAnima1_0\r\n // ]\r\n\r\n // target Y : [\r\n // ChannelAnima0_1\r\n // ChannelAnima1_1\r\n // ]\r\n\r\n\r\n */\r\n\r\n// for a target compute each channel contribution\r\n// channel0, value0, w, priority0\r\n// channel1, value1, w, priority0\r\n// channel2, value2, w, priority0\r\n\r\n// channel0, value0, w, priority1\r\n// channel1, value1, w, priority1\r\n// channel2, value2, w, priority1\r\n\r\n/*\r\n\r\n var value;\r\n Copy( channels[0].value, value );\r\n var weight = 0.0;\r\n var priority = channels[0].priority;\r\n var priorityWeight = channels[0].weight;\r\n\r\n for ( var i = 1; i < channels.length; i++ ) {\r\n\r\n if ( priority !== channels[i].priority ) {\r\n weight += priorityWeight * ( 1.0 - weight );\r\n priorityWeight = 0.0;\r\n priority = channels[i].priority;\r\n }\r\n\r\n priorityWeight += weight;\r\n t = ( 1.0 - weight ) * channels[i].weight / priorityWeight;\r\n lerp( t, value, channels[i].value );\r\n }\r\n\r\n\r\n // second version\r\n\r\n var value;\r\n Copy( channels[0].value, value );\r\n var weight = 0; //channels[0].weight;\r\n //var priority = channels[0].priority;\r\n var priorityWeight = 0;\r\n\r\n for ( var i = 0; i < channels.length; i++ ) {\r\n\r\n if ( priority !== channels[i].priority ) {\r\n weight += priorityWeight * ( 1.0 - weight );\r\n priorityWeight = 0.0;\r\n priority = channels[i].priority;\r\n }\r\n\r\n priorityWeight += weight;\r\n t = ( 1.0 - weight ) * channels[i].weight / priorityWeight;\r\n lerp( t, value, channels[i].value );\r\n }\r\n\r\n\r\n */\r\n\r\nChannel.createInstanceChannel = createInstanceChannel;\r\nChannel.createInstanceVec3Channel = createInstanceVec3Channel;\r\nChannel.createInstanceQuatChannel = createInstanceQuatChannel;\r\nChannel.createInstanceQuatSlerpChannel = createInstanceQuatChannel;\r\nChannel.createInstanceFloatChannel = createInstanceFloatChannel;\r\nChannel.createInstanceFloatCubicBezierChannel = createInstanceFloatCubicBezierChannel;\r\nChannel.createInstanceVec3CubicBezierChannel = createInstanceVec3CubicBezierChannel;\r\n\r\nChannel.createVec3Channel = createVec3Channel;\r\nChannel.createQuatChannel = createQuatChannel;\r\nChannel.createQuatSlerpChannel = createQuatSlerpChannel;\r\nChannel.createFloatChannel = createFloatChannel;\r\nChannel.createFloatCubicBezierChannel = createFloatCubicBezierChannel;\r\nChannel.createVec3CubicBezierChannel = createVec3CubicBezierChannel;\r\n\r\nChannel[channelType.Vec3] = createInstanceVec3Channel;\r\nChannel[channelType.Quat] = createInstanceQuatChannel;\r\nChannel[channelType.QuatSlerp] = createInstanceQuatChannel;\r\nChannel[channelType.Float] = createInstanceFloatChannel;\r\nChannel[channelType.FloatCubicBezier] = createInstanceFloatCubicBezierChannel;\r\nChannel[channelType.Vec3CubicBezier] = createInstanceVec3CubicBezierChannel;\r\n\r\nChannel.ChannelType = channelType;\r\n\r\nexport default Channel;\r\n","import Channel from './channel';\r\n\r\n// create Animation data\r\n// Animation {\r\n// channels: [],\r\n// duration: 0.0;\r\n// name: string\r\n// },\r\n\r\nvar animationCount = 0;\r\n\r\n// assume that iniChannel has been called\r\n// on each channel\r\nvar createAnimation = function(channels, name) {\r\n var min = Infinity;\r\n var max = -Infinity;\r\n for (var i = 0; i < channels.length; i++) {\r\n min = Math.min(min, channels[i].start);\r\n max = Math.max(max, channels[i].end);\r\n }\r\n\r\n var duration = max - min;\r\n var animationName = name || 'animation' + animationCount.toString();\r\n animationCount++;\r\n return {\r\n channels: channels,\r\n duration: duration,\r\n name: animationName,\r\n start: min\r\n };\r\n};\r\n\r\n// create instance Animation data. An instance animation\r\n// contains instance channels instead of original channels\r\n// Animation {\r\n// channels: [],\r\n// duration: 0.0;\r\n// start: 0.0, // used to know when an animation has been started\r\n// name: string\r\n// },\r\nvar createInstanceAnimation = function(animation) {\r\n var channels = [];\r\n for (var i = 0; i < animation.channels.length; i++) {\r\n var channel = Channel.createInstanceChannel(animation.channels[i]);\r\n channels.push(channel);\r\n }\r\n\r\n return {\r\n channels: channels,\r\n duration: animation.duration,\r\n start: 0.0,\r\n name: animation.name,\r\n firstKeyTime: animation.start\r\n };\r\n};\r\n\r\nvar Animation = function() {};\r\n\r\nAnimation.createAnimation = createAnimation;\r\nAnimation.createInstanceAnimation = createInstanceAnimation;\r\n\r\nexport default Animation;\r\n","import { vec3 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport Channel from './channel';\r\n\r\nvar vec3CopyKeyFrame = function(i, keys, result) {\r\n result[0] = keys[i++];\r\n result[1] = keys[i++];\r\n result[2] = keys[i++];\r\n};\r\n\r\nvar Vec4CopyKeyFrame = function(i, keys, result) {\r\n result[0] = keys[i++];\r\n result[1] = keys[i++];\r\n result[2] = keys[i++];\r\n result[3] = keys[i++];\r\n};\r\n\r\nvar Vec3LerpInterpolator = function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n vec3CopyKeyFrame(keys.length - 3, keys, value);\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n vec3CopyKeyFrame(0, keys, value);\r\n return;\r\n }\r\n\r\n var i1 = channelInstance.key;\r\n if (t > times[i1]) while (times[i1 + 1] < t) i1++;\r\n else if (t < times[i1]) while (times[i1] > t) i1--;\r\n\r\n var t1 = times[i1];\r\n var t2 = times[i1 + 1];\r\n\r\n var index = i1 * 3;\r\n var x1 = keys[index++];\r\n var y1 = keys[index++];\r\n var z1 = keys[index++];\r\n\r\n var x2 = keys[index++];\r\n var y2 = keys[index++];\r\n var z2 = keys[index++];\r\n\r\n var r = (t - t1) / (t2 - t1);\r\n\r\n value[0] = x1 + (x2 - x1) * r;\r\n value[1] = y1 + (y2 - y1) * r;\r\n value[2] = z1 + (z2 - z1) * r;\r\n channelInstance.key = i1;\r\n};\r\n\r\nvar QuatLerpInterpolator = (function() {\r\n var q0 = quat.create32();\r\n var q1 = quat.create32();\r\n\r\n return function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n Vec4CopyKeyFrame(keys.length - 4, keys, value);\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n Vec4CopyKeyFrame(0, keys, value);\r\n return;\r\n }\r\n\r\n var i1 = channelInstance.key;\r\n if (t > times[i1]) while (times[i1 + 1] < t) i1++;\r\n else if (t < times[i1]) while (times[i1] > t) i1--;\r\n\r\n var t1 = times[i1];\r\n var t2 = times[i1 + 1];\r\n\r\n var index = i1 * 4;\r\n q0[0] = keys[index++];\r\n q0[1] = keys[index++];\r\n q0[2] = keys[index++];\r\n q0[3] = keys[index++];\r\n\r\n q1[0] = keys[index++];\r\n q1[1] = keys[index++];\r\n q1[2] = keys[index++];\r\n q1[3] = keys[index++];\r\n\r\n var r = (t - t1) / (t2 - t1);\r\n\r\n quat.nlerp(value, q0, q1, r);\r\n channelInstance.key = i1;\r\n };\r\n})();\r\n\r\nvar QuatSlerpInterpolator = (function() {\r\n var q0 = quat.create32();\r\n var q1 = quat.create32();\r\n\r\n return function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n Vec4CopyKeyFrame(keys.length - 4, keys, value);\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n Vec4CopyKeyFrame(0, keys, value);\r\n return;\r\n }\r\n\r\n var i1 = channelInstance.key;\r\n if (t > times[i1]) while (times[i1 + 1] < t) i1++;\r\n else if (t < times[i1]) while (times[i1] > t) i1--;\r\n\r\n var t1 = times[i1];\r\n var t2 = times[i1 + 1];\r\n\r\n var index = i1 * 4;\r\n q0[0] = keys[index++];\r\n q0[1] = keys[index++];\r\n q0[2] = keys[index++];\r\n q0[3] = keys[index++];\r\n\r\n q1[0] = keys[index++];\r\n q1[1] = keys[index++];\r\n q1[2] = keys[index++];\r\n q1[3] = keys[index++];\r\n\r\n var r = (t - t1) / (t2 - t1);\r\n\r\n quat.slerp(value, q0, q1, r);\r\n\r\n channelInstance.key = i1;\r\n };\r\n})();\r\n\r\nvar FloatLerpInterpolator = function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n channelInstance.value = keys[keys.length - 1];\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n channelInstance.value = keys[0];\r\n return;\r\n }\r\n\r\n var i1 = channelInstance.key;\r\n if (t > times[i1]) while (times[i1 + 1] < t) i1++;\r\n else if (t < times[i1]) while (times[i1] > t) i1--;\r\n\r\n var t1 = times[i1];\r\n var t2 = times[i1 + 1];\r\n\r\n var index = i1;\r\n var x1 = keys[index++];\r\n var x2 = keys[index++];\r\n\r\n var r = (t - t1) / (t2 - t1);\r\n\r\n value = x1 + (x2 - x1) * r;\r\n channelInstance.key = i1;\r\n channelInstance.value = value;\r\n};\r\n\r\nvar FloatCubicBezierInterpolator = function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n channelInstance.value = keys[keys.length - 3];\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n channelInstance.value = keys[0];\r\n return;\r\n }\r\n\r\n var i = channelInstance.key;\r\n if (t > times[i]) while (times[i + 1] < t) i++;\r\n else if (t < times[i]) while (times[i] > t) i--;\r\n\r\n var tt = (t - times[i]) / (times[i + 1] - times[i]);\r\n var oneMinusT = 1.0 - tt;\r\n var oneMinusT2 = oneMinusT * oneMinusT;\r\n var oneMinusT3 = oneMinusT2 * oneMinusT;\r\n var t2 = tt * tt;\r\n\r\n var id = i * 3;\r\n var v0 = keys[id] * oneMinusT3;\r\n var v1 = keys[id + 1] * (3.0 * tt * oneMinusT2);\r\n var v2 = keys[id + 2] * (3.0 * t2 * oneMinusT);\r\n var v3 = keys[id + 3] * (t2 * tt);\r\n\r\n value = v0 + v1 + v2 + v3;\r\n channelInstance.key = i;\r\n channelInstance.value = value;\r\n};\r\n\r\nvar Vec3CubicBezierInterpolator = (function() {\r\n var v0 = vec3.create();\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n var v3 = vec3.create();\r\n\r\n return function(t, channelInstance) {\r\n var channel = channelInstance.channel;\r\n var value = channelInstance.value;\r\n var keys = channel.keys;\r\n var times = channel.times;\r\n\r\n if (t >= times[times.length - 1]) {\r\n channelInstance.key = 0;\r\n vec3CopyKeyFrame(keys.length - 9, keys, value);\r\n return;\r\n } else if (t <= times[0]) {\r\n channelInstance.key = 0;\r\n vec3CopyKeyFrame(0, keys, value);\r\n return;\r\n }\r\n\r\n var i = channelInstance.key;\r\n if (t > times[i]) while (times[i + 1] < t) i++;\r\n else if (t < times[i]) while (times[i] > t) i--;\r\n\r\n var tt = (t - times[i]) / (times[i + 1] - times[i]);\r\n var oneMinusT = 1.0 - tt;\r\n var oneMinusT2 = oneMinusT * oneMinusT;\r\n var oneMinusT3 = oneMinusT2 * oneMinusT;\r\n var t2 = tt * tt;\r\n\r\n var id = i * 9;\r\n vec3.scale(v0, vec3.set(v0, keys[id++], keys[id++], keys[id++]), oneMinusT3);\r\n vec3.scale(v1, vec3.set(v1, keys[id++], keys[id++], keys[id++]), 3.0 * tt * oneMinusT2);\r\n vec3.scale(v2, vec3.set(v2, keys[id++], keys[id++], keys[id++]), 3.0 * t2 * oneMinusT);\r\n vec3.scale(v3, vec3.set(v3, keys[id++], keys[id++], keys[id++]), t2 * tt);\r\n\r\n value[0] = v0[0] + v1[0] + v2[0] + v3[0];\r\n value[1] = v0[1] + v1[1] + v2[1] + v3[1];\r\n value[2] = v0[2] + v1[2] + v2[2] + v3[2];\r\n channelInstance.key = i;\r\n };\r\n})();\r\n\r\n// must be sync wiht Interpolator Type\r\nvar ChannelType = Channel.ChannelType;\r\n\r\nvar moduleInterpolator = {};\r\n\r\n// refrence interpolator by channe enum id\r\nmoduleInterpolator[ChannelType.Vec3] = Vec3LerpInterpolator;\r\nmoduleInterpolator[ChannelType.Quat] = QuatLerpInterpolator;\r\nmoduleInterpolator[ChannelType.QuatSlerp] = QuatSlerpInterpolator;\r\nmoduleInterpolator[ChannelType.Float] = FloatLerpInterpolator;\r\nmoduleInterpolator[ChannelType.FloatCubicBezier] = FloatCubicBezierInterpolator;\r\nmoduleInterpolator[ChannelType.Vec3CubicBezier] = Vec3CubicBezierInterpolator;\r\n\r\nmoduleInterpolator.Vec3LerpInterpolator = Vec3LerpInterpolator;\r\nmoduleInterpolator.QuatLerpInterpolator = QuatLerpInterpolator;\r\nmoduleInterpolator.QuatSlerpInterpolator = QuatSlerpInterpolator;\r\nmoduleInterpolator.FloatLerpInterpolator = FloatLerpInterpolator;\r\nmoduleInterpolator.FloatCubicBezierInterpolator = FloatCubicBezierInterpolator;\r\nmoduleInterpolator.Vec3CubicBezierInterpolator = Vec3CubicBezierInterpolator;\r\n\r\nexport default moduleInterpolator;\r\n","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport AnimationUpdateCallback from './AnimationUpdateCallback';\r\n\r\n// search into a subgraph all target\r\nvar CollectAnimationUpdateCallbackVisitor = function() {\r\n NodeVisitor.call(this);\r\n this._animationUpdateCallback = {};\r\n};\r\n\r\nutils.createPrototypeObject(\r\n CollectAnimationUpdateCallbackVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n getAnimationUpdateCallbackMap: function() {\r\n return this._animationUpdateCallback;\r\n },\r\n\r\n apply: function(node) {\r\n var cbs = node.getUpdateCallbackList();\r\n\r\n // collect and remove animation update callback\r\n for (var i = 0, cbsLength = cbs.length; i < cbsLength; i++) {\r\n var cb = cbs[i];\r\n if (cb instanceof AnimationUpdateCallback) {\r\n this._animationUpdateCallback[cb.getInstanceID()] = cb;\r\n //node.removeUpdateCallback( cb );\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'CollectAnimationUpdateCallbackVisitor'\r\n);\r\n\r\nexport default CollectAnimationUpdateCallbackVisitor;\r\n","import notify from '../osg/notify';\r\nimport utils from '../osg/utils';\r\nimport BaseObject from '../osg/Object';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Channel from './channel';\r\nimport Animation from './animation';\r\nimport Interpolator from './interpolator';\r\nimport CollectAnimationUpdateCallbackVisitor from './CollectAnimationUpdateCallbackVisitor';\r\nimport Target from './target';\r\nimport UpdateMorph from './UpdateMorph';\r\nimport UpdateBone from './UpdateBone';\r\nimport UpdateMatrixTransform from './UpdateMatrixTransform';\r\n\r\nvar Float = {\r\n lerp: function(a, b, t) {\r\n return a + (b - a) * t;\r\n },\r\n init: function() {\r\n return 0.0;\r\n },\r\n copy: function(out, src) {\r\n return src;\r\n },\r\n create: function() {\r\n return 0.0;\r\n }\r\n};\r\n\r\nvar TypeToSize = [];\r\nTypeToSize[Channel.ChannelType.Float] = 1;\r\nTypeToSize[Channel.ChannelType.FloatCubicBezier] = 1;\r\nTypeToSize[Channel.ChannelType.Vec3] = 3;\r\nTypeToSize[Channel.ChannelType.Vec3CubicBezier] = 3;\r\nTypeToSize[Channel.ChannelType.Quat] = 4;\r\nTypeToSize[Channel.ChannelType.QuatSlerp] = 4;\r\nTypeToSize[Channel.ChannelType.Matrix] = 16;\r\n\r\nvar ResultType = [];\r\nResultType.length = Channel.ChannelType.Count;\r\nResultType[Channel.ChannelType.Vec3] = vec3;\r\nResultType[Channel.ChannelType.Quat] = quat;\r\nResultType[Channel.ChannelType.QuatSlerp] = quat;\r\nResultType[Channel.ChannelType.Float] = Float;\r\nResultType[Channel.ChannelType.FloatCubicBezier] = Float;\r\nResultType[Channel.ChannelType.Vec3CubicBezier] = vec3;\r\nResultType[Channel.ChannelType.Matrix] = mat4;\r\n\r\n/**\r\n * BasicAnimationManager\r\n * @class BasicAnimationManager\r\n */\r\nvar BasicAnimationManager = function() {\r\n BaseObject.call(this);\r\n\r\n this._simulationTime = 0.0;\r\n this._pauseTime = 0.0;\r\n this._timeFactor = 1.0;\r\n this._startTime = 0.0;\r\n\r\n // contains a map with instance animations\r\n this._instanceAnimations = {};\r\n\r\n // animations to start\r\n this._startAnimations = {};\r\n\r\n // target contains an array of all target for this manager\r\n // index in the array is used as ID\r\n // see Animation.createTarget\r\n // [\r\n // { id: 0,\r\n // channels: [],\r\n // value: 0.0,\r\n // defaultValue: 0.0,\r\n // type\r\n // },\r\n // ...\r\n // ];\r\n this._targets = [];\r\n this._targetsMap = {};\r\n\r\n // target id with active lists\r\n // [\r\n // vec3: [ targetID0, targetID1 ]\r\n // Quat: [ targetID2, targetID3, ... ]\r\n // Float: [ ... ]\r\n // ]\r\n this._targetsByTypes = [];\r\n this._targetsByTypes.length = Channel.ChannelType.Count;\r\n for (var i = 0, ni = this._targetsByTypes.length; i < ni; i++) {\r\n this._targetsByTypes[i] = [];\r\n }\r\n\r\n // current playing animations\r\n this._activeAnimations = {};\r\n this._activeAnimationList = [];\r\n\r\n // current actives channels by types\r\n // [ chanel0, channel1, ... ] // vec3 type\r\n // [ chanel2, channel3, ... ] // Quat type\r\n // [ chanel5, channel6, ... ] // Float type\r\n this._activeChannelsByTypes = [];\r\n this._activeChannelsByTypes.length = Channel.ChannelType.Count;\r\n for (var j = 0, nj = this._activeChannelsByTypes.length; j < nj; j++) {\r\n this._activeChannelsByTypes[j] = [];\r\n }\r\n\r\n // assign all target/channel in animationCallback\r\n // then they can read it directly\r\n // animation callback to update\r\n this._animationsUpdateCallback = {};\r\n this._animationsUpdateCallbackArray = [];\r\n\r\n // queue of animations to register\r\n this._animationsToRegister = [];\r\n\r\n //Pause status (true / false)\r\n this._pause = false;\r\n\r\n this._dirty = false;\r\n\r\n this._seekTime = -1;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n BasicAnimationManager,\r\n utils.objectInherit(BaseObject.prototype, {\r\n init: function(animations) {\r\n // reset all\r\n this._simulationTime = 0.0;\r\n this._pauseTime = 0.0;\r\n this._timeFactor = 1.0;\r\n this._startTime = 0.0;\r\n\r\n // contains a map with instance animations\r\n this._instanceAnimations = {};\r\n\r\n // animations to start\r\n this._startAnimations = {};\r\n\r\n this._resetTargets();\r\n\r\n this._activeAnimations = {};\r\n this._activeAnimationList.length = 0;\r\n\r\n for (var i = 0, ni = this._activeChannelsByTypes.length; i < ni; i++)\r\n this._activeChannelsByTypes[i].length = 0;\r\n\r\n this._animationsUpdateCallback = {};\r\n this._animationsUpdateCallbackArray.length = 0;\r\n\r\n this._pause = false;\r\n this._seekTime = -1;\r\n\r\n // add animations\r\n this.addAnimations(animations);\r\n },\r\n\r\n // push all animations into the queue\r\n addAnimations: function(animations) {\r\n var instanceAnimationList = this._addAnimation(animations);\r\n\r\n // qeue them to assign target\r\n Array.prototype.push.apply(this._animationsToRegister, instanceAnimationList);\r\n this._dirty = true;\r\n this._registerAnimations();\r\n },\r\n\r\n update: function(node, nv) {\r\n if (this._dirty) {\r\n this._findAnimationUpdateCallback(node);\r\n this._registerTargetFoundInAnimationCallback();\r\n this._registerAnimations();\r\n }\r\n\r\n var t = nv.getFrameStamp().getSimulationTime();\r\n\r\n if (this._seekTime !== -1) this._pauseTime = -this._seekTime + this._startTime + t;\r\n this._seekTime = -1;\r\n\r\n if (!this._pause) {\r\n // Not in pause\r\n this._simulationTime = this._startTime + (t - this._pauseTime);\r\n } else {\r\n this._pauseTime = t - this._simulationTime + this._startTime;\r\n }\r\n\r\n this.updateManager(this._simulationTime * this._timeFactor);\r\n return true;\r\n },\r\n\r\n updateManager: function(t) {\r\n // adds active animations / channels requested\r\n //\r\n this._processStartAnimation(t);\r\n\r\n var l = Channel.ChannelType.Count;\r\n // update all actives channels by type\r\n //\r\n for (var i = 0; i < l; i++) {\r\n var activeChannelType = this._activeChannelsByTypes[i];\r\n this._updateChannelsType(t, activeChannelType, Interpolator[i]);\r\n }\r\n\r\n // update targets\r\n //\r\n for (var j = 0; j < l; j++) {\r\n var targetType = this._targetsByTypes[j];\r\n this._updateTargetType(targetType, ResultType[j]);\r\n }\r\n\r\n // update all animation callback\r\n // expect to have UpdateMatrixTransform\r\n for (var k = 0, nk = this._animationsUpdateCallbackArray.length; k < nk; k++) {\r\n var animCallback = this._animationsUpdateCallbackArray[k];\r\n animCallback.computeChannels();\r\n }\r\n\r\n // check animation finished\r\n this._removeFinishedAnimation(t);\r\n },\r\n\r\n togglePause: function() {\r\n //Pause the manager's time\r\n this._pause = !this._pause;\r\n // if we resume an animation we don't want to move forward the animation\r\n if (!this._pause) this._seekTime = this._simulationTime;\r\n },\r\n\r\n getSimulationTime: function() {\r\n return this._simulationTime;\r\n },\r\n\r\n setSimulationTime: function(t) {\r\n this._simulationTime = t;\r\n },\r\n\r\n setSeekTime: function(t) {\r\n this._simulationTime = t;\r\n this._seekTime = t;\r\n },\r\n\r\n stopAnimation: function(name) {\r\n var activeAnimationList = this._activeAnimationList;\r\n for (var i = 0, nbAnim = activeAnimationList.length; i < nbAnim; ++i) {\r\n if (activeAnimationList[i].name === name) {\r\n this._removeActiveChannels(this._instanceAnimations[name]);\r\n this._activeAnimations[name] = undefined;\r\n activeAnimationList.splice(i, 1);\r\n return;\r\n }\r\n }\r\n },\r\n\r\n stopAllAnimation: function() {\r\n var activeAnimationList = this._activeAnimationList;\r\n for (var i = 0, nbAnim = activeAnimationList.length; i < nbAnim; ++i) {\r\n var name = activeAnimationList[i].name;\r\n this._removeActiveChannels(this._instanceAnimations[name]);\r\n this._activeAnimations[name] = undefined;\r\n }\r\n activeAnimationList.length = 0;\r\n },\r\n\r\n setTimeFactor: function(timeFactor) {\r\n var tf = timeFactor / this._timeFactor;\r\n this._startTime += (this._simulationTime - this._simulationTime * tf) / tf;\r\n\r\n this._timeFactor = timeFactor;\r\n\r\n if (this._pause)\r\n this._simulationTime += (this._simulationTime - this._simulationTime * tf) / tf;\r\n },\r\n\r\n getTimeFactor: function() {\r\n return this._timeFactor;\r\n },\r\n\r\n isPlaying: function(name) {\r\n if (this._activeAnimations[name]) return true;\r\n return false;\r\n },\r\n\r\n // play animation using object as config\r\n // {\r\n // name: string,\r\n // priority: 0,\r\n // weight: 1.0,\r\n // loop: true / false\r\n // }\r\n playAnimationObject: function(obj) {\r\n var anim = this._instanceAnimations[obj.name];\r\n if (!anim) {\r\n notify.info('no animation ' + obj.name + ' found');\r\n return;\r\n }\r\n\r\n if (this.isPlaying(obj.name)) return;\r\n\r\n anim.priority = obj.priority === undefined ? 0 : obj.priority;\r\n anim.weight = obj.weight === undefined ? 1.0 : obj.weight;\r\n anim.loop = obj.loop === undefined ? true : obj.loop;\r\n\r\n this._startAnimations[anim.name] = anim;\r\n },\r\n\r\n // if first argument is an object\r\n // playAnimationObject is called instead\r\n playAnimation: function(name, loop, priority, weight) {\r\n var animationObject;\r\n if (typeof name === 'object') animationObject = name;\r\n else {\r\n animationObject = {\r\n name: name,\r\n priority: priority,\r\n weight: weight,\r\n loop: loop\r\n };\r\n }\r\n\r\n return this.playAnimationObject(animationObject);\r\n },\r\n\r\n getAnimations: function() {\r\n return this._instanceAnimations;\r\n },\r\n\r\n _registerAnimations: function() {\r\n if (!this._targets.length) return;\r\n\r\n for (var i = 0, ni = this._animationsToRegister.length; i < ni; i++) {\r\n var instanceAnimation = this._animationsToRegister[i];\r\n this._registerInstanceAnimation(instanceAnimation);\r\n }\r\n\r\n this._animationsToRegister.length = 0;\r\n this._dirty = false;\r\n },\r\n\r\n // Register animation\r\n //\r\n // Register animation list all target from channel in the animations and associate\r\n // target found in the scenegraph. If no target are registered animation cant be\r\n // registered. In this case animation will be pending and resolved after a visitor\r\n // extract target.\r\n _registerInstanceAnimation: function(instanceAnimation) {\r\n var instanceChannels = instanceAnimation.channels;\r\n for (var i = 0, ni = instanceChannels.length; i < ni; i++) {\r\n var instanceChannel = instanceChannels[i];\r\n var targetName = instanceChannel.channel.target;\r\n var name = instanceChannel.channel.name;\r\n var uniqueTargetName = targetName + '.' + name;\r\n\r\n // disply a warning if animation has a channel but not target found in the\r\n // scene graph. We could probably optimize and removes those channels, but\r\n // it must be a user decision in case the user plugin different scene\r\n // graph together and target would appear later in the scenegraph\r\n if (!this._targetMap[uniqueTargetName]) {\r\n notify.warn(\r\n 'registerInstanceAnimation did not find targetName (' +\r\n uniqueTargetName +\r\n ') in the scene graph'\r\n );\r\n continue;\r\n }\r\n\r\n instanceChannel.targetID = this._targetMap[uniqueTargetName].id;\r\n }\r\n return true;\r\n },\r\n\r\n _findAnimationUpdateCallback: function(node) {\r\n var collector = new CollectAnimationUpdateCallbackVisitor();\r\n node.accept(collector);\r\n this._animationsUpdateCallback = collector.getAnimationUpdateCallbackMap();\r\n },\r\n\r\n // assignTargetToAnimationCallback\r\n //\r\n // check all animationUpdateCallback collected and try to\r\n // assign the channel instance registered in the manager. If a\r\n // animationUpdateCallback contains channels not known by the\r\n // manager we skip it. It means that it should be called\r\n // after the animations has been registered into the animation\r\n // manager\r\n _registerTargetFoundInAnimationCallback: function() {\r\n this._resetTargets();\r\n\r\n var targetID = 0;\r\n var targetMap = this._targetMap;\r\n var targets = this._targets;\r\n\r\n var registerTarget = function(uniqueTargetName, target) {\r\n if (!targetMap[uniqueTargetName]) {\r\n targetMap[uniqueTargetName] = target;\r\n // assign an id that will be an index into a array\r\n target.id = targetID++;\r\n targets.push(target);\r\n\r\n var type = target.type; // split by type\r\n this._targetsByTypes[type].push(target);\r\n } else {\r\n // detect differents target instance with same\r\n // unique target name. It's a problem\r\n if (target !== targetMap[uniqueTargetName])\r\n notify.warn(\r\n 'detected differents target instance with the same name (' +\r\n uniqueTargetName +\r\n ')'\r\n );\r\n }\r\n }.bind(this);\r\n\r\n var target;\r\n var name;\r\n var uniqueTargetName;\r\n\r\n for (var keyAnimation in this._animationsUpdateCallback) {\r\n var animCb = this._animationsUpdateCallback[keyAnimation];\r\n\r\n if (animCb instanceof UpdateMatrixTransform || animCb instanceof UpdateBone) {\r\n var stackedTransforms = animCb.getStackedTransforms();\r\n var numStacked = stackedTransforms.length;\r\n if (!numStacked) continue;\r\n\r\n this._animationsUpdateCallbackArray.push(animCb);\r\n\r\n for (var j = 0; j < numStacked; j++) {\r\n var stackedTransform = stackedTransforms[j];\r\n target = stackedTransform.getTarget();\r\n name = stackedTransform.getName();\r\n uniqueTargetName = animCb.getName() + '.' + name;\r\n\r\n registerTarget(uniqueTargetName, target, name);\r\n }\r\n } else if (animCb instanceof UpdateMorph) {\r\n var numTarget = animCb.getNumTarget();\r\n if (!numTarget) continue;\r\n\r\n this._animationsUpdateCallbackArray.push(animCb);\r\n\r\n for (var t = 0; t < numTarget; t++) {\r\n name = animCb.getTargetName(t);\r\n uniqueTargetName = name + '.' + t;\r\n target = animCb.getTarget(t);\r\n\r\n registerTarget(uniqueTargetName, target, name);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _addAnimation: function(animations) {\r\n var instanceAnimationList = [];\r\n for (var i = 0, ni = animations.length; i < ni; i++) {\r\n var animation = animations[i];\r\n var animationName = animation.name;\r\n\r\n if (this._instanceAnimations[animationName]) continue;\r\n\r\n var instanceAnimation = Animation.createInstanceAnimation(animation);\r\n this._instanceAnimations[animationName] = instanceAnimation;\r\n instanceAnimationList.push(instanceAnimation);\r\n }\r\n\r\n return instanceAnimationList;\r\n },\r\n\r\n // add channels from instance animation to the active channels list\r\n _addActiveChannels: function(t, instanceAnimation) {\r\n var instanceChannels = instanceAnimation.channels;\r\n for (var i = 0, ni = instanceChannels.length; i < ni; i++) {\r\n var instanceChannel = instanceChannels[i];\r\n var type = instanceChannel.channel.type;\r\n instanceChannel.t = t; // reset time\r\n instanceChannel.instanceAnimation = instanceAnimation; // link with parent animation\r\n var targetID = instanceChannel.targetID;\r\n\r\n if (targetID === Target.InvalidTargetID) continue;\r\n\r\n this._activeChannelsByTypes[type].push(instanceChannel);\r\n this._targets[targetID].channels.push(instanceChannel);\r\n }\r\n },\r\n\r\n _removeActiveChannels: function(instanceAnimation) {\r\n var instanceChannels = instanceAnimation.channels;\r\n for (var i = 0, ni = instanceChannels.length; i < ni; i++) {\r\n var instanceChannel = instanceChannels[i];\r\n var type = instanceChannel.channel.type;\r\n var targetID = instanceChannel.targetID;\r\n\r\n if (targetID === Target.InvalidTargetID) continue;\r\n\r\n // remove channel instance from targetID channel list\r\n var targetChannelsList = this._targets[targetID].channels;\r\n var index = targetChannelsList.indexOf(instanceChannel);\r\n targetChannelsList.splice(index, 1);\r\n\r\n // remove channel from active channels\r\n var channelTypeList = this._activeChannelsByTypes[type];\r\n var channelIndex = channelTypeList.indexOf(instanceChannel);\r\n channelTypeList.splice(channelIndex, 1);\r\n }\r\n },\r\n\r\n // blend value from each channels for each target\r\n // or copy default value if not updated by an active animation\r\n _updateTargetType: function(targetList, operatorType) {\r\n for (var i = 0, ni = targetList.length; i < ni; i++) {\r\n var target = targetList[i];\r\n var affectedChannels = target.channels;\r\n var nbChannels = affectedChannels.length;\r\n // note operatorType operations doesn't always operate on arrays (float)\r\n // so we can't simply assume that target.value is an array so we need\r\n // to write \"target.value = ...\"\r\n\r\n if (nbChannels === 0) {\r\n // no blending ?\r\n target.value = operatorType.copy(target.value, target.defaultValue);\r\n } else if (nbChannels === 1) {\r\n target.value = operatorType.copy(target.value, affectedChannels[0].value);\r\n } else {\r\n // blend between multiple channels\r\n target.value = operatorType.init(target.value);\r\n var accumulatedWeight = 0.0;\r\n\r\n // it's the same as targetOut = (v0 * w0 + v1 * w1 + ...) / (w0 + w1 + ...)\r\n for (var j = 0, nj = affectedChannels.length; j < nj; j++) {\r\n var achannel = affectedChannels[j];\r\n var weight = achannel.weight;\r\n accumulatedWeight += weight;\r\n // avoid divide by zero and useless lerp\r\n if (accumulatedWeight === 0.0 || weight === 0.0) continue;\r\n\r\n var ratio = weight / accumulatedWeight;\r\n target.value = operatorType.lerp(\r\n target.value,\r\n target.value,\r\n achannel.value,\r\n ratio\r\n );\r\n }\r\n }\r\n }\r\n },\r\n\r\n _updateChannelsType: function(t, channels, interpolator) {\r\n for (var i = 0, ni = channels.length; i < ni; i++) {\r\n var channel = channels[i];\r\n var instanceAnimation = channel.instanceAnimation;\r\n var loop = instanceAnimation.loop;\r\n\r\n var tLocal = t - channel.t;\r\n\r\n // handle loop, careful in case animation is one frame\r\n if (loop && instanceAnimation.duration > 0.0) {\r\n tLocal = tLocal % instanceAnimation.duration;\r\n }\r\n\r\n interpolator(tLocal + instanceAnimation.firstKeyTime, channel);\r\n }\r\n },\r\n\r\n _removeFinishedAnimation: function(t) {\r\n var activeAnimationList = this._activeAnimationList;\r\n\r\n var i = 0;\r\n while (i < activeAnimationList.length) {\r\n var instanceAnimation = activeAnimationList[i];\r\n var name = instanceAnimation.name;\r\n\r\n if (t > instanceAnimation.end && instanceAnimation.loop === false) {\r\n this._removeActiveChannels(instanceAnimation);\r\n this._activeAnimations[name] = undefined;\r\n activeAnimationList.splice(i, 1);\r\n } else {\r\n i++;\r\n }\r\n }\r\n },\r\n\r\n _addActiveAnimation: function(t, cmd) {\r\n this._activeAnimations[cmd.name] = cmd; // set animation in the list of active one\r\n\r\n var instanceAnimation = this._instanceAnimations[cmd.name];\r\n instanceAnimation.start = t;\r\n instanceAnimation.end = t + instanceAnimation.duration;\r\n this._addActiveChannels(t, instanceAnimation);\r\n\r\n // keep track of instance animation active in a list\r\n this._activeAnimationList.push(instanceAnimation);\r\n },\r\n\r\n // execute start animations events\r\n // during the updateManager\r\n _processStartAnimation: function(t) {\r\n // dont really start animation if we dont have yet targets\r\n if (!this._targets.length) return;\r\n\r\n var keyAnimation;\r\n for (keyAnimation in this._startAnimations) {\r\n var cmd = this._startAnimations[keyAnimation];\r\n var name = cmd.name;\r\n\r\n if (this.isPlaying(name)) continue;\r\n\r\n this._addActiveAnimation(t, cmd);\r\n }\r\n\r\n if (keyAnimation !== undefined) this._startAnimations = {};\r\n },\r\n\r\n _resetTargets: function() {\r\n this._targetMap = {};\r\n this._targets.length = 0;\r\n\r\n for (var i = 0, ni = this._targetsByTypes.length; i < ni; i++) {\r\n this._targetsByTypes[i].length = 0;\r\n }\r\n },\r\n\r\n resetUpdateCallbacks: function() {\r\n var anims = this._animationsUpdateCallbackArray;\r\n for (var i = 0, nbAnims = anims.length; i < nbAnims; i++) {\r\n anims[i].reset();\r\n }\r\n },\r\n\r\n resetAllStackedTransforms: function() {\r\n // resetAllStackedTransforms used to reset stacked only (not morph target)\r\n notify.warn('Uses resetUpdateCallback instead');\r\n this.resetUpdateCallbacks();\r\n },\r\n\r\n setAnimationLerpEndStart: function(anim, lerpDuration) {\r\n var channels = anim.channels;\r\n if (anim.originalDuration === undefined) anim.originalDuration = anim.duration;\r\n\r\n anim.duration = anim.originalDuration + lerpDuration;\r\n\r\n var firstKey = anim.firstKeyTime;\r\n var animDuration = anim.originalDuration;\r\n\r\n for (var i = 0, nbChannels = channels.length; i < nbChannels; ++i) {\r\n var ch = channels[i].channel;\r\n\r\n // compare first and last key and detect if we can loop the channel or not\r\n // it uses an arbitrary epsilon\r\n if (\r\n Math.abs(ch.start - firstKey) > 0.01 ||\r\n Math.abs(ch.duration - animDuration) > 0.01\r\n )\r\n continue;\r\n\r\n // update channel end time\r\n if (ch.originalEnd === undefined) ch.originalEnd = ch.end;\r\n\r\n ch.end = ch.originalEnd + lerpDuration;\r\n\r\n // add or remove additonal key and time\r\n\r\n var sizeElt = TypeToSize[ch.type];\r\n var size = ch.times.buffer.byteLength / 4;\r\n\r\n // no lerp between end and start\r\n if (lerpDuration === 0.0) {\r\n ch.keys = new Float32Array(ch.keys.buffer, 0, (size - 1) * sizeElt);\r\n ch.times = new Float32Array(ch.times.buffer, 0, size - 1);\r\n } else {\r\n // take full size of buffer (with additional keys)\r\n ch.keys = new Float32Array(ch.keys.buffer, 0, size * sizeElt);\r\n // copy first key\r\n var idLast = (size - 1) * sizeElt;\r\n for (var j = 0; j < sizeElt; ++j) ch.keys[idLast + j] = ch.keys[j];\r\n\r\n ch.times = new Float32Array(ch.times.buffer, 0, size);\r\n ch.times[size - 1] = ch.times[size - 2] + lerpDuration;\r\n }\r\n }\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'BasicAnimationManager'\r\n);\r\n\r\nBasicAnimationManager.TypeToSize = TypeToSize;\r\n\r\nexport default BasicAnimationManager;\r\n","//\r\n// Visualisations:\r\n// https://greensock.com/docs/Easing\r\n// https://htmlpreview.github.io/?https://github.com/Michaelangel007/easing/blob/master/compare.html\r\n//\r\n// Maths\r\n// https://www.essentialmath.com/tutorial.htm\r\n// Interpolation and Splines + demo (Squirrel Eiserloh)\r\n//\r\n\r\n// Power Easings\r\n//\r\n// IN\r\n//\r\nfunction easeLinear(p) {\r\n return p;\r\n} // p^1\r\nfunction easeInQuadratic(p) {\r\n return p * p;\r\n} // p^2 = Math.pow(p;2)\r\nfunction easeInCubic(p) {\r\n return p * p * p;\r\n} // p^3 = Math.pow(p;3)\r\nfunction easeInQuartic(p) {\r\n return p * p * p * p;\r\n} // p^4 = Math.pow(p;4)\r\nfunction easeInQuintic(p) {\r\n return p * p * p * p * p;\r\n} // p^5 = Math.pow(p;5)\r\nfunction easeInSextic(p) {\r\n return p * p * p * p * p * p;\r\n} // p^6 = Math.pow(p;6)\r\nfunction easeInSeptic(p) {\r\n return p * p * p * p * p * p * p;\r\n} // p^7 = Math.pow(p;7)\r\nfunction easeInOctic(p) {\r\n return p * p * p * p * p * p * p * p;\r\n} // p^8 = Math.pow(p;8)\r\n//\r\n// OUT\r\n//\r\nfunction easeOutQuadratic(p) {\r\n var m = p - 1;\r\n return 1 - m * m;\r\n}\r\nfunction easeOutCubic(p) {\r\n var m = p - 1;\r\n return 1 + m * m * m;\r\n}\r\nfunction easeOutQuartic(p) {\r\n var m = p - 1;\r\n return 1 - m * m * m * m;\r\n}\r\nfunction easeOutQuintic(p) {\r\n var m = p - 1;\r\n return 1 + m * m * m * m * m;\r\n}\r\nfunction easeOutSextic(p) {\r\n var m = p - 1;\r\n return 1 - m * m * m * m * m * m;\r\n}\r\nfunction easeOutSeptic(p) {\r\n var m = p - 1;\r\n return 1 + m * m * m * m * m * m * m;\r\n}\r\nfunction easeOutOctic(p) {\r\n var m = p - 1;\r\n return 1 - m * m * m * m * m * m * m * m;\r\n}\r\n//\r\n// INOUT\r\n//\r\nfunction easeInOutQuadratic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t;\r\n return 1 - m * m * 2;\r\n}\r\nfunction easeInOutCubic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t;\r\n return 1 + m * m * m * 4;\r\n}\r\nfunction easeInOutQuartic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t * t;\r\n return 1 - m * m * m * m * 8;\r\n}\r\nfunction easeInOutQuintic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t * t * t;\r\n return 1 + m * m * m * m * m * 16;\r\n}\r\nfunction easeInOutSextic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t * t * t * t;\r\n return 1 - m * m * m * m * m * m * 32;\r\n}\r\nfunction easeInOutSeptic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t * t * t * t * t;\r\n return 1 + m * m * m * m * m * m * m * 64;\r\n}\r\nfunction easeInOutOctic(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return p * t * t * t * t * t * t * t;\r\n return 1 - m * m * m * m * m * m * m * m * 128;\r\n}\r\n//\r\n// Back\r\n//\r\nfunction easeInBack(p) {\r\n var k = 1.70158;\r\n return p * p * (p * (k + 1) - k);\r\n}\r\nfunction easeInOutBack(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n var k = 1.70158 * 1.525;\r\n if (p < 0.5) return p * t * (t * (k + 1) - k);\r\n else return 1 + 2 * m * m * (2 * m * (k + 1) + k);\r\n} // NOTE: Can go negative! i.e. p = 0.008\r\nfunction easeOutBack(p) {\r\n var m = p - 1;\r\n var k = 1.70158;\r\n return 1 + m * m * (m * (k + 1) + k);\r\n}\r\n\r\n//\r\n// Circle\r\n//\r\nfunction easeInCircle(p) {\r\n return 1 - Math.sqrt(1 - p * p);\r\n}\r\nfunction easeInOutCircle(p) {\r\n var m = p - 1;\r\n var t = p * 2;\r\n if (t < 1) return (1 - Math.sqrt(1 - t * t)) * 0.5;\r\n else return (Math.sqrt(1 - 4 * m * m) + 1) * 0.5;\r\n}\r\nfunction easeOutCircle(p) {\r\n var m = p - 1;\r\n return Math.sqrt(1 - m * m);\r\n}\r\n\r\n//\r\n// elastic\r\n//\r\nfunction easeInElastic(t) {\r\n return -(1.0 * Math.pow(2, 10 * t) * Math.sin((t - 1.0 - 0.075) * 2.0 * Math.PI / 0.3));\r\n}\r\nfunction easeOutElastic(t) {\r\n return Math.pow(2.0, -10.0 * t) * Math.sin((t - 0.3 / 4.0) * (2.0 * Math.PI) / 0.3) + 1.0;\r\n}\r\nfunction easeInOutElastic(t) {\r\n return (t *= 2) < 1.0\r\n ? -0.5 * (1.0 * Math.pow(2, 10 * t)) * Math.sin((t - 1.0 - 0.45) * 2.0 * Math.PI / 0.45)\r\n : 1.0 * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - 0.45) * 2.0 * Math.PI / 0.45) * 0.5 + 1;\r\n}\r\n\r\n// Bounce\r\nfunction easeOutBounce(t) {\r\n if (t < 1 / 2.75) {\r\n return 7.5625 * t * t;\r\n } else if (t < 2 / 2.75) {\r\n return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;\r\n } else if (t < 2.5 / 2.75) {\r\n return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;\r\n } else {\r\n return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\r\n }\r\n}\r\nfunction easeInBounce(t) {\r\n if ((t = 1 - t) < 1 / 2.75) {\r\n return 1 - 7.5625 * t * t;\r\n } else if (t < 2 / 2.75) {\r\n return 1 - (7.5625 * (t -= 1.5 / 2.75) * t + 0.75);\r\n } else if (t < 2.5 / 2.75) {\r\n return 1 - (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375);\r\n } else {\r\n return 1 - (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375);\r\n }\r\n}\r\nfunction easeInOutBounce(t) {\r\n var invert;\r\n if (t < 0.5) {\r\n invert = true;\r\n t = 1 - t * 2;\r\n } else {\r\n t = t * 2 - 1;\r\n }\r\n if (t < 1 / 2.75) {\r\n t = 7.5625 * t * t;\r\n } else if (t < 2 / 2.75) {\r\n t = 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;\r\n } else if (t < 2.5 / 2.75) {\r\n t = 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;\r\n } else {\r\n t = 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\r\n }\r\n return invert ? (1 - t) * 0.5 : t * 0.5 + 0.5;\r\n}\r\n\r\nexport default {\r\n easeLinear: easeLinear,\r\n\r\n easeOutQuad: easeOutQuadratic,\r\n easeInQuad: easeInQuadratic,\r\n easeInOutQuad: easeInOutQuadratic,\r\n\r\n easeOutCubic: easeOutCubic,\r\n easeInCubic: easeInCubic,\r\n easeInOutCubic: easeInOutCubic,\r\n\r\n easeOutQuart: easeOutQuartic,\r\n easeInQuart: easeInQuartic,\r\n easeInOutQuart: easeInOutQuartic,\r\n\r\n easeOutQuintic: easeOutQuintic,\r\n easeInQuintic: easeInQuintic,\r\n easeInOutQuintic: easeInOutQuintic,\r\n\r\n easeOutSextic: easeOutSextic,\r\n easeInSextic: easeInSextic,\r\n easeInOutSextic: easeInOutSextic,\r\n\r\n easeOutSeptic: easeOutSeptic,\r\n easeInSeptic: easeInSeptic,\r\n easeInOutSeptic: easeInOutSeptic,\r\n\r\n easeOutOctic: easeOutOctic,\r\n easeInOctic: easeInOctic,\r\n easeInOutOctic: easeInOutOctic,\r\n\r\n easeOutBack: easeOutBack,\r\n easeInBack: easeInBack,\r\n easeInOutBack: easeInOutBack,\r\n\r\n easeOutCircle: easeOutCircle,\r\n easeInCircle: easeInCircle,\r\n easeInOutCircle: easeInOutCircle,\r\n\r\n easeOutElastic: easeOutElastic,\r\n easeInElastic: easeInElastic,\r\n easeInOutElastic: easeInOutElastic,\r\n\r\n easeOutBounce: easeOutBounce,\r\n easeInBounce: easeInBounce,\r\n easeInOutBounce: easeInOutBounce\r\n};\r\n","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Target from './target';\r\n\r\nvar StackedMatrix = function(name, matrix) {\r\n Object.call(this);\r\n this._target = Target.createMatrixTarget(matrix || mat4.IDENTITY);\r\n if (name) this.setName(name);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StackedMatrix,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(matrix) {\r\n this.setMatrix(matrix);\r\n mat4.copy(this._target.defaultValue, matrix);\r\n },\r\n\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n\r\n getMatrix: function() {\r\n return this._target.value;\r\n },\r\n\r\n setMatrix: function(m) {\r\n mat4.copy(this._target.value, m);\r\n },\r\n\r\n resetToDefaultValue: function() {\r\n this.setMatrix(this._target.defaultValue);\r\n },\r\n\r\n applyToMatrix: function(m) {\r\n mat4.mul(m, m, this._target.value);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'StackedMatrix'\r\n);\r\n\r\nexport default StackedMatrix;\r\n","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport Target from './target';\r\n\r\nvar qIdentity = quat.create();\r\n\r\nvar StackedQuaternion = function(name, q) {\r\n Object.call(this);\r\n this._target = Target.createQuatTarget(q || qIdentity);\r\n if (name) this.setName(name);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StackedQuaternion,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(q) {\r\n this.setQuaternion(q);\r\n quat.copy(this._target.defaultValue, q);\r\n },\r\n\r\n setQuaternion: function(q) {\r\n quat.copy(this._target.value, q);\r\n },\r\n\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n\r\n resetToDefaultValue: function() {\r\n this.setQuaternion(this._target.defaultValue);\r\n },\r\n\r\n applyToMatrix: (function() {\r\n var matrixTmp = mat4.create();\r\n\r\n return function applyToMatrix(m) {\r\n var mtmp = matrixTmp;\r\n mat4.fromQuat(mtmp, this._target.value);\r\n mat4.mul(m, m, mtmp);\r\n };\r\n })()\r\n }),\r\n 'osgAnimation',\r\n 'StackedQuaternion'\r\n);\r\n\r\nexport default StackedQuaternion;\r\n","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport Target from './target';\r\n\r\nvar StackedRotateAxis = function(name, axis, angle) {\r\n Object.call(this);\r\n this._axis = vec3.fromValues(0, 0, 1);\r\n if (axis) vec3.copy(this._axis, axis);\r\n this._target = Target.createFloatTarget(typeof angle === 'number' ? angle : 0.0);\r\n if (name) this.setName(name);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StackedRotateAxis,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(axis, angle) {\r\n this.setAxis(axis);\r\n this.setAngle(angle);\r\n this._target.defaultValue = angle;\r\n },\r\n\r\n setAxis: function(axis) {\r\n vec3.copy(this._axis, axis);\r\n },\r\n\r\n setAngle: function(angle) {\r\n this._target.value = angle;\r\n },\r\n\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n\r\n resetToDefaultValue: function() {\r\n this.setAngle(this._target.defaultValue);\r\n },\r\n\r\n applyToMatrix: (function() {\r\n var matrixTmp = mat4.create();\r\n var quatTmp = quat.create();\r\n\r\n return function(m) {\r\n var axis = this._axis;\r\n var qtmp = quatTmp;\r\n var mtmp = matrixTmp;\r\n var angle = this._target.value;\r\n\r\n quat.setAxisAngle(qtmp, axis, angle);\r\n mat4.fromQuat(mtmp, qtmp);\r\n mat4.mul(m, m, mtmp);\r\n };\r\n })()\r\n }),\r\n 'osgAnimation',\r\n 'StackedRotateAxis'\r\n);\r\n\r\nexport default StackedRotateAxis;\r\n","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Target from './target';\r\n\r\nvar StackedScale = function(name, scale) {\r\n Object.call(this);\r\n this._target = Target.createVec3Target(scale || vec3.ONE);\r\n if (name) this.setName(name);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StackedScale,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(scale) {\r\n this.setScale(scale);\r\n vec3.copy(this._target.defaultValue, scale);\r\n },\r\n\r\n setScale: function(scale) {\r\n vec3.copy(this._target.value, scale);\r\n },\r\n\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n\r\n resetToDefaultValue: function() {\r\n this.setScale(this._target.defaultValue);\r\n },\r\n\r\n // must be optimized\r\n applyToMatrix: function(m) {\r\n var scale = this._target.value;\r\n mat4.scale(m, m, scale);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'StackedScale'\r\n);\r\n\r\nexport default StackedScale;\r\n","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Target from './target';\r\n\r\n/**\r\n * StackedTranslate\r\n */\r\nvar StackedTranslate = function(name, translate) {\r\n Object.call(this);\r\n this._target = Target.createVec3Target(translate || vec3.ZERO);\r\n if (name) this.setName(name);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StackedTranslate,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(translate) {\r\n this.setTranslate(translate);\r\n vec3.copy(this._target.defaultValue, translate);\r\n },\r\n\r\n setTranslate: function(translate) {\r\n vec3.copy(this._target.value, translate);\r\n },\r\n\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n\r\n resetToDefaultValue: function() {\r\n this.setTranslate(this._target.defaultValue);\r\n },\r\n\r\n applyToMatrix: function(m) {\r\n mat4.translate(m, m, this._target.value);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'StackedTranslate'\r\n);\r\n\r\nexport default StackedTranslate;\r\n","import utils from '../osg/utils';\r\nimport Animation from './animation';\r\nimport SkinningAttribute from './SkinningAttribute';\r\nimport AnimationUpdateCallback from './AnimationUpdateCallback';\r\nimport BasicAnimationManager from './BasicAnimationManager';\r\nimport Bone from './Bone';\r\nimport Channel from './channel';\r\nimport CollectAnimationUpdateCallbackVisitor from './CollectAnimationUpdateCallbackVisitor';\r\nimport Easing from './easing';\r\nimport Interpolator from './interpolator';\r\nimport MorphAttribute from './MorphAttribute';\r\nimport MorphGeometry from './MorphGeometry';\r\nimport RigGeometry from './RigGeometry';\r\nimport Skeleton from './Skeleton';\r\nimport StackedMatrix from './StackedMatrix';\r\nimport StackedQuaternion from './StackedQuaternion';\r\nimport StackedRotateAxis from './StackedRotateAxis';\r\nimport StackedScale from './StackedScale';\r\nimport StackedTranslate from './StackedTranslate';\r\nimport UpdateBone from './UpdateBone';\r\nimport UpdateMatrixTransform from './UpdateMatrixTransform';\r\nimport UpdateMorph from './UpdateMorph';\r\nimport UpdateSkeleton from './UpdateSkeleton';\r\n\r\nvar osgAnimation = {};\r\n\r\nutils.objectMix(osgAnimation, Easing);\r\nutils.objectMix(osgAnimation, Interpolator);\r\nosgAnimation.Animation = Animation;\r\nosgAnimation.SkinningAttribute = SkinningAttribute;\r\nosgAnimation.AnimationUpdateCallback = AnimationUpdateCallback;\r\nosgAnimation.BasicAnimationManager = BasicAnimationManager;\r\nosgAnimation.Bone = Bone;\r\nosgAnimation.Channel = Channel;\r\nosgAnimation.CollectAnimationUpdateCallbackVisitor = CollectAnimationUpdateCallbackVisitor;\r\nosgAnimation.MorphAttribute = MorphAttribute;\r\nosgAnimation.MorphGeometry = MorphGeometry;\r\nosgAnimation.RigGeometry = RigGeometry;\r\nosgAnimation.Skeleton = Skeleton;\r\nosgAnimation.StackedMatrix = StackedMatrix;\r\nosgAnimation.StackedQuaternion = StackedQuaternion;\r\nosgAnimation.StackedRotateAxis = StackedRotateAxis;\r\nosgAnimation.StackedScale = StackedScale;\r\nosgAnimation.StackedTranslate = StackedTranslate;\r\nosgAnimation.UpdateBone = UpdateBone;\r\nosgAnimation.UpdateMatrixTransform = UpdateMatrixTransform;\r\nosgAnimation.UpdateMorph = UpdateMorph;\r\nosgAnimation.UpdateSkeleton = UpdateSkeleton;\r\n\r\nexport default osgAnimation;\r\n","import osg from \"../osg/osg\";\r\nimport osgAnimation from \"../osgAnimation/osgAnimation\";\r\n\r\nexport default (nodes) => {\r\n for (let index = 0, len = nodes.length; index < len; ++index) {\r\n var updator,\r\n node = nodes[index];\r\n if (node instanceof osgAnimation.Bone) updator = osgAnimation.UpdateBone;\r\n else {\r\n if (!(node instanceof osg.MatrixTransform)) continue;\r\n updator = osgAnimation.UpdateMatrixTransform;\r\n }\r\n let callbacks = node.getUpdateCallbackList();\r\n for (let callbackIdx = 0; callbackIdx < callbacks.length; ++callbackIdx)\r\n if (callbacks[callbackIdx] instanceof updator) return true;\r\n }\r\n return false;\r\n};\r\n","import GLState from '../GLState.js';\r\nimport osg from \"../../osg/osg\";\r\nimport osgUtil from \"../../osgUtil/osgUtil\";\r\nimport osgAnimation from \"../../osgAnimation/osgAnimation\";\r\n\r\nimport PickMask from '../PickMask.js';\r\nimport RenderDetail from '../RenderDetail.js';\r\nimport UpdateCallbackChecker from '../UpdateCallbackChecker.js';\r\nimport {Model} from 'backbone'\r\n\r\n\r\nconst ComposerPostProcess = osgUtil.ComposerPostProcess;\r\n\r\nclass PathCallback {\r\n constructor(path) {\r\n this._path = path;\r\n }\r\n update(visitor) {\r\n visitor.setMatrix(osg.computeLocalToWorld(this._path));\r\n return PathCallback;\r\n }\r\n}\r\n\r\nconst STATE_ATTRIBUTE_OVERRIDE_ON = osg.StateAttribute.OVERRIDE_ON;\r\n\r\nclass OutlineNode extends osg.Node {\r\n constructor(app) {\r\n super();\r\n this._app = app\r\n this._viewerOSGJS = app.getViewerOSGJS()\r\n this._durationOutline = 5e3\r\n this._timerOutline = undefined\r\n this._durationHighlight = 5e3\r\n this._timerHighlight = undefined\r\n this._nodeProxy = new osg.Node()\r\n this._nodeProxy.setName('Outline Node Proxy');\r\n this._outlineScene = new osg.Node()\r\n this._outlineScene.setName('Outline Scene Node')\r\n this._paths = undefined\r\n this._cbHideHighlight = this.hideHighlight.bind(this)\r\n this._cbHideOutline = this.hideOutline.bind(this)\r\n const GL_DEPTH_DISABLE = GLState.DEPTH_DISABLE\r\n this._stateSetSelection = new osg.StateSet()\r\n this._uColorSelection = osg.Uniform.createFloat3('uOutlineColor')\r\n this._stateSetSelection.addUniform(this._uColorSelection)\r\n this._stateSetSelection.setAttributeAndModes(\r\n GL_DEPTH_DISABLE,\r\n STATE_ATTRIBUTE_OVERRIDE_ON,\r\n )\r\n this._stateSetHover = new osg.StateSet()\r\n this._uColorHover = osg.Uniform.createFloat3('uOutlineColor')\r\n this._stateSetHover.addUniform(this._uColorHover),\r\n this._stateSetHover.setAttributeAndModes(\r\n GL_DEPTH_DISABLE,\r\n STATE_ATTRIBUTE_OVERRIDE_ON,\r\n )\r\n this._uOutlineFactor = osg.Uniform.createFloat(0.25, 'uOutlineFactor')\r\n this._uHighlightFactor = osg.Uniform.createFloat(0, 'uHighlightFactor')\r\n this._uLineWidth = osg.Uniform.createFloat(1, 'uLineWidth')\r\n this.init()\r\n }\r\n\r\n getComposer() {\r\n return this._composer;\r\n }\r\n\r\n setColorSelection(color) {\r\n osg.vec3.copy(this._uColorSelection.getInternalArray(), color);\r\n }\r\n\r\n setColorHover(color) {\r\n osg.vec3.copy(this._uColorHover.getInternalArray(), color);\r\n }\r\n\r\n setDurationHighlight(highlight) {\r\n this._durationHighlight = highlight;\r\n }\r\n setDurationOutline(duration) {\r\n this._durationOutline = duration;\r\n }\r\n setOutlineWidth(width) {\r\n this._uLineWidth.getInternalArray()[0] = width;\r\n }\r\n showOutline() {\r\n //Yn.setOutline(true),\r\n this._nodeProxy.setNodeMask(PickMask.NO_PICK_NO_SHADOW)\r\n this._clearTimeoutOutline()\r\n if (this._durationOutline >= 0) {\r\n this._timerOutline = setTimeout(\r\n this._cbHideOutline,\r\n this._durationOutline,\r\n ) \r\n }\r\n this._uHighlightFactor.setFloat(0 !== this._durationHighlight ? 0.15 : 0),\r\n this._clearTimeoutHighlight()\r\n if (this._durationHighlight >= 0 && this._durationHighlight < this._durationOutline) {\r\n this._timerHighlight = setTimeout(\r\n this._cbHideHighlight,\r\n this._durationHighlight,\r\n ) \r\n } \r\n this._app._frameManager.draw();\r\n }\r\n hideOutline() {\r\n this._nodeProxy.setNodeMask(0)\r\n this._clearTimeoutOutline()\r\n this.hideHighlight()\r\n this._app._frameManager.draw()\r\n }\r\n hideHighlight() {\r\n this._uHighlightFactor.setFloat(0)\r\n this._clearTimeoutHighlight()\r\n this._app._frameManager.draw()\r\n }\r\n _clearTimeoutOutline() {\r\n undefined !== this._timerOutline &&\r\n (clearTimeout(this._timerOutline), (this._timerOutline = undefined));\r\n }\r\n _clearTimeoutHighlight() {\r\n undefined !== this._timerHighlight &&\r\n (clearTimeout(this._timerHighlight), (this._timerHighlight = undefined));\r\n }\r\n clearOutlineScene() {\r\n for (\r\n var scene = this._outlineScene,\r\n children = scene.getChildren(),\r\n index = 0,\r\n n = children.length; index < n;\r\n ++index\r\n ) {\r\n var child = children[index];\r\n child.getChildren()[0].removeChildren(), child.removeChildren();\r\n }\r\n scene.removeChildren();\r\n }\r\n _getMaterialNode(node) {\r\n var stateset = node.getStateSet();\r\n return stateset && stateset.getAttribute('PBRMaterial') ?\r\n stateset :\r\n undefined;\r\n }\r\n _getLastMaterialPath(e, t) {\r\n for (var i = t || 0, n = e.length - 1; n >= i; --n) {\r\n var r = this._getMaterialNode(e[n]);\r\n if (r) return r;\r\n }\r\n }\r\n addPaths(pathnodesArray, isHover) {\r\n for (\r\n let scene = this._outlineScene,\r\n stateset = isHover ? this._stateSetHover : this._stateSetSelection,\r\n r = 0,\r\n a = pathnodesArray.length; r < a;\r\n ++r\r\n ) {\r\n let pathnodes = pathnodesArray[r]\r\n let matrixtransform = new osg.MatrixTransform()\r\n let logicnode = new osg.Node()\r\n scene.addChild(matrixtransform)\r\n matrixtransform.addChild(logicnode)\r\n var node = pathnodes[pathnodes.length - 1]\r\n logicnode.addChild(node)\r\n matrixtransform.setStateSet(stateset)\r\n this._getMaterialNode(node) ||\r\n logicnode.setStateSet(this._getLastMaterialPath(pathnodes))\r\n UpdateCallbackChecker(pathnodes) ?\r\n matrixtransform.addUpdateCallback(new PathCallback(pathnodes)) :\r\n matrixtransform.setMatrix(osg.computeLocalToWorld(pathnodes))\r\n }\r\n }\r\n addPathsHover(pathnodesArray) {\r\n this.addPaths(pathnodesArray, true);\r\n }\r\n createSubSceneRtt(e) {\r\n let camera = new osg.Camera()\r\n camera.setName('Outline Camera')\r\n camera.setClearColor(osg.vec4.create())\r\n camera.setRenderOrder(osg.Camera.PRE_RENDER, 0)\r\n camera.attachTexture(osg.FrameBufferObject.COLOR_ATTACHMENT0, e)\r\n let camerastateset = camera.getOrCreateStateSet(); // setAttribute(new VertexCompresoin), attributeType: \"VertexCompression\",\r\n camerastateset.setShaderGeneratorName(\r\n 'outline',\r\n STATE_ATTRIBUTE_OVERRIDE_ON,\r\n );\r\n return camera;\r\n }\r\n init() {\r\n var glCullDisable = GLState.CULL_DISABLE;\r\n this._outlineScene\r\n .getOrCreateStateSet()\r\n .setAttributeAndModes(glCullDisable, STATE_ATTRIBUTE_OVERRIDE_ON);\r\n let outlineComposer = this._createComposer();\r\n this._composer = outlineComposer;\r\n let outlineTexture = outlineComposer.getInternalTexture('TextureOutline')\r\n let cameraRTT = this.createSubSceneRtt(outlineTexture)\r\n this._cameraRtt = cameraRTT\r\n cameraRTT.addChild(this._outlineScene),\r\n this._nodeProxy.addChild(cameraRTT),\r\n this._nodeProxy.addChild(outlineComposer),\r\n this.addChild(this._nodeProxy),\r\n this._nodeProxy.setNodeMask(0);\r\n }\r\n _createComposer() {\r\n const composer = new ComposerPostProcess();\r\n const viewerosg = this._viewerOSGJS;\r\n composer.setMethodWrapUV(1, 1);\r\n composer.setScreenSize(\r\n viewerosg.getCanvasWidth(),\r\n viewerosg.getCanvasHeight(),\r\n );\r\n composer.setFinalPassUpScaleToScreen(false);\r\n composer.addInternalTexture({\r\n name: 'TextureOutline',\r\n immuable: true,\r\n srgb: true,\r\n rgbm: false,\r\n });\r\n composer.build({\r\n func: 'outline',\r\n textures: ['TextureOutline'],\r\n uniforms: [\r\n this._uOutlineFactor,\r\n this._uHighlightFactor,\r\n this._uLineWidth,\r\n ],\r\n out: {\r\n name: '%next',\r\n },\r\n });\r\n const composerPassOutlineStateset = composer.getStateSetPass('outline');\r\n const blendSub = GLState.BLEND_SUBSTRACTIVE;\r\n composerPassOutlineStateset.setAttributeAndModes(blendSub);\r\n composerPassOutlineStateset.setRenderBinDetails(RenderDetail.OUTLINE, 'RenderBin');\r\n this._app.getEventEmitter().on('resizeCanvas', composer.resize.bind(composer));\r\n this._app.getEventEmitter().on('resizeRatio', composer.resizeRatio.bind(composer));\r\n return composer;\r\n }\r\n}\r\n\r\nconst tempBoundingbox = new osg.BoundingBox();\r\n\r\nclass EditorComputeBoundsVisitor extends osg.ComputeBoundsVisitor {\r\n constructor(e) {\r\n super();\r\n this._paths = [];\r\n this.setStateSet(e);\r\n }\r\n reset() {\r\n osg.ComputeBoundsVisitor.prototype.reset.call(this);\r\n this._pushIfGeo = false;\r\n this._paths.length = 0;\r\n this._bonesBoxMatrix = {};\r\n this._usedBones = {};\r\n }\r\n setStateSet(stateset) {\r\n this.reset(), (this._stateSet = stateset);\r\n }\r\n getBoundingBox() {\r\n for (var bone in this._usedBones) {\r\n const bonematrix = this._bonesBoxMatrix[bone];\r\n bonematrix &&\r\n (tempBoundingbox.copy(bonematrix.box),\r\n tempBoundingbox.transformMat4(tempBoundingbox, bonematrix.matrix),\r\n this._bb.expandByBoundingBox(tempBoundingbox));\r\n }\r\n return this._bb;\r\n }\r\n apply(node) {\r\n const statsset = node.getStateSet(),\r\n pushIfGeo = this._pushIfGeo;\r\n if (statsset) {\r\n this._pushIfGeo = statsset === this._stateSet;\r\n }\r\n if (this._pushIfGeo && node instanceof osg.Geometry) {\r\n this._paths.push(this.nodePath.slice(0));\r\n if (node instanceof osgAnimation.RigGeometry) {\r\n var nameids = node.getBoneNameID();\r\n for (var key in nameids) this._usedBones[key] = 1;\r\n }\r\n }\r\n osg.ComputeBoundsVisitor.prototype.apply.call(this, node);\r\n this._pushIfGeo = pushIfGeo;\r\n }\r\n pushMatrix(matrix) {\r\n var lastnode = this.nodePath[this.nodePath.length - 1];\r\n if (lastnode instanceof osgAnimation.Bone) {\r\n var bb = lastnode.getBoneBoundingBox();\r\n bb.valid() &&\r\n (this._bonesBoxMatrix[lastnode.getName()] = {\r\n matrix: osg.mat4.clone(matrix),\r\n box: bb,\r\n });\r\n }\r\n osg.ComputeBoundsVisitor.prototype.pushMatrix.call(this, matrix);\r\n }\r\n applyBoundingBox(bb) {\r\n this._pushIfGeo &&\r\n osg.ComputeBoundsVisitor.prototype.applyBoundingBox.call(this, bb);\r\n }\r\n}\r\n\r\nconst editorBoundsVisitor = new EditorComputeBoundsVisitor();\r\n\r\nexport default class OutLine {\r\n constructor(appviewer) {\r\n this._viewer = appviewer;\r\n this._viewerOSGJS = this._viewer.getViewerOSGJS();\r\n var model = new Model({\r\n colorHover:[1,0,0],\r\n outlineWidth: 2,\r\n colorSelection:[1,1,0], \r\n durationOutline: 1e3 * 2,\r\n durationHighlight: 1e3 * 2\r\n })\r\n this.model = model;\r\n model.on('change:colorSelection', this.onColorSelectionChanged, this)\r\n model.on('change:colorHover', this.onColorHoverChanged, this)\r\n model.on('change:outlineWidth', this.onOutlineWiddthChanged, this)\r\n model.on('hideOutline', this.onHideOutline, this)\r\n model.on('hideHighlight', this.onHideHighlight, this)\r\n model.on('clearFocusTimeout', this.onClearFocusTimeout, this)\r\n this._nodeOutline = new OutlineNode(this._viewer)\r\n this._nodeOutline.setName('Feature - Outline')\r\n this.onColorSelectionChanged()\r\n this.onColorHoverChanged()\r\n this.onOutlineWiddthChanged()\r\n this.model.on(\r\n 'displayOutlineFocus',\r\n this._onMaterialChange.bind(this, true),\r\n )\r\n this.model.on(\r\n 'displayOutlineNoFocus',\r\n this._onMaterialChange.bind(this, false),\r\n )\r\n }\r\n getNode() {\r\n return this._nodeOutline;\r\n }\r\n getNodeOutline() {\r\n return this._nodeOutline;\r\n }\r\n onColorSelectionChanged() {\r\n this._nodeOutline.setColorSelection(this.model.get(\"colorSelection\"));\r\n }\r\n onColorHoverChanged() {\r\n this._nodeOutline.setColorHover(this.model.get(\"colorHover\"));\r\n }\r\n onOutlineWiddthChanged() {\r\n\r\n this._nodeOutline.setOutlineWidth(this.model.get(\"outlineWidth\"));\r\n }\r\n onHideOutline() {\r\n this._nodeOutline.hideOutline();\r\n }\r\n onHideHighlight() {\r\n this._nodeOutline.hideHighlight();\r\n }\r\n onClearFocusTimeout() {\r\n this._timer &&\r\n (window.clearTimeout(this._timer), (this._timer = undefined));\r\n }\r\n _focusOnBound(e) {\r\n const featureManager = this._viewer.getFeaturesManager();\r\n const bb = e.getBoundingBox();\r\n const nodeoutline = this._nodeOutline;\r\n this.onClearFocusTimeout();\r\n this._timer = window.setTimeout(function() {\r\n featureManager.focusOnBound(bb, 1) ||\r\n featureManager.focusOnHomePosition(1),\r\n nodeoutline.showOutline();\r\n }, 200);\r\n }\r\n _onMaterialChange(focus, outlineStateset, hoverStateset) {\r\n var featureManager = this._viewer.getFeaturesManager();\r\n if (featureManager) {\r\n editorBoundsVisitor.setStateSet(outlineStateset || hoverStateset);\r\n //n.getWorldNode().accept(editorBoundsVisitor);\r\n featureManager.getRootModel().accept(editorBoundsVisitor);\r\n var pathNodes = editorBoundsVisitor._paths;\r\n if (pathNodes.length !== 0) {\r\n focus && this._focusOnBound(editorBoundsVisitor);\r\n this._nodeOutline.clearOutlineScene();\r\n if (outlineStateset) {\r\n this._nodeOutline.addPaths(pathNodes);\r\n if (hoverStateset) {\r\n editorBoundsVisitor.setStateSet(hoverStateset),\r\n featureManager.getRootModel().accept(editorBoundsVisitor);\r\n this._nodeOutline.addPathsHover(editorBoundsVisitor._paths);\r\n }\r\n } else {\r\n this._nodeOutline.addPathsHover(pathNodes);\r\n }\r\n this._nodeOutline.setDurationOutline(this.model.get(\"durationOutline\"))\r\n this._nodeOutline.setDurationHighlight(this.model.get(\"durationHighlight\"))\r\n focus || this._nodeOutline.showOutline();\r\n } else osg.warn();('Cound not find nodes attached to the stateset.');\r\n }\r\n //displayGraph()\r\n }\r\n prepareForScreenShot () {\r\n this.getNode().hideOutline()\r\n return false;\r\n }\r\n}","import osg from '../osg/osg';\r\n\r\nexport default class FrameManager {\r\n constructor(){\r\n this.mFrame = -1\r\n this.duration = 0\r\n this.poseForScreenShot = false\r\n this.viewer = null\r\n this.preTick = osg.Timer.instance().tick()\r\n this.frameTimeAverage = 40\r\n this.shadowForcedUpdate = false; // shadow force update\r\n this.superSample = null\r\n window.setTimeout(this.SuperSampleTrigger.bind(this), this.frameTimeAverage);\r\n }\r\n\r\n SuperSampleTrigger () {\r\n window.setTimeout(this.SuperSampleTrigger.bind(this), this.frameTimeAverage);\r\n if (this.viewer && this.superSample) {\r\n if (!this.poseForScreenShot && !this.viewer._requestRedraw) {\r\n if ( osg.Timer.instance().tick() - this.preTick - this.frameTimeAverage <= this.frameTimeAverage )\r\n return;\r\n this.superSample.enable();\r\n this.mFrame = -1;\r\n }\r\n }\r\n }\r\n\r\n _drawImpl (isSameFrame) {\r\n if (this.viewer && !this.poseForScreenShot) {\r\n var isDrawAlreadyQueued = this.viewer._requestRedraw;;\r\n if (\r\n (isDrawAlreadyQueued || this.viewer.requestRedraw(),\r\n this.superSample &&\r\n !isSameFrame &&\r\n (this.superSample.reset(), !isDrawAlreadyQueued))\r\n ) {\r\n var currentTick = osg.Timer.instance().tick();\r\n (this.duration += currentTick - this.preTick),\r\n 0 === ++this.mFrame\r\n ? ((this.mFrame = 0), (this.duration = 0))\r\n : 4 === this.mFrame &&\r\n ((this.frameTimeAverage = Math.min(\r\n 200,\r\n Math.max(16, this.duration / this.mFrame),\r\n )),\r\n (this.mFrame = 0),\r\n (this.duration = 0)),\r\n (this.preTick = currentTick);\r\n }\r\n }\r\n };\r\n\r\n setPoseForScreenshot (screenshot) {\r\n this.poseForScreenShot = screenshot\r\n }\r\n\r\n draw () {\r\n this._drawImpl();\r\n }\r\n drawNoJitter(){\r\n this._doJitter = false\r\n this._drawImpl()\r\n }\r\n\r\n drawSameFrame() {\r\n this._drawImpl(true);\r\n }\r\n\r\n redrawShadow(){\r\n this.shadowForcedUpdate = true;\r\n this._drawImpl();\r\n }\r\n\r\n redrawShadowNextFrame(){\r\n window.setTimeout(this.redrawShadow.bind(this), 0);\r\n }\r\n\r\n getShadowForcedUpdate(){\r\n return this.shadowForcedUpdate\r\n }\r\n setShadowForcedUpdate(value){\r\n this.shadowForcedUpdate = value;\r\n }\r\n\r\n setViewer(viewer) {\r\n this.viewer = viewer\r\n }\r\n\r\n setSuperSample(ss) {\r\n this.superSample = ss\r\n }\r\n\r\n getSuperSample(){\r\n return this.superSample\r\n }\r\n\r\n getFrameTimeAverage(){\r\n return this.frameTimeAverage\r\n }\r\n}\r\n\r\n\r\n","import Config from './Config.js';\r\nimport osg from '../osg/osg';\r\n\r\nconst JITTER_ARRAY = [\r\n [0.263385, -0.0252475],\r\n [-0.38545, 0.054485],\r\n [-0.139795, -0.5379925],\r\n [-0.2793775, 0.6875475],\r\n [0.7139025, 0.4710925],\r\n [0.90044, -0.16422],\r\n [0.4481775, -0.82799],\r\n [-0.9253375, -0.2910625],\r\n [0.3468025, 1.02292],\r\n [-1.13742, 0.33522],\r\n [-0.7676225, -0.9123175],\r\n [-0.2005775, -1.1774125],\r\n [-0.926525, 0.96876],\r\n [1.12909, -0.7500325],\r\n [0.9603, 1.14625],\r\n];\r\n\r\n\r\nexport default class SuperSample {\r\n constructor(app) {\r\n this._canBeEnabled = true;\r\n this._app = app;\r\n this._sampleCount = 15;\r\n this._isFakeSupersampling = false;\r\n this._isSupersampling = false;\r\n this._frameNum = 1;\r\n this._frameNumTaa = 0;\r\n this._switch = true;\r\n this._jitter = this._app.globalUniform.uHalton.getInternalArray();\r\n this._jitter[2] = 1;\r\n }\r\n\r\n getSampleCount() {\r\n return this._sampleCount;\r\n }\r\n\r\n canBeEnabled() {\r\n return this._canBeEnabled;\r\n }\r\n\r\n getSortedJitterTable() {\r\n return JITTER_ARRAY;\r\n }\r\n\r\n getBackgroundModel() {\r\n return this._app.getFeatures().background.getModel();\r\n }\r\n\r\n getAnimationModel() {\r\n return this._app.getFeatures().animation.getModel();\r\n }\r\n\r\n getWireframeAttenuation() {\r\n var wireframeNode = this._app.getOrCreateScene().getWireframeNodes();\r\n if (!wireframeNode.length || 0 === wireframeNode[0].getNodeMask()) return 1;\r\n var alpha = wireframeNode[0]\r\n .getStateSet()\r\n .getUniform('uColor')\r\n .getInternalArray()[3];\r\n return 1 - alpha + 0.05 * alpha;\r\n }\r\n\r\n updateUniforms(framenum, istaa) {\r\n let framemod = framenum % this._sampleCount,\r\n jitter = this.getSortedJitterTable()[framemod],\r\n taascale = istaa ? 0.05 : 1.0; //this.getWireframeAttenuation()\r\n this._jitter[0] = jitter[0] * taascale;\r\n this._jitter[1] = jitter[1] * taascale;\r\n this._jitter[3] = framemod;\r\n }\r\n\r\n setSwitch(switchenable) {\r\n this._switch = switchenable;\r\n }\r\n\r\n isTaaJitter() {\r\n return false;\r\n let mode = this._postProcess.getModel(),\r\n taaEnable = mode.get('taaEnable'),\r\n hasBackground = 'none' !== this.getBackgroundModel().get('enable'),\r\n n = undefined !== Config.taaJitter ? Config.taaJitter : hasBackground,\r\n r = mode.get('webVR'),\r\n a = this.getAnimationModel().canActivateTAA(),\r\n o = 0 === Config.autospin || Config.taaAnimation;\r\n return a && taaEnable && n && !r && o;\r\n }\r\n\r\n updateFrame() {\r\n this._jitter[2] = -this._jitter[2];\r\n this._app.getEventEmitter().trigger('pingPongTexture0', this._jitter[2] > 0);\r\n if (!this._isSupersampling) {\r\n this._jitter[2] = Math.sign(this._jitter[2]);\r\n if (this._app._frameManager._doJitter && this.isTaaJitter()) {\r\n this.updateUniforms(this._frameNumTaa, true);\r\n this._frameNumTaa++;\r\n } else {\r\n this._jitter[0] = 0;\r\n this._jitter[1] = 0;\r\n this._frameNum = 1;\r\n this._frameNumTaa = 0;\r\n }\r\n this._app._frameManager._doJitter = true;\r\n return false;\r\n }\r\n this._app._frameManager._doJitter = true;\r\n var framemod = this._frameNum % this._sampleCount;\r\n this.updateUniforms(framemod);\r\n this._frameNum++;\r\n this.isSupersampled() && (this._isSupersampling = false);\r\n this._isFakeSupersampling = false;\r\n return this._isSupersampling;\r\n }\r\n\r\n getFrameNumber() {\r\n return this._frameNum % this._sampleCount;\r\n }\r\n\r\n update(node, updateVisitor) {\r\n if (!this._switch) return true;\r\n var curFrame = updateVisitor.getFrameStamp().getFrameNumber();\r\n if (this._lastUpdateFrame === curFrame) return true;\r\n this._lastUpdateFrame = curFrame;\r\n if (!this._postProcess) {\r\n this._postProcess = this._app.getFeatures().postProcess;\r\n if (!this._postProcess) {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.updateFrame()) {\r\n this._app._frameManager.drawSameFrame();\r\n }\r\n return true;\r\n\r\n \r\n // return (\r\n // this._lastUpdateFrame === curFrame ||\r\n // ((this._lastUpdateFrame = curFrame),\r\n // (!this._postProcess && ((this._postProcess = this._viewer.getFeatures().postProcess), !this._postProcess)) ||\r\n // (this.updateFrame() && GlobalSetter.drawSameFrame(), true))\r\n // )\r\n \r\n }\r\n\r\n isSupersampled() {\r\n return this._frameNum >= this._sampleCount;\r\n }\r\n\r\n isEnabled() {\r\n return this._isSupersampling;\r\n }\r\n\r\n isFakeEnabled() {\r\n return this._isFakeSupersampling;\r\n }\r\n\r\n forceEnable() {\r\n this._isSupersampling = true;\r\n this._jitter[0] = 0;\r\n this._jitter[1] = 0;\r\n this._jitter[2] = 2 * Math.sign(this._jitter[2]);\r\n this._jitter[3] = 0;\r\n this._frameNum = 1;\r\n this._app._frameManager.drawSameFrame();\r\n }\r\n\r\n enable() {\r\n if (!this.canBeEnabled()) {\r\n if (this._isFakeSupersampling) return true;\r\n this._app._frameManager.drawSameFrame();\r\n return (this._isFakeSupersampling = true);\r\n }\r\n if (1 === this._frameNum) {\r\n this.forceEnable();\r\n }\r\n }\r\n\r\n reset() {\r\n this._jitter[2] = Math.sign(this._jitter[2]);\r\n this._frameNum = 1;\r\n this._isSupersampling = false;\r\n this._isFakeSupersampling = false;\r\n }\r\n\r\n setRoot(rootScene) {\r\n var node = new osg.Node();\r\n rootScene.addChild(node);\r\n node.addUpdateCallback(this);\r\n }\r\n}\r\n","import OrbitManipulatorStandardMouseKeyboardController from './OrbitManipulatorStandardMouseKeyboardController';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\nimport utils from '../osg/utils';\r\n\r\nvar CADManipulatorStandardMouseKeyboardController = function(manipulator) {\r\n OrbitManipulatorStandardMouseKeyboardController.call(this, manipulator);\r\n this._timer = false;\r\n};\r\n\r\nvar ZOOM_OFFSET = 10;\r\nvar PICK_INTERVAL = 200;\r\n\r\nutils.createPrototypeObject(\r\n CADManipulatorStandardMouseKeyboardController,\r\n utils.objectInherit(OrbitManipulatorStandardMouseKeyboardController.prototype, {\r\n _initInputs: function() {\r\n OrbitManipulatorStandardMouseKeyboardController.prototype._initInputs.call(\r\n this,\r\n InputGroups.CAD_MANIPULATOR_MOUSEKEYBOARD,\r\n InputGroups.CAD_MANIPULATOR_RESETTOHOME\r\n );\r\n var manager = this._manipulator.getInputManager();\r\n\r\n manager.group(InputGroups.CAD_MANIPULATOR_MOUSEKEYBOARD).addMappings(\r\n {\r\n savePosition: 'mousemove'\r\n },\r\n this\r\n );\r\n },\r\n\r\n zoom: function(ev) {\r\n var intDelta = -ev.deltaY / this._zoomFactor;\r\n var manipulator = this._manipulator;\r\n var zoomTarget = manipulator.getZoomInterpolator().getTarget()[0] - intDelta;\r\n manipulator.getZoomInterpolator().setTarget(zoomTarget);\r\n if (this._timer === false) {\r\n this._timer = true;\r\n var that = this;\r\n if (this._timerRef) {\r\n clearTimeout(this._timerRef);\r\n }\r\n this._timerRef = setTimeout(function() {\r\n that._timer = false;\r\n }, PICK_INTERVAL);\r\n manipulator.computeIntersections(ev.glX, ev.glY);\r\n }\r\n },\r\n\r\n savePosition: function(ev) {\r\n this._lastX = ev.glX;\r\n this._lastY = ev.glY;\r\n },\r\n\r\n setMode: function(mode, interpolator, ev) {\r\n if (!this._inMotion) {\r\n this._manipulator.computeIntersections(this._lastX, this._lastY);\r\n }\r\n OrbitManipulatorStandardMouseKeyboardController.prototype.setMode.call(\r\n this,\r\n mode,\r\n interpolator,\r\n ev\r\n );\r\n },\r\n\r\n center: function(ev) {\r\n var manipulator = this._manipulator;\r\n manipulator.getZoomInterpolator().set(0.0);\r\n var zoomTarget = manipulator.getZoomInterpolator().getTarget()[0] - ZOOM_OFFSET;\r\n manipulator.getZoomInterpolator().setTarget(zoomTarget);\r\n manipulator.computeIntersections(ev.glX, ev.glY);\r\n }\r\n })\r\n);\r\n\r\nexport default CADManipulatorStandardMouseKeyboardController;\r\n","import OrbitManipulatorHammerController from './OrbitManipulatorHammerController';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\nimport utils from '../osg/utils';\r\n\r\nvar CADManipulatorHammerController = function(manipulator) {\r\n OrbitManipulatorHammerController.call(this, manipulator);\r\n this._timer = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n CADManipulatorHammerController,\r\n utils.objectInherit(OrbitManipulatorHammerController.prototype, {\r\n _initInputs: function() {\r\n OrbitManipulatorHammerController.prototype._initInputs.call(\r\n this,\r\n InputGroups.CAD_MANIPULATOR_TOUCH\r\n );\r\n },\r\n\r\n startMotion: function(interpolator, factor, ev) {\r\n OrbitManipulatorHammerController.prototype.startMotion.call(\r\n this,\r\n interpolator,\r\n factor,\r\n ev\r\n );\r\n this._manipulator.computeIntersections(ev.glX, ev.glY);\r\n }\r\n })\r\n);\r\n\r\nexport default CADManipulatorHammerController;\r\n","import utils from '../osg/utils';\r\nimport Manipulator from './Manipulator';\r\nimport IntersectionVisitor from '../osgUtil/IntersectionVisitor';\r\nimport LineSegmentIntersector from '../osgUtil/LineSegmentIntersector';\r\nimport PolytopeIntersector from '../osgUtil/PolytopeIntersector';\r\nimport ComputeMatrixFromNodePath from '../osg/computeMatrixFromNodePath';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport { vec2 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport CADManipulatorStandardMouseKeyboardController from './CADManipulatorStandardMouseKeyboardController';\r\nimport CADManipulatorHammerController from './CADManipulatorHammerController';\r\nimport DelayInterpolator from '../osgUtil/DelayInterpolator';\r\nimport intersectionEnums from '../osgUtil/intersectionEnums';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\n/**\r\n * CADManipulator\r\n * @class Provides a manipulator with rotation and zoom capacities around a pivot point.\r\n * The pivot point is computed through intersections. If no intersection is computed\r\n * the manipulator uses the last computed pivot point.\r\n * - Mousewheel/Pinch zooms in and out on the pivot point.\r\n * - Double click/tap zooms in on the pivot point.\r\n * - Left click/pan rotates around the pivot point.\r\n * - Center/Right click or two-finger drag moves the view.\r\n * - Spacebar resets the view.\r\n */\r\n\r\nvar CADManipulator = function(options) {\r\n Manipulator.call(this, options);\r\n this._tmpHomePosition = vec3.create();\r\n this._intersectionVisitor = new IntersectionVisitor();\r\n this._lineSegmentIntersector = new LineSegmentIntersector();\r\n this._polytopeIntersector = undefined;\r\n this._usePolytopeIntersector = false;\r\n this._primitiveMask = intersectionEnums.ALL_PRIMITIVES;\r\n this.init();\r\n};\r\n\r\nCADManipulator.Interpolator = function() {\r\n this._current = vec2.create();\r\n this._target = vec2.create();\r\n this._delta = vec2.create();\r\n this._reset = false;\r\n this.reset();\r\n this._width = undefined;\r\n this._height = undefined;\r\n};\r\n\r\nCADManipulator.Interpolator.prototype = {\r\n setWidth: function(width) {\r\n this._width = width;\r\n },\r\n setHeight: function(height) {\r\n this._height = height;\r\n },\r\n reset: function() {\r\n for (var i = 0, l = this._current.length; i < l; i++) {\r\n this._current[i] = this._target[i] = 0;\r\n }\r\n this._reset = true;\r\n },\r\n update: function() {\r\n var d0;\r\n var d1;\r\n if (this._width === undefined) d0 = 0;\r\n else d0 = (this._target[0] - this._current[0]) / this._width;\r\n this._delta[0] = d0;\r\n this._current[0] = this._target[0];\r\n if (this._height === undefined) d1 = 0;\r\n else d1 = (this._target[1] - this._current[1]) / this._height;\r\n this._delta[1] = d1;\r\n this._current[1] = this._target[1];\r\n return this._delta;\r\n },\r\n set: function() {\r\n for (var i = 0, l = this._current.length; i < l; i++) {\r\n this._current[i] = this._target[i] = arguments[i];\r\n }\r\n this._reset = false;\r\n },\r\n isReset: function() {\r\n return this._reset;\r\n },\r\n getCurrent: function() {\r\n return this._current;\r\n },\r\n setTarget: function() {\r\n for (var i = 0, l = this._target.length; i < l; i++) {\r\n if (this._reset) {\r\n this._target[i] = this._current[i] = arguments[i];\r\n } else {\r\n this._target[i] = arguments[i];\r\n }\r\n }\r\n this._reset = false;\r\n },\r\n addTarget: function() {\r\n for (var i = 0; i < arguments.length; i++) {\r\n this._target[i] += arguments[i];\r\n }\r\n },\r\n getTarget: function() {\r\n return this._target;\r\n },\r\n getDelta: function() {\r\n return this._delta;\r\n }\r\n};\r\n\r\nCADManipulator.AvailableControllerList = ['StandardMouseKeyboard', 'Hammer'];\r\nCADManipulator.ControllerList = ['StandardMouseKeyboard', 'Hammer'];\r\n\r\n/** @lends CADManipulator.prototype */\r\nutils.createPrototypeObject(\r\n CADManipulator,\r\n utils.objectInherit(Manipulator.prototype, {\r\n init: function() {\r\n this._distance = 25.0;\r\n this._target = vec3.create();\r\n this._upz = vec3.fromValues(0.0, 0.0, 1.0);\r\n this._right = vec3.fromValues(1.0, 0.0, 0.0);\r\n\r\n vec3.init(this._target);\r\n\r\n var rot1 = mat4.fromRotation(mat4.create(), -Math.PI, this._upz);\r\n var rot2 = mat4.fromRotation(mat4.create(), Math.PI / 10.0, this._right);\r\n this._rotation = mat4.create();\r\n mat4.mul(this._rotation, rot1, rot2);\r\n this._time = 0.0;\r\n\r\n this._rotate = new CADManipulator.Interpolator();\r\n this._pan = new CADManipulator.Interpolator();\r\n this._zoom = new DelayInterpolator(1);\r\n\r\n this._panFactor = 1.5;\r\n this._rotateFactor = 1;\r\n this._zoomFactor = 1;\r\n\r\n this._inverseMatrix = mat4.create();\r\n\r\n this._homeEye = undefined;\r\n this._homeCenter = undefined;\r\n this._homeUp = vec3.fromValues(0.0, 0.0, 1.0);\r\n\r\n this._orientation = quat.create();\r\n this._pivotPoint = vec3.create();\r\n\r\n this._eye = undefined;\r\n\r\n this._zoomDir = vec3.create();\r\n\r\n // instance of controller\r\n var self = this;\r\n\r\n CADManipulator.ControllerList.forEach(function(value) {\r\n if (CADManipulator[value] !== undefined) {\r\n if (self._controllerList[value]) {\r\n self._controllerList[value].init();\r\n } else {\r\n self._controllerList[value] = new CADManipulator[value](self);\r\n }\r\n }\r\n });\r\n },\r\n\r\n setViewer: function(viewer) {\r\n this._viewer = viewer;\r\n },\r\n\r\n reset: function() {\r\n this.init();\r\n },\r\n\r\n setEnable: function(enabled) {\r\n this.getInputManager().setEnable(InputGroups.CAD_MANIPULATOR, enabled);\r\n },\r\n\r\n setNode: function(node) {\r\n this._node = node;\r\n },\r\n\r\n setPivotPoint: function(pivotPoint) {\r\n // First calculate offset\r\n vec3.copy(this._pivotPoint, pivotPoint);\r\n },\r\n\r\n setTarget: (function() {\r\n var eyePos = vec3.create();\r\n return function(target) {\r\n vec3.copy(this._target, target);\r\n this.getEyePosition(eyePos);\r\n this._distance = vec3.distance(target, eyePos);\r\n };\r\n })(),\r\n\r\n setEyePosition: function(eye) {\r\n vec3.copy(this._eye, eye);\r\n this._distance = vec3.distance(this._target, eye);\r\n },\r\n\r\n setHomePosition: function(eye, center, up) {\r\n this._homeEye = eye;\r\n this._homeCenter = center;\r\n this._homeUp = up;\r\n },\r\n\r\n computeHomePosition: (function() {\r\n var f = vec3.create();\r\n var s = vec3.create();\r\n var u = vec3.create();\r\n var result = mat4.create();\r\n return function(boundStrategy) {\r\n var bs = this.getHomeBoundingSphere(boundStrategy);\r\n if (!bs) return;\r\n this.setDistance(this.getHomeDistance(bs));\r\n this.setTarget(bs.center());\r\n this.setPivotPoint(bs.center());\r\n\r\n if (this._homeEye === undefined) {\r\n this._homeEye = vec3.create();\r\n this.getEyePosition(this._homeEye);\r\n }\r\n\r\n if (this._homeCenter === undefined) {\r\n this._homeCenter = vec3.create();\r\n vec3.copy(this._homeCenter, bs.center());\r\n }\r\n\r\n if (this._eye === undefined) {\r\n this._eye = vec3.create();\r\n }\r\n\r\n vec3.copy(this._eye, this._homeEye);\r\n vec3.copy(this._target, this._homeCenter);\r\n vec3.copy(this._upz, this._homeUp);\r\n\r\n mat4.copy(result, this._rotation);\r\n var center = this._target;\r\n var eye = this._eye;\r\n\r\n vec3.sub(f, center, eye);\r\n vec3.normalize(f, f);\r\n\r\n vec3.cross(s, f, this._upz);\r\n vec3.normalize(s, s);\r\n\r\n vec3.cross(u, s, f);\r\n vec3.normalize(u, u);\r\n\r\n // s[0], f[0], u[0], 0.0,\r\n // s[1], f[1], u[1], 0.0,\r\n // s[2], f[2], u[2], 0.0,\r\n // 0, 0, 0, 1.0\r\n result[0] = s[0];\r\n result[1] = u[0];\r\n result[2] = -f[0];\r\n result[3] = 0.0;\r\n result[4] = s[1];\r\n result[5] = u[1];\r\n result[6] = -f[1];\r\n result[7] = 0.0;\r\n result[8] = s[2];\r\n result[9] = u[2];\r\n result[10] = -f[2];\r\n result[11] = 0.0;\r\n result[12] = 0;\r\n result[13] = 0;\r\n result[14] = 0;\r\n result[15] = 1.0;\r\n\r\n mat4.getRotation(this._orientation, result);\r\n quat.invert(this._orientation, this._orientation);\r\n };\r\n })(),\r\n\r\n setZoomFactor: function(f) {\r\n this._zoomFactor = f;\r\n },\r\n\r\n setRotateFactor: function(f) {\r\n this._rotateFactor = f;\r\n },\r\n\r\n setPanFactor: function(f) {\r\n this._panFactor = f;\r\n },\r\n\r\n setDistance: function(d) {\r\n this._distance = d;\r\n },\r\n\r\n // If set to true, intersections are computed against points and lines\r\n setUsePolytopeIntersector: function(upi) {\r\n this._usePolytopeIntersector = upi;\r\n },\r\n\r\n getUsePolytopeIntersector: function() {\r\n return this._usePolytopeIntersector;\r\n },\r\n\r\n getDistance: function() {\r\n return this._distance;\r\n },\r\n\r\n zoom: function(ratio) {\r\n this._distance = ratio;\r\n },\r\n\r\n getRotateInterpolator: function() {\r\n return this._rotate;\r\n },\r\n\r\n getPanInterpolator: function() {\r\n return this._pan;\r\n },\r\n\r\n getZoomInterpolator: function() {\r\n return this._zoom;\r\n },\r\n\r\n getIntersectionVisitor: function() {\r\n return this._intersectionVisitor;\r\n },\r\n\r\n getLineSegmentIntersector: function() {\r\n return this._lineSegmentIntersector;\r\n },\r\n\r\n getOrCreatePolytopeIntersector: function() {\r\n if (this._polytopeIntersector === undefined) {\r\n this._polytopeIntersector = new PolytopeIntersector();\r\n this._polytopeIntersector.setIntersectionLimit(\r\n intersectionEnums.LIMIT_ONE_PER_DRAWABLE\r\n );\r\n this._polytopeIntersector.setPrimitiveMask(\r\n intersectionEnums.POINT_PRIMITIVES | intersectionEnums.LINE_PRIMITIVES\r\n );\r\n }\r\n return this._polytopeIntersector;\r\n },\r\n\r\n getTarget: function(target) {\r\n vec3.copy(target, this._target);\r\n return target;\r\n },\r\n\r\n getEyePosition: function(eye) {\r\n if (this._eye === undefined) this.computeEyePosition(this._target, this._distance, eye);\r\n else vec3.copy(eye, this._eye);\r\n },\r\n\r\n computeEyePosition: (function() {\r\n var tmpDist = vec3.create();\r\n var tmpInverse = mat4.create();\r\n return function(target, distance, eye) {\r\n mat4.invert(tmpInverse, this._rotation);\r\n tmpDist[1] = distance;\r\n vec3.transformMat4(eye, tmpDist, tmpInverse);\r\n vec3.add(eye, target, eye);\r\n };\r\n })(),\r\n\r\n computePan: (function() {\r\n var trans = vec3.create();\r\n var rotPos = vec3.create();\r\n var speedTmp = vec3.create();\r\n return function(dx, dy, rotMat) {\r\n var speed =\r\n vec3.length(vec3.sub(speedTmp, this._eye, this._pivotPoint)) / this._panFactor;\r\n if (speed < 10) speed = 10;\r\n trans[0] = dx * speed / 2;\r\n trans[1] = dy * speed / 2;\r\n trans[2] = 0;\r\n vec3.transformMat4(rotPos, trans, rotMat);\r\n vec3.add(this._eye, this._eye, rotPos);\r\n };\r\n })(),\r\n\r\n computeZoom: (function() {\r\n var vectorDistance = vec3.create();\r\n var speedDist = vec3.create();\r\n return function(dz) {\r\n var zoomSpeed = dz * this._zoomFactor;\r\n vec3.sub(vectorDistance, this._pivotPoint, this._eye);\r\n vec3.add(this._eye, this._eye, vec3.scale(speedDist, vectorDistance, zoomSpeed));\r\n };\r\n })(),\r\n\r\n computeRotation: (function() {\r\n var rightNormalized = vec3.create();\r\n var right = vec3.create();\r\n var dir = vec3.create();\r\n var offset = vec3.create();\r\n var pitchQuat = quat.create();\r\n var yawQuat = quat.create();\r\n var pitchyawQuat = quat.create();\r\n var tmp = vec3.create();\r\n var rightScalar = vec3.create();\r\n\r\n return function(yawDelta, pitchDelta) {\r\n vec3.transformQuat(right, this._right, this._orientation);\r\n vec3.normalize(rightNormalized, right);\r\n vec3.sub(dir, this._eye, this._pivotPoint);\r\n var scalar = vec3.dot(rightNormalized, dir);\r\n vec3.sub(offset, dir, vec3.scale(rightScalar, rightNormalized, scalar));\r\n var xy = vec3.fromValues(-offset[0], -offset[1], 0);\r\n\r\n var positionPitch = Math.atan2(-offset[2], vec3.length(xy));\r\n pitchDelta =\r\n Math.max(\r\n -Math.PI / 2 + 0.01,\r\n Math.min(Math.PI / 2 - 0.01, positionPitch + pitchDelta)\r\n ) - positionPitch;\r\n\r\n quat.setAxisAngle(pitchQuat, right, pitchDelta * this._rotateFactor);\r\n quat.setAxisAngle(yawQuat, this._upz, yawDelta * this._rotateFactor);\r\n\r\n quat.mul(pitchyawQuat, yawQuat, pitchQuat);\r\n vec3.transformQuat(tmp, dir, pitchyawQuat);\r\n vec3.add(this._eye, tmp, this._pivotPoint);\r\n\r\n // Find rotation offset and target\r\n quat.mul(this._orientation, yawQuat, this._orientation);\r\n\r\n vec3.transformQuat(right, this._right, this._orientation);\r\n quat.setAxisAngle(pitchQuat, right, pitchDelta * this._rotateFactor);\r\n quat.mul(this._orientation, pitchQuat, this._orientation);\r\n };\r\n })(),\r\n\r\n update: (function() {\r\n var rotMat = mat4.create();\r\n var transMat = mat4.create();\r\n return function(nv) {\r\n var dt = nv.getFrameStamp().getDeltaTime();\r\n\r\n var mouseFactor = 10;\r\n //Note inverted y\r\n var delta = this._rotate.update();\r\n this.computeRotation(-delta[0] * mouseFactor, delta[1] * mouseFactor);\r\n mat4.fromQuat(rotMat, this._orientation);\r\n\r\n var deltapan = this._pan.update();\r\n this.computePan(-deltapan[0] * mouseFactor, -deltapan[1] * mouseFactor, rotMat);\r\n\r\n delta = this._zoom.update(dt);\r\n this.computeZoom(-delta[0] / 10.0);\r\n\r\n mat4.fromTranslation(transMat, this._eye);\r\n mat4.mul(this._inverseMatrix, transMat, rotMat);\r\n mat4.invert(this._inverseMatrix, this._inverseMatrix);\r\n };\r\n })(),\r\n getInverseMatrix: function() {\r\n return this._inverseMatrix;\r\n },\r\n\r\n computeIntersections: (function() {\r\n var hits = [];\r\n var pTrans = vec3.create();\r\n return function(posX, posY) {\r\n var viewer = this._camera.getView();\r\n\r\n var cam = this._camera;\r\n var width = cam.getViewport().width();\r\n var height = cam.getViewport().height();\r\n this._rotate.setWidth(width);\r\n this._rotate.setHeight(height);\r\n this._pan.setWidth(width);\r\n this._pan.setHeight(height);\r\n\r\n var point, matrix;\r\n if ((this._primitiveMask & intersectionEnums.TRIANGLE_PRIMITIVES) !== 0) {\r\n hits = viewer.computeIntersections(posX, posY);\r\n\r\n if (hits.length > 0) {\r\n point = hits[0]._localIntersectionPoint;\r\n hits[0]._nodePath.shift();\r\n matrix = ComputeMatrixFromNodePath.computeLocalToWorld(hits[0]._nodePath);\r\n vec3.transformMat4(pTrans, point, matrix);\r\n this.setPivotPoint(pTrans);\r\n }\r\n }\r\n\r\n if (hits.length === 0 && this._usePolytopeIntersector) {\r\n var pi = this.getOrCreatePolytopeIntersector();\r\n pi.reset();\r\n pi.setPolytopeFromWindowCoordinates(posX - 5, posY - 5, posX + 5, posY + 5);\r\n var iv = this._intersectionVisitor;\r\n iv.setIntersector(pi);\r\n viewer.getCamera().accept(iv);\r\n hits = pi.getIntersections();\r\n hits.sort(function(a, b) {\r\n return a._distance - b._distance;\r\n });\r\n if (hits.length > 0) {\r\n point = hits[0]._localIntersectionPoint;\r\n hits[0]._nodePath.shift();\r\n matrix = ComputeMatrixFromNodePath.computeLocalToWorld(hits[0]._nodePath);\r\n vec3.transformMat4(pTrans, point, matrix);\r\n this.setPivotPoint(pTrans);\r\n }\r\n }\r\n };\r\n })(),\r\n\r\n getPositionRelativeToCanvas: (function() {\r\n var offset = vec2.create();\r\n var pos = vec2.create();\r\n return function(x, y) {\r\n var canvas = this._camera._graphicContext.canvas;\r\n this.getOffsetRect(canvas, offset);\r\n var ratioX = canvas.width / canvas.clientWidth;\r\n var ratioY = canvas.height / canvas.clientHeight;\r\n pos[0] = (x - offset[1]) * ratioX;\r\n pos[1] = (canvas.clientHeight - (y - offset[0])) * ratioY;\r\n return pos;\r\n };\r\n })(),\r\n\r\n getCanvasCenter: (function() {\r\n var offset = vec2.create();\r\n var pos = vec2.create();\r\n return function() {\r\n var canvas = this._camera.getGraphicContext().canvas;\r\n this.getOffsetRect(canvas, offset);\r\n var ratioX = canvas.width / canvas.clientWidth;\r\n var ratioY = canvas.height / canvas.clientHeight;\r\n pos[0] = canvas.clientWidth / 2 * ratioX;\r\n pos[1] = canvas.clientHeight / 2 * ratioY;\r\n return pos;\r\n };\r\n })(),\r\n\r\n getOffsetRect: function(elem, offset) {\r\n var box = elem.getBoundingClientRect();\r\n var body = document.body;\r\n var docElem = document.documentElement;\r\n var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;\r\n var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;\r\n var clientTop = docElem.clientTop || body.clientTop || 0;\r\n var clientLeft = docElem.clientLeft || body.clientLeft || 0;\r\n var top = box.top + scrollTop - clientTop;\r\n var left = box.left + scrollLeft - clientLeft;\r\n offset[0] = Math.round(top);\r\n offset[1] = Math.round(left);\r\n return offset;\r\n }\r\n }),\r\n 'osgGA',\r\n 'CADManipulator'\r\n);\r\n\r\nCADManipulator.StandardMouseKeyboard = CADManipulatorStandardMouseKeyboardController;\r\nCADManipulator.Hammer = CADManipulatorHammerController;\r\n\r\nexport default CADManipulator;\r\n","import OrbitManipulatorHammerController from './OrbitManipulatorHammerController';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\nimport utils from '../osg/utils';\r\n\r\nvar FirstPersonManipulatorHammerController = function(manipulator) {\r\n OrbitManipulatorHammerController.call(this, manipulator);\r\n this._timer = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n FirstPersonManipulatorHammerController,\r\n utils.objectInherit(OrbitManipulatorHammerController.prototype, {\r\n _initInputs: function() {\r\n OrbitManipulatorHammerController.prototype._initInputs.call(\r\n this,\r\n InputGroups.FPS_MANIPULATOR_TOUCH\r\n );\r\n }\r\n })\r\n);\r\n\r\nexport default FirstPersonManipulatorHammerController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar tempQuat = quat.create();\r\nvar tempPos = vec3.create();\r\n\r\nvar FirstPersonManipulatorWebVRController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n FirstPersonManipulatorWebVRController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._pos = vec3.create();\r\n this._quat = quat.create();\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.FPS_MANIPULATOR_WEBVR).addMappings(\r\n {\r\n update: 'vrdisplayposechanged'\r\n },\r\n this\r\n );\r\n\r\n // default to disabled\r\n manager.setEnable(InputGroups.FPS_MANIPULATOR_WEBVR, false);\r\n },\r\n update: function(ev) {\r\n var q = ev.pose.orientation;\r\n if (q) {\r\n if (ev.sitToStandMatrix) {\r\n q = mat4.getRotation(tempQuat, ev.sitToStandMatrix);\r\n quat.mul(q, q, ev.pose.orientation);\r\n }\r\n\r\n this._quat[0] = q[0];\r\n this._quat[1] = -q[2];\r\n this._quat[2] = q[1];\r\n this._quat[3] = q[3];\r\n }\r\n\r\n var pos = ev.pose.position;\r\n if (pos) {\r\n if (ev.sitToStandMatrix) {\r\n pos = vec3.transformMat4(tempPos, pos, ev.sitToStandMatrix);\r\n }\r\n this._pos[0] = pos[0] * ev.worldFactor;\r\n this._pos[1] = -pos[2] * ev.worldFactor;\r\n this._pos[2] = pos[1] * ev.worldFactor;\r\n }\r\n this._manipulator.setPoseVR(this._quat, this._pos);\r\n }\r\n })\r\n);\r\n\r\nexport default FirstPersonManipulatorWebVRController;\r\n","import Controller from './Controller';\r\nimport utils from '../osg/utils';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\nvar FirstPersonManipulatorStandardMouseKeyboardController = function(manipulator) {\r\n Controller.call(this, manipulator);\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n FirstPersonManipulatorStandardMouseKeyboardController,\r\n utils.objectInherit(Controller.prototype, {\r\n init: function() {\r\n this._delay = 0.15;\r\n this._stepFactor = 1.0; // meaning radius*stepFactor to move\r\n this._looking = false;\r\n\r\n var manager = this._manipulator.getInputManager();\r\n manager.group(InputGroups.FPS_MANIPULATOR_MOUSEKEYBOARD).addMappings(\r\n {\r\n startLookAt: 'mousedown',\r\n lookAt: 'mousemove',\r\n stopLookAt: ['mouseup', 'mouseout'],\r\n goForward: ['keydown w', 'keydown z', 'keydown ArrowUp'],\r\n goBackward: ['keydown s', 'keydown ArrowDown'],\r\n goLeft: ['keydown a', 'keydown q', 'keydown ArrowLeft'],\r\n goRight: ['keydown d', 'keydown ArrowRight'],\r\n stopMoving: [\r\n 'keyup w',\r\n 'keyup z',\r\n 'keyup ArrowUp',\r\n 'keyup s',\r\n 'keyup ArrowDown'\r\n ],\r\n stopStrafing: [\r\n 'keyup a',\r\n 'keyup q',\r\n 'keyup ArrowLeft',\r\n 'keyup d',\r\n 'keyup ArrowRight'\r\n ],\r\n changeStepFactor: 'wheel'\r\n },\r\n this\r\n );\r\n\r\n manager.group(InputGroups.FPS_MANIPULATOR_RESETTOHOME).addMappings(\r\n {\r\n reset: 'keydown space'\r\n },\r\n this\r\n );\r\n },\r\n // called to enable/disable controller\r\n setEnable: function(bool) {\r\n if (!bool) {\r\n // reset mode if we disable it\r\n this._buttonup = true;\r\n }\r\n Controller.prototype.setEnable.call(this, bool);\r\n },\r\n\r\n setManipulator: function(manipulator) {\r\n this._manipulator = manipulator;\r\n\r\n // we always want to sync speed of controller with manipulator\r\n this._manipulator.setStepFactor(this._stepFactor);\r\n },\r\n\r\n stopLookAt: function() {\r\n this._looking = false;\r\n },\r\n\r\n startLookAt: function(ev) {\r\n var manipulator = this._manipulator;\r\n manipulator.getLookPositionInterpolator().set(ev.canvasX, -ev.canvasY);\r\n this._looking = true;\r\n },\r\n\r\n lookAt: function(ev) {\r\n if (!this._looking) {\r\n return;\r\n }\r\n\r\n this._manipulator.getLookPositionInterpolator().setDelay(this._delay);\r\n this._manipulator.getLookPositionInterpolator().setTarget(ev.canvasX, -ev.canvasY);\r\n },\r\n\r\n changeStepFactor: function(ev) {\r\n this._stepFactor = Math.min(Math.max(0.001, this._stepFactor + ev.deltaY * 0.01), 4.0);\r\n this._manipulator.setStepFactor(this._stepFactor);\r\n },\r\n\r\n reset: function() {\r\n this._manipulator.computeHomePosition();\r\n },\r\n\r\n goForward: function() {\r\n this._manipulator.getForwardInterpolator().setDelay(this._delay);\r\n this._manipulator.getForwardInterpolator().setTarget(1);\r\n },\r\n\r\n goBackward: function() {\r\n this._manipulator.getForwardInterpolator().setDelay(this._delay);\r\n this._manipulator.getForwardInterpolator().setTarget(-1);\r\n },\r\n\r\n goLeft: function() {\r\n this._manipulator.getSideInterpolator().setDelay(this._delay);\r\n this._manipulator.getSideInterpolator().setTarget(-1);\r\n },\r\n\r\n goRight: function() {\r\n this._manipulator.getSideInterpolator().setDelay(this._delay);\r\n this._manipulator.getSideInterpolator().setTarget(1);\r\n },\r\n\r\n stopMoving: function() {\r\n this._manipulator.getForwardInterpolator().setDelay(this._delay);\r\n this._manipulator.getForwardInterpolator().setTarget(0);\r\n },\r\n\r\n stopStrafing: function() {\r\n this._manipulator.getSideInterpolator().setDelay(this._delay);\r\n this._manipulator.getSideInterpolator().setTarget(0);\r\n }\r\n })\r\n);\r\n\r\nexport default FirstPersonManipulatorStandardMouseKeyboardController;\r\n","import utils from '../osg/utils';\r\nimport Manipulator from './Manipulator';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport { vec2 } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport FirstPersonManipulatorDeviceOrientationController from './FirstPersonManipulatorDeviceOrientationController';\r\nimport FirstPersonManipulatorHammerController from './FirstPersonManipulatorHammerController';\r\nimport FirstPersonManipulatorWebVRController from './FirstPersonManipulatorWebVRController';\r\nimport FirstPersonManipulatorStandardMouseKeyboardController from './FirstPersonManipulatorStandardMouseKeyboardController';\r\nimport DelayInterpolator from '../osgUtil/DelayInterpolator';\r\nimport InputGroups from '../osgViewer/input/InputConstants';\r\n\r\n/**\r\n * Authors:\r\n * Matt Fontaine <tehqin@gmail.com>\r\n * Cedric Pinson <trigrou@gmail.com>\r\n */\r\n\r\n/**\r\n * FirstPersonManipulator\r\n * @class\r\n */\r\nvar FirstPersonManipulator = function (options) {\r\n Manipulator.call(this, options);\r\n this._redrawCB = options.redrawCB\r\n this.init();\r\n};\r\n\r\nFirstPersonManipulator.AvailableControllerList = [\r\n 'StandardMouseKeyboard',\r\n 'WebVR',\r\n 'DeviceOrientation',\r\n 'Hammer'\r\n];\r\nFirstPersonManipulator.ControllerList = [\r\n 'StandardMouseKeyboard',\r\n 'WebVR',\r\n 'DeviceOrientation',\r\n 'Hammer'\r\n];\r\n\r\nutils.createPrototypeObject(\r\n FirstPersonManipulator,\r\n utils.objectInherit(Manipulator.prototype, {\r\n computeHomePosition: function (boundStrategy) {\r\n var bs = this.getHomeBoundingSphere(boundStrategy);\r\n if (!bs || !bs.valid()) return;\r\n\r\n this._distance = this.getHomeDistance(bs);\r\n var cen = bs.center();\r\n vec3.scale(this._eye, this._direction, -this._distance);\r\n vec3.add(this._eye, cen, this._eye);\r\n this.setTarget(cen);\r\n },\r\n\r\n init: function () {\r\n this._direction = vec3.fromValues(0.0, 1.0, 0.0);\r\n this._eye = vec3.fromValues(0.0, 25.0, 10.0);\r\n this._up = vec3.fromValues(0.0, 0.0, 1.0);\r\n this._distance = 1.0;\r\n this._forward = new DelayInterpolator(1, undefined, this._redrawCB);\r\n this._side = new DelayInterpolator(1, undefined, this._redrawCB);\r\n this._lookPosition = new DelayInterpolator(2, undefined, this._redrawCB);\r\n\r\n // direct pan interpolator (not based on auto-move)\r\n this._pan = new DelayInterpolator(2, undefined, this._redrawCB);\r\n this._zoom = new DelayInterpolator(1, undefined, this._redrawCB);\r\n\r\n this._stepFactor = 1.0; // meaning radius*stepFactor to move\r\n this._angleVertical = 0.0;\r\n this._angleHorizontal = 0.0;\r\n\r\n // tmp value use for computation\r\n this._tmpGetTargetDir = vec3.create();\r\n\r\n // vr controls\r\n this._vrEnable = false;\r\n this._vrRot = quat.create(); // absolute orientation\r\n this._vrPos = vec3.create(); // absolute position\r\n this._vrTrans = vec3.create(); // delta translation since last update\r\n\r\n var self = this;\r\n\r\n this._controllerList = {};\r\n FirstPersonManipulator.ControllerList.forEach(function (value) {\r\n if (FirstPersonManipulator[value] !== undefined) {\r\n if (self._controllerList[value]) {\r\n self._controllerList[value].init();\r\n } else {\r\n self._controllerList[value] = new FirstPersonManipulator[value](self);\r\n }\r\n }\r\n });\r\n },\r\n\r\n setDelay: function (dt) {\r\n this._forward.setDelay(dt);\r\n this._side.setDelay(dt);\r\n this._lookPosition.setDelay(dt);\r\n this._pan.setDelay(dt);\r\n this._zoom.setDelay(dt);\r\n },\r\n\r\n getEyePosition: function (eye) {\r\n eye[0] = this._eye[0];\r\n eye[1] = this._eye[1];\r\n eye[2] = this._eye[2];\r\n return eye;\r\n },\r\n\r\n setEyePosition: function (eye) {\r\n this._eye[0] = eye[0];\r\n this._eye[1] = eye[1];\r\n this._eye[2] = eye[2];\r\n return this;\r\n },\r\n\r\n getTarget: function (pos) {\r\n var dir = vec3.scale(this._tmpGetTargetDir, this._direction, this._distance);\r\n vec3.add(pos, this._eye, dir);\r\n return pos;\r\n },\r\n\r\n setEnable: function (enabled) {\r\n this.getInputManager().setEnable(InputGroups.FPS_MANIPULATOR, enabled);\r\n },\r\n\r\n setTarget: function (pos) {\r\n var dir = this._tmpGetTargetDir;\r\n vec3.sub(dir, pos, this._eye);\r\n dir[2] = 0.0;\r\n vec3.normalize(dir, dir);\r\n this._angleHorizontal = Math.acos(dir[1]);\r\n if (dir[0] < 0.0) {\r\n this._angleHorizontal = -this._angleHorizontal;\r\n }\r\n vec3.sub(dir, pos, this._eye);\r\n vec3.normalize(dir, dir);\r\n\r\n this._angleVertical = -Math.asin(dir[2]);\r\n vec3.copy(this._direction, dir);\r\n },\r\n\r\n getLookPositionInterpolator: function () {\r\n return this._lookPosition;\r\n },\r\n getSideInterpolator: function () {\r\n return this._side;\r\n },\r\n getForwardInterpolator: function () {\r\n return this._forward;\r\n },\r\n getPanInterpolator: function () {\r\n return this._pan;\r\n },\r\n getZoomInterpolator: function () {\r\n return this._zoom;\r\n },\r\n getRotateInterpolator: function () {\r\n // for compatibility with orbit hammer controllers\r\n return this._lookPosition;\r\n },\r\n\r\n computeRotation: (function () {\r\n var first = mat4.create();\r\n var rotMat = mat4.create();\r\n\r\n var right = vec3.fromValues(1.0, 0.0, 0.0);\r\n var upy = vec3.fromValues(0.0, 1.0, 0.0);\r\n var upz = vec3.fromValues(0.0, 0.0, 1.0);\r\n var LIMIT = Math.PI * 0.5;\r\n return function (dx, dy) {\r\n this._angleVertical += dy * 0.01;\r\n this._angleHorizontal -= dx * 0.01;\r\n if (this._angleVertical > LIMIT) this._angleVertical = LIMIT;\r\n else if (this._angleVertical < -LIMIT) this._angleVertical = -LIMIT;\r\n\r\n if (this._vrEnable) {\r\n vec3.transformQuat(this._direction, upy, this._vrRot);\r\n vec3.normalize(this._direction, this._direction);\r\n vec3.transformQuat(this._up, upz, this._vrRot);\r\n } else {\r\n mat4.fromRotation(first, -this._angleVertical, right);\r\n mat4.fromRotation(rotMat, -this._angleHorizontal, upz);\r\n mat4.mul(rotMat, rotMat, first);\r\n\r\n vec3.transformMat4(this._direction, upy, rotMat);\r\n vec3.normalize(this._direction, this._direction);\r\n vec3.transformMat4(this._up, upz, rotMat);\r\n }\r\n };\r\n })(),\r\n reset: function () {\r\n this.init();\r\n },\r\n setDistance: function (d) {\r\n this._distance = d;\r\n },\r\n getDistance: function () {\r\n return this._distance;\r\n },\r\n setStepFactor: function (t) {\r\n this._stepFactor = t;\r\n },\r\n\r\n computePosition: (function () {\r\n var vec = vec2.create();\r\n\r\n return function (dt) {\r\n this._forward.update(dt);\r\n this._side.update(dt);\r\n\r\n // TDOO why check with epsilon ?\r\n var factor = this._distance < 1e-3 ? 1e-3 : this._distance;\r\n\r\n // see comment in orbitManipulator for fov modulation speed\r\n var proj = this._camera.getProjectionMatrix();\r\n var vFov = proj[15] === 1 ? 1.0 : 2.0 / proj[5];\r\n\r\n // time based displacement vector\r\n vec[0] = this._forward.getCurrent()[0];\r\n vec[1] = this._side.getCurrent()[0];\r\n var len2 = vec2.sqrLen(vec);\r\n if (len2 > 1.0) vec2.scale(vec, vec, 1.0 / Math.sqrt(len2));\r\n\r\n // direct displacement vectors\r\n var pan = this._pan.update(dt);\r\n var zoom = this._zoom.update(dt);\r\n\r\n var timeFactor = this._stepFactor * factor * vFov * dt;\r\n var directFactor = this._stepFactor * factor * vFov * 0.005;\r\n\r\n this.moveForward(vec[0] * timeFactor - zoom[0] * directFactor * 20.0);\r\n this.strafe(vec[1] * timeFactor - pan[0] * directFactor);\r\n this.strafeVertical(-pan[1] * directFactor);\r\n\r\n if (this._vrEnable) {\r\n vec3.add(this._eye, this._eye, this._vrTrans);\r\n // in case setPoseVR skips some frame (possible if tracking is lost temporarily)\r\n vec3.init(this._vrTrans);\r\n }\r\n };\r\n })(),\r\n\r\n update: (function () {\r\n var tmpTarget = vec3.create();\r\n\r\n return function (nv) {\r\n var dt = nv.getFrameStamp().getDeltaTime();\r\n\r\n var delta = this._lookPosition.update(dt);\r\n this.computeRotation(-delta[0] * 0.5, -delta[1] * 0.5);\r\n this.computePosition(dt);\r\n\r\n vec3.add(tmpTarget, this._eye, this._direction);\r\n mat4.lookAt(this._inverseMatrix, this._eye, tmpTarget, this._up);\r\n\r\n this._vrEnable = false; // setPoseVR is called on each frame\r\n };\r\n })(),\r\n\r\n setPoseVR: function (q, pos) {\r\n this._vrEnable = true;\r\n quat.copy(this._vrRot, q);\r\n vec3.sub(this._vrTrans, pos, this._vrPos);\r\n vec3.copy(this._vrPos, pos);\r\n },\r\n\r\n moveForward: (function () {\r\n var tmp = vec3.create();\r\n return function (distance) {\r\n vec3.normalize(tmp, this._direction);\r\n vec3.scale(tmp, tmp, distance);\r\n vec3.add(this._eye, this._eye, tmp);\r\n };\r\n })(),\r\n\r\n strafe: (function () {\r\n var tmp = vec3.create();\r\n return function (distance) {\r\n vec3.cross(tmp, this._direction, this._up);\r\n vec3.normalize(tmp, tmp);\r\n vec3.scale(tmp, tmp, distance);\r\n vec3.add(this._eye, this._eye, tmp);\r\n };\r\n })(),\r\n\r\n strafeVertical: (function () {\r\n var tmp = vec3.create();\r\n return function (distance) {\r\n vec3.normalize(tmp, this._up);\r\n vec3.scale(tmp, tmp, distance);\r\n vec3.add(this._eye, this._eye, tmp);\r\n };\r\n })()\r\n }),\r\n 'osgGA',\r\n 'FirstPersonManipulator'\r\n);\r\n\r\nFirstPersonManipulator.DeviceOrientation = FirstPersonManipulatorDeviceOrientationController;\r\nFirstPersonManipulator.Hammer = FirstPersonManipulatorHammerController;\r\nFirstPersonManipulator.WebVR = FirstPersonManipulatorWebVRController;\r\nFirstPersonManipulator.StandardMouseKeyboard = FirstPersonManipulatorStandardMouseKeyboardController;\r\n\r\nexport default FirstPersonManipulator;\r\n","import notify from '../osg/notify';\r\n\r\n/**\r\n * OrbitManipulator\r\n * @class\r\n */\r\nvar SwitchManipulator = function(inputManager) {\r\n this._manipulatorList = [];\r\n this._currentManipulator = undefined;\r\n this._inputManager = inputManager;\r\n};\r\n\r\n/** @lends SwitchManipulator.prototype */\r\nSwitchManipulator.prototype = {\r\n getCamera: function() {\r\n return this.getCurrentManipulator().getCamera();\r\n },\r\n setCamera: function(cam) {\r\n var cbList = this.getManipulatorList();\r\n for (var i = 0, nb = cbList.length; i < nb; ++i) cbList[i].setCamera(cam);\r\n },\r\n update: function(nv) {\r\n var manipulator = this.getCurrentManipulator();\r\n if (manipulator !== undefined) {\r\n return manipulator.update(nv);\r\n }\r\n return undefined;\r\n },\r\n\r\n getInputManager: function() {\r\n return this._inputManager;\r\n },\r\n\r\n setEnable: function(enable) {\r\n this.getCurrentManipulator().setEnable(enable);\r\n },\r\n\r\n getNode: function() {\r\n // we should add an accessor in the osgjs manipulator\r\n return this.getCurrentManipulator()._node;\r\n },\r\n setNode: function(node) {\r\n var cbList = this.getManipulatorList();\r\n for (var i = 0, nb = cbList.length; i < nb; ++i) cbList[i].setNode(node);\r\n },\r\n getControllerList: function() {\r\n return this.getCurrentManipulator().getControllerList();\r\n },\r\n getNumManipulator: function() {\r\n return this._manipulatorList.length;\r\n },\r\n addManipulator: function(manipulator) {\r\n this._manipulatorList.push(manipulator);\r\n if (this._currentManipulator === undefined) {\r\n this.setManipulatorIndex(0);\r\n }\r\n },\r\n getManipulatorList: function() {\r\n return this._manipulatorList;\r\n },\r\n setManipulatorIndex: function(index) {\r\n this._currentManipulator = index;\r\n },\r\n getCurrentManipulatorIndex: function() {\r\n return this._currentManipulator;\r\n },\r\n getCurrentManipulator: function() {\r\n return this._manipulatorList[this._currentManipulator];\r\n },\r\n reset: function() {\r\n this.getCurrentManipulator().reset();\r\n },\r\n computeHomePosition: function(useBoundingBox) {\r\n var manipulator = this.getCurrentManipulator();\r\n if (manipulator !== undefined) {\r\n manipulator.computeHomePosition(useBoundingBox);\r\n }\r\n },\r\n getInverseMatrix: function() {\r\n var manipulator = this.getCurrentManipulator();\r\n if (manipulator !== undefined) {\r\n return manipulator.getInverseMatrix();\r\n }\r\n },\r\n getHomeBound: function(boundStrategy) {\r\n notify.warn('Please use getHomeBoundingSphere instead');\r\n return this.getHomeBoundingSphere(boundStrategy);\r\n },\r\n getHomeBoundingSphere: function(boundStrategy) {\r\n return this.getCurrentManipulator().getHomeBoundingSphere(boundStrategy);\r\n },\r\n getHomeDistance: function(bs) {\r\n return this.getCurrentManipulator().getHomeDistance(bs);\r\n }\r\n};\r\n\r\nexport default SwitchManipulator;\r\n","import Hammer from 'hammerjs';\r\nimport CADManipulator from './CADManipulator';\r\nimport CADManipulatorStandardMouseKeyboardController from './CADManipulatorStandardMouseKeyboardController';\r\nimport CADManipulatorHammerController from './CADManipulatorHammerController';\r\nimport FirstPersonManipulator from './FirstPersonManipulator';\r\nimport FirstPersonManipulatorDeviceOrientationController from './FirstPersonManipulatorDeviceOrientationController';\r\nimport FirstPersonManipulatorHammerController from './FirstPersonManipulatorHammerController';\r\nimport FirstPersonManipulatorStandardMouseKeyboardController from './FirstPersonManipulatorStandardMouseKeyboardController';\r\nimport FirstPersonManipulatorWebVRController from './FirstPersonManipulatorWebVRController';\r\nimport Manipulator from './Manipulator';\r\nimport OrbitManipulator from './OrbitManipulator';\r\nimport OrbitManipulatorDeviceOrientationController from './OrbitManipulatorDeviceOrientationController';\r\nimport OrbitManipulatorGamePadController from './OrbitManipulatorGamePadController';\r\nimport OrbitManipulatorHammerController from './OrbitManipulatorHammerController';\r\nimport OrbitManipulatorStandardMouseKeyboardController from './OrbitManipulatorStandardMouseKeyboardController';\r\nimport OrbitManipulatorWebVRController from './OrbitManipulatorWebVRController';\r\nimport SwitchManipulator from './SwitchManipulator';\r\nimport OrbitManipulatorEnums from './orbitManipulatorEnums';\r\nimport Controller from './Controller';\r\n\r\nvar osgGA = {};\r\n\r\nHammer.NO_MOUSEEVENTS = true; // disable hammer js mouse events\r\n\r\nosgGA.CADManipulator = CADManipulator;\r\nosgGA.getCADManipulatorStandardMouseKeyboardController = function() {\r\n return CADManipulatorStandardMouseKeyboardController;\r\n};\r\nosgGA.getCADManipulatorHammerController = function() {\r\n return CADManipulatorHammerController;\r\n};\r\nosgGA.FirstPersonManipulator = FirstPersonManipulator;\r\nosgGA.getFirstPersonDeviceOrientationController = function() {\r\n return FirstPersonManipulatorDeviceOrientationController;\r\n};\r\nosgGA.getFirstPersonManipulatorHammerController = function() {\r\n return FirstPersonManipulatorHammerController;\r\n};\r\nosgGA.getFirstPersonStandardMouseKeyboardControllerClass = function() {\r\n return FirstPersonManipulatorStandardMouseKeyboardController;\r\n};\r\nosgGA.getFirstPersonWebVRControllerClass = function() {\r\n return FirstPersonManipulatorWebVRController;\r\n};\r\nosgGA.Manipulator = Manipulator;\r\nosgGA.OrbitManipulator = OrbitManipulator;\r\nosgGA.getOrbitManipulatorDeviceOrientationController = function() {\r\n return OrbitManipulatorDeviceOrientationController;\r\n};\r\nosgGA.getOrbitManipulatorGamePadController = function() {\r\n return OrbitManipulatorGamePadController;\r\n};\r\nosgGA.getOrbitManipulatorHammerController = function() {\r\n return OrbitManipulatorHammerController;\r\n};\r\nosgGA.getOrbitManipulatorStandardMouseKeyboardController = function() {\r\n return OrbitManipulatorStandardMouseKeyboardController;\r\n};\r\nosgGA.getOrbitManipulatorWebVRController = function() {\r\n return OrbitManipulatorWebVRController;\r\n};\r\n\r\nosgGA.SwitchManipulator = SwitchManipulator;\r\n\r\nosgGA.OrbitManipulator.Rotate = OrbitManipulatorEnums.ROTATE;\r\nosgGA.OrbitManipulator.Pan = OrbitManipulatorEnums.PAN;\r\nosgGA.OrbitManipulator.Zoom = OrbitManipulatorEnums.ZOOM;\r\n\r\nosgGA.Controller = Controller;\r\n\r\nexport default osgGA;","import osg from \"../osg/osg\";\r\nimport osgGA from \"../osgGA/osgGA\"\r\n\r\nconst eps = 0.99\r\nconst limit = 0.5 * Math.PI * 0.99\r\nexport default class OrbitManipulator extends osgGA.OrbitManipulator {\r\n constructor(option) {\r\n super(option);\r\n this.setLimitPitchUp(limit);\r\n this.setLimitPitchDown(-limit);\r\n this._enableRecenter = true;\r\n this._zoomEMA = 0;\r\n this._pitchEMA = 0;\r\n this._yawEMA = 0;\r\n this._panVEMA = 0;\r\n this._panHEMA = 0;\r\n this._constrainPan = false;\r\n this._constrainedTarget = osg.vec3.create();\r\n this._scaleMouseMotion = 0.5;\r\n this._noPan = false;\r\n this._noZoom = false;\r\n this._noRotation = false;\r\n this.setDelay(0.1);\r\n }\r\n setEyePosition(eye, preventFlip) {\r\n let eyeDir = osg.vec3.create(),\r\n rightDir = osg.vec3.create(),\r\n upDir = osg.vec3.create();\r\n let rotationMatrix = this._rotation,\r\n target = this._target;\r\n osg.vec3.sub(eyeDir, eye, target);\r\n osg.vec3.normalize(eyeDir, eyeDir);\r\n if (preventFlip) {\r\n var dotvalue = osg.vec3.dot(eyeDir, this._upz);\r\n if (Math.abs(dotvalue) > eps) {\r\n let scale = Math.sqrt(\r\n (1 - 0.9801) / (eyeDir[0] * eyeDir[0] + eyeDir[1] * eyeDir[1]),\r\n );\r\n eyeDir[0] *= scale;\r\n eyeDir[1] *= scale;\r\n eyeDir[2] = eps * Math.sign(dotvalue);\r\n }\r\n }\r\n osg.vec3.cross(rightDir, eyeDir, this._upz);\r\n osg.vec3.normalize(rightDir, rightDir);\r\n osg.vec3.cross(upDir, rightDir, eyeDir);\r\n osg.vec3.normalize(upDir, upDir);\r\n rotationMatrix[0] = rightDir[0];\r\n rotationMatrix[1] = eyeDir[0];\r\n rotationMatrix[2] = upDir[0];\r\n rotationMatrix[3] = 0;\r\n rotationMatrix[4] = rightDir[1];\r\n rotationMatrix[5] = eyeDir[1];\r\n rotationMatrix[6] = upDir[1];\r\n rotationMatrix[7] = 0;\r\n rotationMatrix[8] = rightDir[2];\r\n rotationMatrix[9] = eyeDir[2];\r\n rotationMatrix[10] = upDir[2];\r\n rotationMatrix[11] = 0;\r\n rotationMatrix[12] = 0;\r\n rotationMatrix[13] = 0;\r\n rotationMatrix[14] = 0;\r\n rotationMatrix[15] = 1;\r\n this._distance = osg.vec3.dist(target, eye);\r\n }\r\n\r\n enableRecenter(e) {\r\n this._enableRecenter = e;\r\n }\r\n\r\n computeHomePosition(boundStrategy) {\r\n this._enableRecenter &&\r\n osgGA.OrbitManipulator.prototype.computeHomePosition.call(\r\n this,\r\n boundStrategy,\r\n );\r\n let bound = this.getHomeBoundingSphere()\r\n bound && (this.setLimitZoomIn(bound.radius() / 1.5), this.setLimitZoomOut(bound.radius() * 5))\r\n }\r\n\r\n _computeEMA(e, zoomEma) {\r\n return 0 === zoomEma ? e : 0.2 * e + 0.8 * zoomEma;\r\n }\r\n\r\n _getLimitReached(distance, limitIn, limitOut) {\r\n return Math.abs(distance - limitOut) < 0.001 ?\r\n limitOut :\r\n Math.abs(distance - limitIn) < 0.001 ?\r\n limitIn :\r\n undefined;\r\n }\r\n\r\n computeZoom(zoomValue) {\r\n if(this._noZoom) return \r\n osgGA.OrbitManipulator.prototype.computeZoom.call(this, zoomValue);\r\n if (this._constrainZoom) {\r\n var direction = 1;\r\n if ((zoomValue -= 1 < 0)) {\r\n (zoomValue = -zoomValue), (direction = -1);\r\n }\r\n var zoomdist = this.getSpeedFactor() * zoomValue,\r\n limit = this._getLimitReached(\r\n this.getDistance(),\r\n this._limitZoomIn,\r\n this._limitZoomOut,\r\n );\r\n\r\n if (limit !== undefined) {\r\n // this.zoom.setDelay(0)\r\n this._zoom.reset()\r\n if(this._prevDistance > limit)\r\n this._distance = limit + this._distance / 100\r\n else {\r\n this._distance = limit - this._distance / 100\r\n }\r\n \r\n if (this._prevDistance == undefined) this._prevDistance = limit;\r\n // zoomdist = (zoomdist / (1 + zoomdist)) * (0.1 * this.getDistance());\r\n // this._zoomEMA = this._computeEMA(zoomdist, this._zoomEMA);\r\n // if ((direction < 0 && this._prevDistance > limit) || (direction > 0 && this._prevDistance < limit)) {\r\n // this._distance = this._prevDistance + this.getSpeedFactor() * zoomValue * direction\r\n // } else {\r\n // this._distance = limit + this._zoomEMA * direction\r\n // }\r\n \r\n }\r\n this._prevDistance = this._distance;\r\n }\r\n }\r\n\r\n _computePitch(prevPitch, dy) {\r\n if (this._noRotation) return \r\n prevPitch =\r\n undefined !== this._previousPitch ? this._previousPitch : prevPitch;\r\n let pitch = osgGA.OrbitManipulator.prototype._computePitch.call(\r\n this,\r\n prevPitch,\r\n dy,\r\n );\r\n if (!this._constrainPitch || 0 === dy) {\r\n this._previousPitch = undefined;\r\n return pitch;\r\n }\r\n this._previousPitch = pitch;\r\n var n = dy / 10;\r\n n = (n / (1 + n)) * 0.5;\r\n var limitReachy = this._getLimitReached(\r\n pitch,\r\n this._limitPitchUp,\r\n this._limitPitchDown,\r\n );\r\n if (undefined !== limitReachy) {\r\n (this._pitchEMA = this._computeEMA(n, this._pitchEMA)),\r\n (pitch = limitReachy + this._pitchEMA);\r\n }\r\n return Math.max(Math.min(pitch, limit), -limit);\r\n }\r\n\r\n _computeYaw(prevYaw, dx) {\r\n if (this._noRotation) return\r\n var yaw;\r\n prevYaw = undefined !== this._previousYaw ? this._previousYaw : prevYaw;\r\n yaw = osgGA.OrbitManipulator.prototype._computeYaw.call(this, prevYaw, dx);\r\n\r\n if (!this._constrainYaw || 0 === dx) {\r\n this._previousYaw = undefined;\r\n return yaw;\r\n }\r\n this._previousYaw = yaw;\r\n var n = dx / 10;\r\n n = (n / (1 + n)) * 3;\r\n var limitReach = this._getLimitReached(\r\n yaw,\r\n this._limitYawLeft,\r\n this._limitYawRight,\r\n );\r\n if (limitReach !== undefined) {\r\n (this._yawEMA = this._computeEMA(n, this._yawEMA)),\r\n (yaw = limitReach + this._yawEMA);\r\n }\r\n return yaw;\r\n }\r\n\r\n computePan(dx, dy) {\r\n if(this._noPan) return \r\n if (this._constrainPan && (dx !== 0 || dy !== 0)) {\r\n (this._panVEMA = this._computeEMA((dx / (1 + dx)) * 0.5, this._panVEMA)),\r\n (this._panHEMA = this._computeEMA(\r\n (dy / (1 + dy)) * 0.5,\r\n this._panHEMA,\r\n )),\r\n (dx = this._panVEMA),\r\n (dy = this._panHEMA),\r\n osg.vec3.copy(this._target, this._constrainedTarget);\r\n }\r\n osgGA.OrbitManipulator.prototype.computePan.call(this, dx, dy);\r\n }\r\n\r\n setConstrainPan(val) {\r\n this._constrainPan = val;\r\n }\r\n\r\n isConstrainPan() {\r\n return this._constrainPan;\r\n }\r\n\r\n setPanConstraintTarget(val) {\r\n osg.vec3.copy(this._constrainedTarget, val);\r\n }\r\n\r\n setNoPan(value) {\r\n this._noPan = value\r\n }\r\n\r\n setNoZoom(value) {\r\n this._noZoom = value\r\n }\r\n\r\n setNoRotation(value) {\r\n this._noRotation = value\r\n }\r\n}","import Config from './Config.js';\r\nimport osg from '../osg/osg';\r\nimport osgGA from '../osgGA/osgGA';\r\n\r\nexport default class FirstPersonManipulator extends osgGA.FirstPersonManipulator {\r\n constructor(options) {\r\n super(options);\r\n this._stepFactor = Math.max(0, Math.min(4, Config.fpsSpeed / 25));\r\n this.getControllerList().StandardMouseKeyboard._stepFactor = this._stepFactor;\r\n this._postMultRotate = osg.quat.create();\r\n this._resetInitialVR = false;\r\n this._lookPosition._delay = 0.25;\r\n }\r\n\r\n getPostMultRotate() {\r\n return this._postMultRotate;\r\n }\r\n\r\n setResetInitialRotationVR(e) {}\r\n\r\n setNode(node) {}\r\n\r\n setInitialPoseVR(e, t) {}\r\n\r\n setPoseVR(e, t) {}\r\n}","import Config from './Config.js';\r\nimport OrbitManipulator from './OrbitManipulator.js';\r\nimport FirstPersonManipulator from './FirstPersonManipulator.js';\r\nimport osg from \"../osg/osg\";\r\nimport osgGA from \"../osgGA/osgGA\";\r\nimport osgUtil from \"../osgUtil/osgUtil\";\r\n\r\n\r\nconst DelayInterpolatorProtoType = osgUtil.DelayInterpolator.prototype;\r\n\r\nconst setter = DelayInterpolatorProtoType.set;\r\nDelayInterpolatorProtoType.set = function () {\r\n setter.apply(this, arguments)\r\n this._epsilon >= 0 && !this.isDone() && this._redrawCB(true);\r\n};\r\n\r\nconst setTarget = DelayInterpolatorProtoType.setTarget;\r\nDelayInterpolatorProtoType.setTarget = function () {\r\n setTarget.apply(this, arguments)\r\n this._epsilon >= 0 && !this.isDone() && this._redrawCB(true);\r\n};\r\n\r\nconst addTarget = DelayInterpolatorProtoType.addTarget;\r\nDelayInterpolatorProtoType.addTarget = function () {\r\n addTarget.apply(this, arguments)\r\n this._epsilon >= 0 && !this.isDone() && this._redrawCB(true);\r\n};\r\n\r\nDelayInterpolatorProtoType.isDone = function (threhold) {\r\n threhold = threhold || 1;\r\n for (\r\n var t = Math.abs(this._epsilon), i = 0, n = this._current.length;\r\n i < n;\r\n ++i\r\n )\r\n if (Math.abs(this._target[i] - this._current[i]) > t * threhold)\r\n return false;\r\n return true;\r\n};\r\n\r\nconst updater = DelayInterpolatorProtoType.update;\r\nDelayInterpolatorProtoType.update = function (e) {\r\n var delta = updater.call(this, e);\r\n if (this._epsilon >= 0)\r\n if (this.isDone()){\r\n for (var i = 0, n = this._current.length; i < n; ++i)\r\n this._current[i] = this._target[i];\r\n }\r\n else {\r\n this._redrawCB(), this.isDone(100) ? this._redrawCB(true) : this._redrawCB('noJitter');\r\n }\r\n \r\n return delta;\r\n};\r\n\r\nvar isDone = function () {\r\n var epsilon = Math.abs(this._epsilon);\r\n for (var t = 0, i = this._current.length; t < i; ++t)\r\n if (\r\n 1 === Math.abs(this._target[t]) ||\r\n Math.abs(this._target[t] - this._current[t]) > epsilon\r\n )\r\n return !1;\r\n return true;\r\n};\r\n\r\nvar hookIsDone = function (interpolator) {\r\n interpolator.isDone = isDone.bind(interpolator);\r\n};\r\n\r\nexport default class SwitchManipulator extends osgGA.SwitchManipulator {\r\n constructor(inputManager, redrawCB) {\r\n super()\r\n this._redrawCB = redrawCB\r\n this._boundStrategy = osgGA.Manipulator.COMPUTE_HOME_USING_SPHERE | osgGA.Manipulator.COMPUTE_HOME_USING_BBOX\r\n this._inputManager = inputManager\r\n this.init();\r\n this._upz = osg.vec3.fromValues(0.0, 0.0, 1.0);\r\n this._autoRotating = false\r\n this._autoRotateMode = false\r\n }\r\n\r\n init() {\r\n\r\n this._startAutoRotate = _.debounce(()=>{\r\n this._autoRotating = true\r\n }, 3000, {trailing:true})\r\n\r\n this._stopAutoRotate = _.debounce(()=>{\r\n this._autoRotating = false\r\n }, 3000, {leading:true})\r\n\r\n osgGA.SwitchManipulator.prototype.setManipulatorIndex.call(this, 0);\r\n var orbiter = new OrbitManipulator({\r\n boundStrategy: this._boundStrategy,\r\n inputManager: this._inputManager,\r\n redrawCB: (p)=>{\r\n this._redrawCB(p)\r\n if(this._autoRotateMode) {\r\n this._stopAutoRotate()\r\n this._startAutoRotate()\r\n }\r\n }\r\n });\r\n orbiter.getRotateInterpolator()._epsilon = 0.1;\r\n orbiter.getPanInterpolator()._epsilon = 0.1;\r\n orbiter.getZoomInterpolator()._epsilon = 0.001;\r\n orbiter.setZoomFactor(Config.orbitZoomFactor);\r\n orbiter.setRotationFactor(Config.orbitRotationFactor);\r\n orbiter.setPanFactor(Config.orbitPanFactor);\r\n orbiter.getPanInterpolator()._isOrbitPan = true;\r\n const fps = new FirstPersonManipulator({\r\n boundStrategy: this._boundStrategy,\r\n inputManager: this._inputManager,\r\n redrawCB: this._redrawCB\r\n })\r\n fps.getLookPositionInterpolator()._epsilon = 0.1;\r\n fps.getSideInterpolator()._epsilon = 0.001;\r\n hookIsDone(fps.getSideInterpolator());\r\n fps.getForwardInterpolator()._epsilon = 0.001;\r\n hookIsDone(fps.getForwardInterpolator());\r\n fps.getPanInterpolator()._epsilon = 0.001;\r\n hookIsDone(fps.getPanInterpolator());\r\n fps.getZoomInterpolator()._epsilon = 0.001;\r\n hookIsDone(fps.getZoomInterpolator());\r\n this.addManipulator(orbiter, 'ORBIT');\r\n this.addManipulator(fps, 'FPS');\r\n if (undefined !== Config.cameraEasing)\r\n this.setDelay(1 - Config.cameraEasing);\r\n }\r\n getOrbitManipulator() {\r\n return this._manipulatorList[SwitchManipulator.ORBIT];\r\n }\r\n getFirstPersonManipulator() {\r\n return this._manipulatorList[SwitchManipulator.FPS];\r\n }\r\n _setManipulatorDelay(manipulator, delay) {\r\n manipulator.setDelay(delay);\r\n const controlist = manipulator._controllerList;\r\n for (var n in controlist) {\r\n const controller = controlist[n];\r\n if (undefined !== controller._delay) controller._delay = delay;\r\n }\r\n }\r\n setDelay(delay) {\r\n this._setManipulatorDelay(\r\n this._manipulatorList[SwitchManipulator.ORBIT],\r\n delay,\r\n ),\r\n this._setManipulatorDelay(\r\n this._manipulatorList[SwitchManipulator.FPS],\r\n delay,\r\n );\r\n }\r\n addManipulator(manipulator, name) {\r\n osgGA.SwitchManipulator.prototype.addManipulator.call(this, manipulator),\r\n name && (SwitchManipulator[name] = this.getManipulatorList().length - 1);\r\n }\r\n setManipulatorIndex(index) {\r\n let target = osg.vec3.create(),\r\n eye = osg.vec3.create();\r\n if (index !== this.getCurrentManipulatorIndex()) {\r\n const curManipulator = this.getCurrentManipulator();\r\n osgGA.SwitchManipulator.prototype.setManipulatorIndex.call(this, index);\r\n this.setTargetAndEye(\r\n curManipulator.getTarget(target),\r\n curManipulator.getEyePosition(eye),\r\n );\r\n }\r\n }\r\n setTargetAndEye(target, eye) {\r\n const currentManipulator = this.getCurrentManipulator();\r\n if (this.getCurrentManipulatorIndex() === SwitchManipulator.ORBIT) {\r\n target && currentManipulator.setTarget(target);\r\n eye && currentManipulator.setEyePosition(eye);\r\n } else {\r\n eye && currentManipulator.setEyePosition(eye);\r\n target && currentManipulator.setTarget(target);\r\n }\r\n this._redrawCB(true);\r\n }\r\n setEyePosition(eye, t) {\r\n this.getCurrentManipulator().setEyePosition(eye, t);\r\n this._redrawCB(true);\r\n }\r\n getEyePosition(eye) {\r\n return this.getCurrentManipulator().getEyePosition(eye);\r\n }\r\n setTarget(target) {\r\n this.getCurrentManipulator().setTarget(target);\r\n this._redrawCB(true);\r\n }\r\n getTarget(target) {\r\n return this.getCurrentManipulator().getTarget(target);\r\n }\r\n setDistance(distance) {\r\n if (this.getCurrentManipulatorIndex() === SwitchManipulator.ORBIT) {\r\n this.getCurrentManipulator().setDistance(distance), this._redrawCB(true);\r\n }\r\n }\r\n getDistance() {\r\n return this.getCurrentManipulator().getDistance();\r\n }\r\n computeHomePosition(e) {\r\n osgGA.SwitchManipulator.prototype.computeHomePosition.call(this, e);\r\n this._redrawCB(true);\r\n }\r\n\r\n setViewMode(mode, distance) {\r\n var rotation = this.getCurrentManipulator()._rotation\r\n switch (mode) {\r\n case 'front': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), -Math.PI, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 10.0,\r\n osg.vec3.fromValues(1.0, 0.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'back': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), 0, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 10.0,\r\n osg.vec3.fromValues(-1.0, 0.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'right': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), Math.PI / 2, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 10,\r\n osg.vec3.fromValues(0.0, 1.0, 0.0)\r\n );\r\n\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'left': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), -Math.PI / 2, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 10.0,\r\n osg.vec3.fromValues(0.0, -1.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'top': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), -Math.PI, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 2 - 0.0001,\r\n osg.vec3.fromValues(1.0, 0.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'bottom': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), -Math.PI, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n -Math.PI / 2 + 0.0001,\r\n osg.vec3.fromValues(1.0, 0.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'right-top': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), Math.PI * 2 / 3, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 9,\r\n osg.vec3.fromValues(1.0, 1.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n case 'left-top': {\r\n var rot1 = osg.mat4.fromRotation(osg.mat4.create(), -Math.PI * 2 / 3, this._upz);\r\n var rot2 = osg.mat4.fromRotation(\r\n osg.mat4.create(),\r\n Math.PI / 9,\r\n osg.vec3.fromValues(1.0, -1.0, 0.0)\r\n );\r\n osg.mat4.mul(rotation, rot1, rot2);\r\n }\r\n break\r\n }\r\n var bs = this.getHomeBoundingSphere();\r\n if (!bs || !bs.valid()) return;\r\n this.setDistance(distance ? distance : this.getHomeDistance(bs));\r\n this.setTarget(bs.center());\r\n var newHome = this.getCurrentManipulator().getHomePosition()\r\n this.setEyePosition(newHome)\r\n }\r\n\r\n update(visitor){\r\n if(this._autoRotating) {\r\n let tempEye = osg.vec3.create()\r\n let tempTarget = osg.vec3.create()\r\n this.getEyePosition(tempEye)\r\n this.getTarget(tempTarget)\r\n osg.vec3.rotateZ(tempEye, tempEye, tempTarget, Math.PI/6 * visitor._frameStamp._deltaTime)\r\n this.setTargetAndEye(tempTarget, tempEye)\r\n }\r\n\r\n super.update(visitor)\r\n }\r\n\r\n setAutoRotateMode(value) {\r\n this._autoRotateMode = !!value\r\n this._autoRotating = this._autoRotateMode\r\n \r\n }\r\n}\r\n","import osg from '../osg/osg';\r\n\r\nconst SHADINGKEYS = [\r\n 'Inspector',\r\n 'Matcap',\r\n 'Displacement',\r\n 'AlphaMask',\r\n 'Opacity',\r\n 'SubsurfaceScattering',\r\n 'SubsurfaceTranslucency',\r\n 'DiffuseColor',\r\n 'DiffusePBR',\r\n 'AlbedoPBR',\r\n 'ClearCoat',\r\n 'ClearCoatRoughness',\r\n 'ClearCoatNormalMap',\r\n 'SpecularColor',\r\n 'DiffuseIntensity',\r\n 'SpecularPBR',\r\n 'MetalnessPBR',\r\n 'GlossinessPBR',\r\n 'RoughnessPBR',\r\n 'NormalMap',\r\n 'BumpMap',\r\n 'AOPBR',\r\n 'EmitColor',\r\n 'CavityPBR',\r\n 'SpecularHardness',\r\n 'SpecularF0',\r\n 'Anisotropy',\r\n 'Sheen',\r\n 'SheenRoughness',\r\n];\r\n\r\nconst getComponentEnums = function(key) {\r\n switch (key) {\r\n case 'DiffuseColor':\r\n case 'DiffuseIntensity':\r\n case 'SpecularColor':\r\n case 'NormalMap':\r\n case 'EmitColor':\r\n case 'DiffusePBR':\r\n case 'AlbedoPBR':\r\n case 'SpecularPBR':\r\n case 'Matcap':\r\n case 'Inspector':\r\n case 'ClearCoatNormalMap':\r\n case 'Anisotropy':\r\n case 'Sheen':\r\n return osg.Texture.RGB;\r\n case 'SpecularHardness':\r\n case 'BumpMap':\r\n case 'GlossinessPBR':\r\n case 'RoughnessPBR':\r\n case 'MetalnessPBR':\r\n case 'SheenRoughness':\r\n case 'SpecularF0':\r\n case 'AOPBR':\r\n case 'CavityPBR':\r\n case 'Displacement':\r\n case 'SubsurfaceScattering':\r\n case 'SubsurfaceTranslucency':\r\n case 'ClearCoat':\r\n case 'ClearCoatRoughness':\r\n return osg.Texture.LUMINANCE;\r\n case 'Opacity':\r\n case 'AlphaMask':\r\n return osg.Texture.ALPHA;\r\n default:\r\n return console.error('unknown channel: ' + key), osg.Texture.RGB;\r\n }\r\n};\r\n\r\nconst getComponents = function(key) {\r\n if ('Anisotropy' === key) return 'rg';\r\n var t = getComponentEnums(key);\r\n return t === osg.Texture.RGB ?\r\n 'rgb' :\r\n t === osg.Texture.LUMINANCE ?\r\n 'r' :\r\n t === osg.Texture.ALPHA ?\r\n 'a' :\r\n 'rgba';\r\n};\r\n\r\nconst Remapping = function(mapper) {\r\n for (var mapping = {}, i = 0, length = SHADINGKEYS.length; i < length; ++i) {\r\n var r = SHADINGKEYS[i];\r\n mapping[r] = mapper(r);\r\n }\r\n return function(e) {\r\n return mapping[e];\r\n };\r\n};\r\n\r\nconst MaskMapping = {\r\n CLASSIC: 10,\r\n CLASSIC_LIT: 2,\r\n CLASSIC_SHADELESS: 8,\r\n INSPECTOR: 32,\r\n LIT: 3,\r\n MATCAP: 16,\r\n PBR: 5,\r\n PBR_LIT: 1,\r\n PBR_SHADELESS: 4,\r\n SHADELESS: 12,\r\n};\r\n\r\nSHADINGKEYS.getShadingMask = Remapping(function(key) {\r\n switch (key) {\r\n case 'Matcap':\r\n return MaskMapping.MATCAP;\r\n case 'SubsurfaceScattering':\r\n case 'SubsurfaceTranslucency':\r\n return MaskMapping.LIT;\r\n case 'Opacity':\r\n case 'AlphaMask':\r\n case 'Displacement':\r\n return (\r\n MaskMapping.LIT |\r\n MaskMapping.SHADELESS |\r\n MaskMapping.MATCAP |\r\n MaskMapping.INSPECTOR\r\n );\r\n case 'EmitColor':\r\n return MaskMapping.LIT | MaskMapping.SHADELESS;\r\n case 'NormalMap':\r\n case 'BumpMap':\r\n return MaskMapping.LIT | MaskMapping.MATCAP;\r\n case 'DiffusePBR':\r\n case 'AlbedoPBR':\r\n case 'AOPBR':\r\n case 'CavityPBR':\r\n return MaskMapping.PBR;\r\n case 'SpecularPBR':\r\n case 'MetalnessPBR':\r\n case 'GlossinessPBR':\r\n case 'RoughnessPBR':\r\n case 'SpecularF0':\r\n case 'ClearCoat':\r\n case 'ClearCoatRoughness':\r\n case 'ClearCoatNormalMap':\r\n case 'Anisotropy':\r\n case 'Sheen':\r\n case 'SheenRoughness':\r\n return MaskMapping.PBR_LIT;\r\n case 'DiffuseColor':\r\n case 'DiffuseIntensity':\r\n return MaskMapping.CLASSIC;\r\n case 'SpecularColor':\r\n case 'SpecularHardness':\r\n return MaskMapping.CLASSIC_LIT;\r\n case 'Inspector':\r\n return MaskMapping.INSPECTOR;\r\n }\r\n});\r\n\r\nSHADINGKEYS.isSRGB = Remapping(function(key) {\r\n switch (key) {\r\n case 'DiffuseColor':\r\n case 'DiffusePBR':\r\n case 'AlbedoPBR':\r\n case 'EmitColor':\r\n case 'SpecularColor':\r\n case 'SpecularPBR':\r\n case 'Matcap':\r\n case 'Inspector':\r\n case 'Sheen':\r\n return true;\r\n default:\r\n return false;\r\n }\r\n});\r\n\r\nSHADINGKEYS.getDefaultFormatEnum = Remapping(getComponentEnums);\r\nSHADINGKEYS.getDefaultFormatComponent = Remapping(getComponents);\r\nSHADINGKEYS.getDefaultFormatString = Remapping(function(key) {\r\n var format = getComponentEnums(key);\r\n return format === osg.Texture.RGB ?\r\n 'RGB' :\r\n format === osg.Texture.LUMINANCE ?\r\n 'LUMINANCE' :\r\n format === osg.Texture.ALPHA ?\r\n 'ALPHA' :\r\n 'RGBA';\r\n});\r\n\r\n(SHADINGKEYS.getDefaultComponentCount = Remapping(function(key) {\r\n return getComponents(key).length;\r\n})),\r\n(SHADINGKEYS.getPossibleFormat = Remapping(function(key) {\r\n var textureFormat = {};\r\n switch (key) {\r\n case 'NormalMap':\r\n case 'SpecularPBR':\r\n case 'ClearCoatNormalMap':\r\n case 'Anisotropy':\r\n case 'Sheen':\r\n textureFormat.RGB = 'RGB';\r\n break;\r\n case 'SpecularHardness':\r\n case 'BumpMap':\r\n case 'GlossinessPBR':\r\n case 'RoughnessPBR':\r\n case 'MetalnessPBR':\r\n case 'SpecularF0':\r\n case 'AOPBR':\r\n case 'CavityPBR':\r\n case 'Displacement':\r\n case 'SubsurfaceScattering':\r\n case 'SubsurfaceTranslucency':\r\n case 'ClearCoat':\r\n case 'ClearCoatRoughness':\r\n case 'SheenRoughness':\r\n textureFormat.LUMINANCE = 'Luminance';\r\n break;\r\n case 'DiffuseColor':\r\n case 'DiffuseIntensity':\r\n case 'SpecularColor':\r\n case 'EmitColor':\r\n case 'DiffusePBR':\r\n case 'AlbedoPBR':\r\n case 'Matcap':\r\n case 'Inspector':\r\n (textureFormat.LUMINANCE = 'Luminance'), (textureFormat.RGB = 'RGB');\r\n break;\r\n case 'AlphaMask':\r\n case 'Opacity':\r\n (textureFormat.ALPHA = 'Alpha'),\r\n (textureFormat.LUMINANCE = 'Luminance');\r\n break;\r\n default:\r\n return console.error('unknown channel: ' + key), osg.Texture.RGB;\r\n }\r\n return textureFormat;\r\n})),\r\n(SHADINGKEYS.getPossibleFiltering = Remapping(function(key) {\r\n var textureParam = {};\r\n return (\r\n 'Displacement' !== key &&\r\n ((textureParam.LINEAR_MIPMAP_LINEAR = 'Trilinear (best)'),\r\n (textureParam.NEAREST_MIPMAP_LINEAR = 'Nearest (mipmap)')),\r\n (textureParam.LINEAR = 'Bilinear'),\r\n (textureParam.NEAREST = 'Nearest'),\r\n textureParam\r\n );\r\n})),\r\n(SHADINGKEYS.getColorPacking = Remapping(function(key) {\r\n switch (key) {\r\n case 'DiffuseColor':\r\n case 'DiffusePBR':\r\n case 'AlbedoPBR':\r\n case 'Inspector':\r\n return 0;\r\n case 'EmitColor':\r\n return 1;\r\n case 'SpecularColor':\r\n case 'SpecularPBR':\r\n return 2;\r\n case 'DiffuseIntensity':\r\n return 3;\r\n default:\r\n return -1;\r\n }\r\n})),\r\n(SHADINGKEYS.getBoxFactor = Remapping(function(key) {\r\n return 'SubsurfaceScattering' === key || 'SubsurfaceTranslucency' === key ?\r\n 0.2 :\r\n 'Displacement' === key ?\r\n 1 :\r\n -1;\r\n}));\r\n\r\nclass Material extends osg.StateAttribute {\r\n constructor() {\r\n super(), (this._channelMapping = {});\r\n (this._materialModel = void 0),\r\n (this._stateSetContext = void 0),\r\n (this._additive = false),\r\n (this._depthWrite = true),\r\n (this._castShadows = true),\r\n (this._hashes = ['', '']),\r\n (this._dirtyUniforms = true),\r\n (this._activeChannels = []);\r\n }\r\n\r\n dirtyMaterial() {\r\n for (var index = 0; index < this._hashes.length; ++index)\r\n this._hashes[index] = '';\r\n this._dirtyUniforms = true;\r\n }\r\n\r\n getHash() {\r\n if (!this._materialModel) return '';\r\n var hash = this._hashes[Material.CURRENT_COMPILER];\r\n if (hash) return hash;\r\n hash = this.attributeType;\r\n Material.CURRENT_COMPILER !== Material.WIREFRAME_COMPILER &&\r\n (hash += this.getVertexAlphaEnable() ? '1' : '0'),\r\n Material.CURRENT_COMPILER === Material.SHADING_COMPILER &&\r\n ((hash += this.getShadeless() ? '1' : '0'),\r\n (hash += this.getVertexColorEnable() ? '1' : '0'),\r\n (hash += this.getHasOnlyPoints() ? '1' : '0'),\r\n (hash += 'srgb' === this.getVertexColorColorSpace() ? '1' : '0'),\r\n (hash += a.Z.get('hasSsr') ? '1' : '0'));\r\n var isShadowCompiler =\r\n Material.CURRENT_COMPILER === Material.SHADOWCAST_COMPILER;\r\n var channels = this._materialModel.getChannels();\r\n var compilerChannel = Material.compilerChannels[Material.CURRENT_COMPILER];\r\n var mapping = this._channelMapping;\r\n var index = 0;\r\n for (; index < compilerChannel.length; ++index) {\r\n var cc = compilerChannel[index],\r\n channel = channels[cc];\r\n if (channel.isEnableEffective())\r\n if (!isShadowCompiler || this._castShadows) {\r\n var value = mapping[cc];\r\n (hash += '.'),\r\n (hash += value < 0 ? '' : value),\r\n (hash += channel.getShaderHash()),\r\n (hash += this.getChannelPacking(cc));\r\n } else hash += '.0';\r\n else hash += '.0';\r\n }\r\n return (this._hashes[Material.CURRENT_COMPILER] = hash), hash;\r\n }\r\n\r\n setMaterialModel(model) {\r\n this._materialModel = model;\r\n }\r\n\r\n setStateSetContext(stateSetContext) {\r\n this._stateSetContext = stateSetContext;\r\n }\r\n\r\n setChannelMapping(key, value) {\r\n this._channelMapping[key] = value;\r\n }\r\n\r\n getChannelPacking(channel) {\r\n return this._stateSetContext ?\r\n this._stateSetContext.getChannelPacking(channel) :\r\n '';\r\n }\r\n\r\n updateOpacity() {\r\n (this._additive = false),\r\n (this._depthWrite = true),\r\n (this._castShadows = true);\r\n var opacity = this._materialModel.getChannels().Opacity;\r\n if (opacity.isEffective()) {\r\n var t = opacity.getTransparency();\r\n if ('dithering' !== t) {\r\n if ('additive' === t)\r\n return (\r\n (this._additive = true),\r\n (this._depthWrite = false),\r\n void(this._castShadows = false)\r\n );\r\n var i = false;\r\n return (\r\n 1 === opacity.getFactor() &&\r\n (i = opacity.getTextureModel() || this.getVertexAlphaEnable()),\r\n i ?\r\n void 0 :\r\n ((this._depthWrite = false), void(this._castShadows = false))\r\n );\r\n }\r\n }\r\n }\r\n\r\n cloneType() {\r\n return new Material();\r\n }\r\n\r\n getType() {\r\n return this.attributeType;\r\n }\r\n\r\n getTypeMember() {\r\n return this.attributeType;\r\n }\r\n\r\n getMaterialModel() {\r\n return this._materialModel;\r\n }\r\n\r\n getShadeless() {\r\n return this._materialModel && this._materialModel.get('shadeless');\r\n }\r\n\r\n getReflection() {\r\n return this._materialModel && this._materialModel.get('reflection');\r\n }\r\n\r\n getVertexColorEnable() {\r\n return this._materialModel && this._materialModel.get('vertexColorEnable');\r\n }\r\n getVertexAlphaEnable() {\r\n return this._materialModel && this._materialModel.get('vertexAlphaEnable');\r\n }\r\n getVertexColorColorSpace() {\r\n return (\r\n this._materialModel && this._materialModel.get('vertexColorColorSpace')\r\n );\r\n }\r\n getCullFace() {\r\n return this._materialModel && this._materialModel.get('cullFace');\r\n }\r\n getHasOnlyPoints() {\r\n return this._materialModel && this._materialModel.hasOnlyPoints();\r\n }\r\n getAdditive() {\r\n return this._additive;\r\n }\r\n getDepthWrite() {\r\n return this._depthWrite;\r\n }\r\n getCastShadows() {\r\n return this._castShadows;\r\n }\r\n getChannelMapping(key) {\r\n return this._channelMapping[key];\r\n }\r\n getOrCreateUniforms() {\r\n if (Material.uniforms) return Material.uniforms;\r\n var uniform = (Material.uniforms = {});\r\n uniform.uReflection = osg.Uniform.createFloat('uReflection');\r\n for (var t = i('egBR').Z, n = MaskMapping.length, a = 0; a < n; ++a) {\r\n var u = r.Z[a],\r\n l = t[u].model;\r\n l.prototype.addUniforms.call(l, uniform, u);\r\n }\r\n return uniform;\r\n }\r\n _cacheChannelUniforms() {\r\n var uniforms = this.getOrCreateUniforms(),\r\n channels = this._materialModel.getChannels(),\r\n length = MaskMapping.length,\r\n activeChannels = this._activeChannels;\r\n activeChannels.length = 0;\r\n for (var index = 0; index < length; ++index) {\r\n var channel = channels[r.Z[index]];\r\n osg.isEnableEffective() &&\r\n (osg.cacheUniforms(uniforms), activeChannels.push(channel));\r\n }\r\n }\r\n apply() {\r\n if (this._materialModel) {\r\n this._dirtyUniforms &&\r\n ((this._dirtyUniforms = false), this._cacheChannelUniforms()),\r\n this.getOrCreateUniforms().uReflection.setFloat(this.getReflection());\r\n var activeChannels = this._activeChannels;\r\n var index = 0;\r\n for (; index < activeChannels.length; ++index)\r\n activeChannels[index].updateUniforms();\r\n }\r\n }\r\n}\r\n\r\nMaterial.prototype.attributeType = 'EditorMaterial';\r\n\r\nMaterial.SHADING_COMPILER = 0\r\nMaterial.EARLYZ_COMPILER = 1\r\nMaterial.SHADOWCAST_COMPILER = 2\r\nMaterial.WIREFRAME_COMPILER = 3\r\nMaterial.CURRENT_COMPILER = Material.SHADING_COMPILER\r\nMaterial.compilerChannels = []\r\nMaterial[Material.SHADING_COMPILER] = SHADINGKEYS\r\nMaterial.compilerChannels[Material.EARLYZ_COMPILER] = [\r\n 'AlphaMask',\r\n 'Opacity',\r\n 'Displacement',\r\n 'SubsurfaceScattering',\r\n]\r\nMaterial.compilerChannels[Material.SHADOWCAST_COMPILER] = [\r\n 'Displacement',\r\n 'AlphaMask',\r\n 'Opacity',\r\n]\r\nMaterial.compilerChannels[Material.WIREFRAME_COMPILER] = ['Displacement']\r\nMaterial.hasVertexColor = false\r\nMaterial.hasVertexAlpha = false\r\n\r\nexport default Material;","import osg from \"../osg/osg\";\r\nimport osgShader from \"../osgShader/osgShader\";\r\n\r\nimport Config from './Config.js';\r\nconst shaderProcessor = osgShader.NextShaderProcessor;\r\nclass EditorCompiler {\r\n constructor(attrs, textureAttrs) {\r\n this._vertDefines = []\r\n this._fragDefines = []\r\n this._vertAssignUV = []\r\n this._envBrdf\r\n this._envSpecular\r\n this._compression\r\n this._material\r\n this._skinning\r\n this._morphing\r\n this._pointSize\r\n this._lights = []\r\n this._shadows = []\r\n this._shadowsTextures = []\r\n this._targetByUnit = []\r\n this.initAttributes(attrs)\r\n this.initTextureAttributes(textureAttrs);\r\n // var materialmodel = this._material ? this._material.getMaterialModel() : undefined;\r\n // this._channels = materialmodel ? materialmodel.getChannels() : undefined,\r\n //We.default.apple.device && this._vertDefines.push(\"#define IS_IOS\"),\r\n this.defineShaderName(), this.initDefines();\r\n }\r\n\r\n getCompilerName() {\r\n return 'PBR';\r\n }\r\n\r\n getFragmentMain() {\r\n return 'pbr.frag';\r\n }\r\n\r\n getVertexMain() {\r\n return 'pbr.vert';\r\n }\r\n\r\n initAttributes(attributes) {\r\n var lights = this._lights,\r\n shadows = this._shadows,\r\n index = 0;\r\n for (; index < attributes.length; index++) {\r\n var typeName = attributes[index].className();\r\n 'Light' === typeName\r\n ?\r\n lights.push(attributes[index]) :\r\n 'Material' === typeName ?\r\n (this._material = attributes[index]) :\r\n 'ShadowReceiveAttribute' === typeName ?\r\n shadows.push(attributes[index]) :\r\n 'SkinningAttribute' === typeName ?\r\n (this._skinning = attributes[index]) :\r\n 'MorphAttribute' === typeName ?\r\n (this._morphing = attributes[index]) :\r\n 'PointSizeAttribute' === typeName ?\r\n (this._pointSize = attributes[index]) :\r\n 'VertexCompression' === typeName &&\r\n (this._compression = attributes[index]);\r\n }\r\n }\r\n\r\n initTextureAttributes(textureAttributes) {\r\n for (var index = 0; index < textureAttributes.length; index++) {\r\n var textureAttribute = textureAttributes[index];\r\n if (textureAttribute)\r\n for (var j = 0; j < textureAttribute.length; j++) {\r\n var target = textureAttribute[j];\r\n this._targetByUnit[index] = target;\r\n var typeName = target.className();\r\n if ('TextureEnvironment' === typeName) {\r\n var channel = target.getChannel();\r\n 'SpecularPBR' === channel || 'Specular' === channel ?\r\n (this._envSpecular = target) :\r\n 'IntegrateBRDF' === channel && (this._envBrdf = target);\r\n }\r\n ('ShadowTexture' !== typeName && 'ShadowTextureAtlas' !== typeName) ||\r\n this._shadowsTextures.push(target);\r\n }\r\n }\r\n }\r\n\r\n defineShaderName() {\r\n this._vertDefines.push('#define SHADER_NAME ' + this.getVertexShaderName()),\r\n this._fragDefines.push(\r\n '#define SHADER_NAME ' + this.getFragmentShaderName(),\r\n );\r\n var eps_alpha = (1 - Config.epsilonAlpha).toExponential();\r\n this._fragDefines.push('#define EPSILON_ALPHA ' + eps_alpha);\r\n }\r\n\r\n getFragmentShaderName() {\r\n var compilerName = this.getCompilerName(),\r\n material = this._material && this._material.getName();\r\n material &&\r\n (compilerName +=\r\n '(' +\r\n (material = material.replace(/[^a-zA-Z0-9]+/g, '_').slice(0, 20)) +\r\n ')');\r\n var renderMode,\r\n channels = this._channels && this._channels.Opacity;\r\n var type = channels && channels.isEffective() && channels.get('type');\r\n if (\r\n ((renderMode =\r\n 'alphaBlend' === type || 'additive' === type ?\r\n 'Blend' :\r\n 'refraction' === type ?\r\n 'Refract' :\r\n 'dithering' === type ?\r\n 'Dither' :\r\n 'Opaque'),\r\n this._channels &&\r\n this._channels.AlphaMask &&\r\n this._channels.AlphaMask.isEffective() &&\r\n (renderMode = 'AlphaMask' + renderMode),\r\n renderMode)\r\n ) {\r\n var name = this.getCompilerName();\r\n compilerName = compilerName.replace(name, name + '_' + renderMode);\r\n }\r\n return compilerName;\r\n }\r\n\r\n getVertexShaderName() {\r\n return this.getFragmentShaderName();\r\n }\r\n\r\n getDebugIdentifier() {\r\n var vert = this.getVertexShaderName(),\r\n frag = this.getFragmentShaderName();\r\n return vert === frag ? frag : vert + '|' + frag;\r\n }\r\n\r\n createShader(isFrag) {\r\n var mainSource = isFrag ? this.getFragmentMain() : this.getVertexMain(),\r\n defines = isFrag ? this._fragDefines : this._vertDefines;\r\n isFrag || defines.push('#define ASSIGN_UV ' + this._vertAssignUV.join(' ')),\r\n (defines = shaderProcessor.getSortedUnique(defines));\r\n for (var defineStr = '', index = 0; index < defines.length; ++index)\r\n defines[index] && (defineStr += defines[index] + '\\n');\r\n return (\r\n (defineStr =\r\n (defineStr =\r\n '#define SHADER_NAME ' +\r\n this.getFragmentShaderName() +\r\n '\\n' +\r\n defineStr) +\r\n '#pragma include \"' +\r\n mainSource +\r\n '\"'),\r\n shaderProcessor.processShader(defineStr)\r\n );\r\n }\r\n\r\n createFragmentShader() {\r\n return this.createShader(true);\r\n }\r\n\r\n createVertexShader() {\r\n return this.createShader(false);\r\n }\r\n\r\n declareAndAssignTexCoord(unit, t) {\r\n var i = 'TexCoord' + unit;\r\n if (\r\n (this._vertDefines.push('attribute vec2 ' + i + ';'),\r\n t && !this._compression)\r\n )\r\n return i;\r\n var n = 'vTexCoord' + unit,\r\n r = 'varying vec2 ' + n + ';',\r\n a = 'vec2 ' + n + ';';\r\n if (t)\r\n -\r\n 1 === this._vertDefines.indexOf(r) &&\r\n this._vertDefines.push('vec2 ' + n + ';');\r\n else {\r\n this._fragDefines.push(r), this._vertDefines.push(r);\r\n var o = this._vertDefines.indexOf(a); -\r\n 1 !== o && this._vertDefines.splice(o, 1);\r\n }\r\n var s = n + ' = ';\r\n if (this._compression) {\r\n var u = 'uQUV' + unit;\r\n this._vertDefines.push('uniform vec4 ' + u + ';'),\r\n (s += i + '.xy * ' + u + '.zw + ' + u + '.xy;');\r\n } else s += i + ';';\r\n return (-1 === this._vertAssignUV.indexOf(s) && this._vertAssignUV.push(s), n);\r\n }\r\n\r\n _getTexCoordTransforms(e, t) {\r\n var i = 'u' + t;\r\n return (\r\n (e = 'vec2( mat2(' + i + 'UVTransforms) * ' + e),\r\n (e += ' + ' + i + 'UVOffset)')\r\n );\r\n }\r\n\r\n getChannelUV(channel) {\r\n var name = channel.getName();\r\n if (!channel.getTextureModel()) {\r\n var i = E.Z.getColorPacking(name);\r\n return 0 === i ?\r\n 'vec2(0.125, 0.5)' :\r\n 1 === i ?\r\n 'vec2(0.375, 0.5)' :\r\n 2 === i ?\r\n 'vec2(0.625, 0.5)' :\r\n 'vec2(0.875, 0.5)';\r\n }\r\n var n = 'Displacement' === channel.get('name'),\r\n r = this.declareAndAssignTexCoord(channel.getTexCoordUnit(), n);\r\n return (\r\n channel.getNonIdentityUvTransform() &&\r\n (r = this._getTexCoordTransforms(r, channel.get('name'))),\r\n r\r\n );\r\n }\r\n\r\n defineOpacity(e) {\r\n var t = e.get('type');\r\n 'alphaBlend' !== t && 'additive' !== t ?\r\n 'dithering' !== t ?\r\n (this._fragDefines.push('#define HAS_OPACITY_REFRACTION'),\r\n e.get('useNormalOffset') &&\r\n this._fragDefines.push('#define HAS_REFRACTION_NORMAL_OFFSET'),\r\n e.get('useAlbedoTint') &&\r\n this._fragDefines.push('#define HAS_REFRACTION_ALBEDO_TINT'),\r\n e.get('useMicrosurfaceTexture') &&\r\n this._fragDefines.push('#define HAS_REFRACTION_MICROSURFACE'),\r\n Config.depthMipmap && this._fragDefines.push('#define DEPTH_MIPMAP')) :\r\n this._fragDefines.push('#define HAS_OPACITY_DITHER') :\r\n this._fragDefines.push('#define HAS_OPACITY_BLEND_OR_ADDITIVE');\r\n }\r\n\r\n defineChannel(e) {\r\n var t = e.getName();\r\n if (e.isEnableEffectiveHardware(this._material)) {\r\n var i = 'Displacement' === t ? this._vertDefines : this._fragDefines,\r\n n = t.toUpperCase();\r\n if (\r\n (i.push('#define HAS_' + n),\r\n ('NormalMap' !== t && 'Inspector' !== t) ||\r\n this._vertDefines.push('#define HAS_' + n),\r\n e.isEffective())\r\n ) {\r\n ('NormalMap' !== t &&\r\n 'BumpMap' !== t &&\r\n 'ClearCoatNormalMap' !== t &&\r\n 'Anisotropy' !== t) ||\r\n (this._fragDefines.push('#define HAS_VIEW_TANGENT'),\r\n this._vertDefines.push('#define HAS_VIEW_TANGENT')),\r\n 'Opacity' === t && this.defineOpacity(e),\r\n 'Displacement' === t &&\r\n ((0, b.Z)().substanceDisplacement ?\r\n i.push('#define HAS_SUBSTANCE_DISPLACEMENT') :\r\n i.push('#define HAS_EDITOR_DISPLACEMENT'));\r\n var r = E.Z.getColorPacking(t);\r\n if (e.getTextureModel() || !(r < 0)) {\r\n var a = this._material.getChannelMapping(t);\r\n if (!(void 0 === a || a < 0)) {\r\n var o = this._targetByUnit[a],\r\n s = o.getName(),\r\n u = o.getChannelPacking(t),\r\n l = e.getSRGB() ? 'sRGBToLinear' : '',\r\n h = t.toUpperCase(),\r\n c = this.getChannelUV(e);\r\n i.push('uniform sampler2D ' + s + ';'),\r\n i.push('uniform vec4 u' + t + 'UVTransforms;'),\r\n i.push('uniform vec2 u' + t + 'UVOffset;'),\r\n i.push('#define SAMPLER_' + h + ' ' + s),\r\n i.push('#define PACK_' + h + ' ' + u),\r\n i.push('#define UV_' + h + ' ' + c),\r\n i.push('#define COLOR_CONVERT_' + h + ' ' + l);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n defineVertexColorAndAlpha() {\r\n if (this._material && this._material.getVertexColorEnable()) {\r\n this._fragDefines.push('#define HAS_VERTEX_COLOR'),\r\n this._vertDefines.push('#define HAS_VERTEX_COLOR');\r\n var e =\r\n 'srgb' === this._material.getVertexColorColorSpace() ?\r\n 'sRGBToLinear' :\r\n '';\r\n this._fragDefines.push('#define COLOR_CONVERT_VERTEX_COLOR ' + e),\r\n this._material.getVertexAlphaEnable() &&\r\n (this._fragDefines.push('#define HAS_VERTEX_ALPHA'),\r\n this._vertDefines.push('#define HAS_VERTEX_ALPHA'));\r\n }\r\n }\r\n\r\n defineLights() {\r\n var e = this._lights;\r\n if (e.length) {\r\n for (var t = 0; t < e.length; ++t) {\r\n var i = e[t],\r\n n = i.getLightNumber(),\r\n r = 'LIGHT_' + i.getLightType();\r\n this._fragDefines.push('#define LIGHT_TYPE_' + n + ' ' + r);\r\n }\r\n this._fragDefines.push('#define HAS_LIGHT');\r\n }\r\n }\r\n\r\n defineShadows() {\r\n var shadows = this._shadows;\r\n if (shadows.length) {\r\n for (var t = 0; t < shadows.length; ++t) {\r\n var shadow = shadows[t];\r\n this._fragDefines.push('#define HAS_SHADOW_' + shadow.getLightNumber())\r\n this._fragDefines.push.apply(this._fragDefines, shadow.getDefines())\r\n }\r\n this._fragDefines.push('#define HAS_SHADOW')\r\n this._vertDefines.push('#define HAS_MODEL_VERTEX')\r\n this._vertDefines.push('#define HAS_MODEL_NORMAL')\r\n }\r\n }\r\n defineEnvironment() {\r\n this._envSpecular &&\r\n (this._fragDefines.push('#define HAS_ENVIRONMENT'),\r\n this._envSpecular.getIsCubemap() ?\r\n this._fragDefines.push('#define ENV_CUBEMAP') :\r\n this._fragDefines.push('#define ENV_PANORAMA')),\r\n this._envBrdf && this._fragDefines.push('#define HAS_ENVIRONMENT_BRDF');\r\n }\r\n defineSsr() {\r\n return;\r\n je.Z.get('hasSsr') &&\r\n (this._fragDefines.push('#define HAS_SSR'),\r\n (0, b.Z)().ssrTransparent &&\r\n this._fragDefines.push('#define HAS_SSR_TRANSPARENT'),\r\n (0, b.Z)().depthMipmap &&\r\n -1 === this._fragDefines.indexOf('#define DEPTH_MIPMAP') &&\r\n this._fragDefines.push('#define DEPTH_MIPMAP'));\r\n }\r\n defineSkinning() {\r\n this._skinning &&\r\n (this._vertDefines.push('#define HAS_SKINNING'),\r\n this._vertDefines.push(\r\n '#define NUM_BONES ' + this._skinning.getBoneUniformSize(),\r\n ));\r\n }\r\n defineMorphing() {\r\n this._morphing &&\r\n this._morphing.hasTarget('Vertex') &&\r\n (this._vertDefines.push('#define HAS_MORPHING'),\r\n this._vertDefines.push(\r\n '#define NUM_TARGETS ' + this._morphing.getNumTargets(),\r\n ),\r\n this._morphing.hasTarget('Normal') &&\r\n this._vertDefines.push('#define HAS_MORPHING_NORMAL'),\r\n this._morphing.hasTarget('Tangent') &&\r\n this._vertDefines.push('#define HAS_MORPHING_TANGENT'));\r\n }\r\n defineChannels() {\r\n var e = this._channels;\r\n for (var t in e) this.defineChannel(e[t]);\r\n }\r\n _randHardcodedScale() {\r\n var e,\r\n t = osg.BufferArray.randa,\r\n i = t[0],\r\n n = t[1],\r\n r = t[2];\r\n Ye > 0.5 ? (e = '* ') : ((e = '/ '), (i = 1 / i), (n = 1 / n), (r = 1 / r)),\r\n (i = i.toExponential()),\r\n (n = n.toExponential()),\r\n (r = r.toExponential());\r\n var a = Math.random();\r\n return a < 0.33 ?\r\n e + 'vec3(' + r + ',' + i + ',' + n + ').yzx' :\r\n a < 0.66 ?\r\n e + 'vec3(' + n + ',' + r + ',' + i + ').zxy' :\r\n e + 'vec3(' + r + ',' + i + ',' + n + ').yzx';\r\n }\r\n defineCompression() {\r\n this._compression &&\r\n (0, b.Z)().zz &&\r\n (this._vertDefines.push(\r\n '#define RAND_SCALE ' + this._randHardcodedScale(),\r\n ),\r\n this._vertDefines.push('#define HAS_COMPRESSION'),\r\n (0, b.Z)().zoct && this._vertDefines.push('#define HAS_OCT_COMPRESSION'),\r\n (0, b.Z)().zw && this._vertDefines.push('#define HAS_ZW_COMPRESSION'));\r\n }\r\n definePointSize() {\r\n this._pointSize &&\r\n (this._vertDefines.push('#define HAS_POINT_SIZE'),\r\n this._pointSize.isCircleShape() &&\r\n this._fragDefines.push('#define HAS_POINT_CIRCLE'));\r\n }\r\n initDefines() {\r\n this.defineChannels(),\r\n this.defineVertexColorAndAlpha(),\r\n this.defineLights(),\r\n this.defineShadows(),\r\n this.defineEnvironment(),\r\n this.defineSsr(),\r\n this.defineMorphing(),\r\n this.defineSkinning(),\r\n this.defineCompression(),\r\n this.definePointSize();\r\n return;\r\n je.Z.get('mask') & je.Z.CLASSIC &&\r\n (this._fragDefines.push('#define HAS_LEGACY_CLASSIC'),\r\n 'PBR' === this.getCompilerName() &&\r\n (this._fragDefines.push('#pragma include \"utils/cubemap.glsl\"'),\r\n this._fragDefines.push('#pragma include \"utils/lights.glsl\"')));\r\n }\r\n}\r\n\r\nosg.setStateAttributeConfig(EditorCompiler, {\r\n attribute: [\r\n 'VertexCompression',\r\n 'EditorLight0',\r\n 'EditorLight1',\r\n 'EditorLight2',\r\n 'EditorLight3',\r\n 'ShadowReceive0',\r\n 'ShadowReceive1',\r\n 'ShadowReceive2',\r\n 'ShadowReceive3',\r\n 'PBRMaterial',\r\n 'Morph',\r\n 'Skinning',\r\n 'PointSize',\r\n ],\r\n textureAttribute: ['Texture'],\r\n});\r\n\r\nexport default EditorCompiler;","export default (function () {\r\n if (navigator.userAgent.match(/Mobile/i)) return true;\r\n if (navigator.userAgent.match(/Android/i)) return true;\r\n if (navigator.userAgent.match(/iPhone/i)) return true;\r\n if (navigator.userAgent.match(/iPad/i)) return true;\r\n if (navigator.userAgent.match(/iPod/i)) return true;\r\n if (navigator.userAgent.match(/BlackBerry/i)) return true;\r\n if (navigator.userAgent.match(/Windows Phone/i)) return true;\r\n\r\n return false;\r\n})();\r\n","export default /*glsl*/ `\r\n\r\n#extension GL_EXT_shader_texture_lod : enable\r\n#extension GL_OES_standard_derivatives : enable\r\nprecision highp float;\r\nuniform mat4 uViewMatrix;\r\nvarying vec2 vTexCoord0;\r\nvarying vec3 vModelNormal;\r\nvarying vec3 vModelVertex;\r\nvarying vec3 vAutoUVCoord;\r\nvarying vec3 vWorldNormal;\r\nvarying vec4 vViewTangent;\r\nuniform int uToneMethod;\r\n\r\nuniform float uBrightness;\r\nuniform float uScale;\r\n\r\nuniform sampler2D albedoMap; // tcolors\r\nuniform sampler2D metallicMap; // tspec - triangles\r\nuniform sampler2D normalMap;\r\nuniform sampler2D roughnessMap; // tpoints\r\n\r\n\r\n#pragma include \"triplanar_projection.glsl\"\r\nvec4 fetchTexture(sampler2D texture, vec2 yz, vec2 xz, vec2 yx) {\r\n vec4 color;\r\n // vec3 coord = vAutoUVCoord * .1;\r\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\r\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\r\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\r\n color = triplanlar_projection(yz, xz, yx, texture);\r\n return color;\r\n}\r\n\r\nvec3 gAutoUVCoord;\r\n\r\n#define FragColor gl_FragColor\r\nconst float REC_PI = 0.31830988618;\r\nconst float REC_PI2 = 0.15915494;\r\nvoid getNormal(out vec3 n1, out vec3 n2, out vec3 n3, out vec3 n4) {\r\n vec3 pos_dx = dFdx(vModelVertex.xyz);\r\n vec3 pos_dy = dFdy(vModelVertex.xyz);\r\n vec2 tex_dx = dFdx(vTexCoord0);\r\n vec2 tex_dy = dFdy(vTexCoord0);\r\n vec3 t = normalize(pos_dx * tex_dy.t - pos_dy * tex_dx.t);\r\n vec3 b = normalize(-pos_dx * tex_dy.s + pos_dy * tex_dx.s);\r\n mat3 tbn = mat3(t, b, normalize(vModelNormal));\r\n\r\n vec4 tangent = vViewTangent; \r\n // my tbn \r\n vec3 tang = vec3(0.0, 1.0, 0.0);\r\n if (length(tangent.xyz) != 0.0) {\r\n tang = normalize(tangent.xyz);\r\n }\r\n vec3 B = tangent.w * cross(vModelNormal, tang);\r\n tbn = mat3(tang, B, normalize(vModelNormal));\r\n\r\n n4 = normalize((uViewMatrix * vec4(vModelNormal, 0.0)).xyz);\r\n\r\n vec2 yz = gAutoUVCoord.yz * 0.5;\r\n vec2 xz = gAutoUVCoord.xz * 0.5;\r\n vec2 yx = gAutoUVCoord.yx * 0.5;\r\n yz.x += n4.x * 0.3;\r\n yz.y += n4.y * 0.3;\r\n yz.x += n4.z * 0.6;\r\n \r\n xz.x += n4.x * 0.3;\r\n xz.y += n4.y * 0.3;\r\n xz.x += n4.z * 0.6;\r\n\r\n yx.x += n4.x * 0.3;\r\n yx.y += n4.y * 0.3;\r\n yx.x += n4.z * 0.6;\r\n\r\n n1 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\r\n\r\n //-------\r\n yz = gAutoUVCoord.yz * 1.;\r\n xz = gAutoUVCoord.xz * 1.;\r\n yx = gAutoUVCoord.yx * 1.;\r\n\r\n yz.x += n4.x * 0.2;\r\n yz.y += n4.y * 0.3;\r\n yz.y += n4.z * 0.3;\r\n \r\n xz.x += n4.x * 0.2;\r\n xz.y += n4.y * 0.3;\r\n xz.y += n4.z * 0.3;\r\n\r\n yx.x += n4.x * 0.2;\r\n yx.y += n4.y * 0.3;\r\n yx.y += n4.z * 0.3; \r\n\r\n n2 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\r\n // ---------\r\n\r\n yz = gAutoUVCoord.yz * 1.6;\r\n xz = gAutoUVCoord.xz * 1.6;\r\n yx = gAutoUVCoord.yx * 1.6; \r\n\r\n yz.x += n4.y * -0.4;\r\n yz.y += n4.x * 0.4;\r\n yz.x += n4.z * 0.2;\r\n\r\n xz.x += n4.y * -0.4;\r\n xz.y += n4.x * 0.4;\r\n xz.x += n4.z * 0.2;\r\n\r\n yx.x += n4.y * -0.4;\r\n yx.y += n4.x * 0.4;\r\n yx.x += n4.z * 0.2;\r\n n3 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\r\n\r\n // ------\r\n\r\n n1 = normalize((uViewMatrix * vec4(normalize(tbn * n1), 0.0)).xyz); \r\n n2 = normalize((uViewMatrix * vec4(normalize(tbn * n2), 0.0)).xyz);\r\n n3 = normalize((uViewMatrix * vec4(normalize(tbn * n3), 0.0)).xyz);\r\n \r\n}\r\n\r\n\r\nfloat sRGBToLinear(const in float color) {\r\n return color < 0.04045 ? color * (1.0 / 12.92) : pow((color + 0.055) * (1.0 / 1.055), 2.4);\r\n}\r\nvec3 sRGBToLinear(const in vec3 color) {\r\n return vec3( color.r < 0.04045 ? color.r * (1.0 / 12.92) : pow((color.r + 0.055) * (1.0 / 1.055), 2.4), color.g < 0.04045 ? color.g * (1.0 / 12.92) : pow((color.g + 0.055) * (1.0 / 1.055), 2.4), color.b < 0.04045 ? color.b * (1.0 / 12.92) : pow((color.b + 0.055) * (1.0 / 1.055), 2.4));\r\n}\r\nvec4 sRGBToLinear(const in vec4 color) {\r\n return vec4( color.r < 0.04045 ? color.r * (1.0 / 12.92) : pow((color.r + 0.055) * (1.0 / 1.055), 2.4), color.g < 0.04045 ? color.g * (1.0 / 12.92) : pow((color.g + 0.055) * (1.0 / 1.055), 2.4), color.b < 0.04045 ? color.b * (1.0 / 12.92) : pow((color.b + 0.055) * (1.0 / 1.055), 2.4), color.a);\r\n}\r\n\r\nfloat getLuminance(const in vec3 color) {\r\n const vec3 colorBright = vec3(0.2126, 0.7152, 0.0722);\r\n return dot(color, colorBright);\r\n}\r\n\r\nvoid main() {\r\n \r\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\r\n gAutoUVCoord = vAutoUVCoord * 0.1 * uScale;\r\n\r\n float ior = 2.5;\r\n float radius = 1.0;\r\n // vec3 dir1 = normalize(vViewDir);\r\n vec3 normal1 = normalize(vModelNormal);\r\n vec3 n1;\r\n vec3 n2;\r\n vec3 n3;\r\n vec3 n4;\r\n getNormal(n1, n2, n3, n4);\r\n //float isTop = step(0.99, dot(vec3(0, 1, 0), vModelNormal2));\r\n //float isLookingDown = smoothstep(0.8, 1.0, dot(vec3(0, -1, 0), dir1));\r\n float isTop = 0.0;\r\n float isLookingDown = 0.0;\r\n vec3 color = vec3(0.4);\r\n\r\n vec2 yz = gAutoUVCoord.yz * 0.8 + n2.xy * 0.5;\r\n vec2 xz = gAutoUVCoord.xz * 0.8 + n2.xy * 0.5;\r\n vec2 yx = gAutoUVCoord.yx * 0.8 + n2.xy * 0.5; \r\n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.4;\r\n\r\n vec2 uv3 = vTexCoord0 * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\r\n color += texture2D(roughnessMap, uv3).rgb * 0.5 * (1.0 - isTop);\r\n\r\n yz = gAutoUVCoord.yz * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\r\n xz = gAutoUVCoord.xz * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\r\n yx = gAutoUVCoord.yx * 1.3 + n3.xy * 0.4 + n3.z * 0.2; \r\n color += fetchTexture(roughnessMap, yz, xz, yx).rgb * 0.5 * (1.0 - isTop); \r\n\r\n yz = gAutoUVCoord.yz * 0.3 + n4.xy * 1.5 + n4.z * 0.8;\r\n xz = gAutoUVCoord.xz * 0.3 + n4.xy * 1.5 + n4.z * 0.8;\r\n yx = gAutoUVCoord.yx * 0.3 + n4.xy * 1.5 + n4.z * 0.8; \r\n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.8 * isTop * (1.0 - 0.7 * isLookingDown); // DING DING DING \r\n \r\n yz = gAutoUVCoord.yz * 0.6 + n2.xy * 0.3 + n2.z * 0.2;\r\n xz = gAutoUVCoord.xz * 0.6 + n2.xy * 0.3 + n2.z * 0.2;\r\n yx = gAutoUVCoord.yx * 0.6 + n2.xy * 0.3 + n2.z * 0.2; \r\n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.5 * (1. - isTop); \r\n \r\n yz = gAutoUVCoord.yz * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\r\n xz = gAutoUVCoord.xz * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\r\n yx = gAutoUVCoord.yx * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\r\n color += fetchTexture(albedoMap, yz, xz, yx).rgb * 0.5;\r\n\r\n color = pow(color, vec3(1.2)) * 1.1;\r\n //float alpha = step(dot(vec3(0, 1, 0), vModelNormal2), 0.99);\r\n float alpha = pow(color.g, 1.0); \r\n \r\n color = mix(color, vec3(0.970, 0.926, 0.917), 0.22);\r\n FragColor.rgb = color * uBrightness;// * vec3(uBrightness * 1.2);\r\n\r\n // my handle\r\n FragColor.rgb *= alpha; \r\n // FragColor.rgb *= 1.0 + getLuminance(FragColor.rgb); \r\n FragColor.a = 1.0;\r\n \r\n // if (uToneMethod > 0) {\r\n // FragColor.rgb = vec3(1., 0., 0.);\r\n // }\r\n FragColor.rgb = sRGBToLinear(FragColor.rgb); \r\n\r\n\r\n}\r\n\r\n`\r\n","import osg from \"../osg/osg\";\r\nimport osgShader from \"../osgShader/osgShader\";\r\nimport EditorCompiler from './EditorCompiler';\r\nimport isMobile from './isMobile';\r\nimport diamondShader from './shaders/auto_diamond';\r\n\r\nconst shaderProcessor = osgShader.NextShaderProcessor;\r\nclass PBRCompiler extends EditorCompiler {\r\n constructor(attr, textureAttr) {\r\n super(attr, textureAttr);\r\n this._changeColorAttribute\r\n }\r\n getCompilerName() {\r\n return 'PBR';\r\n }\r\n getFragmentMain() {\r\n return 'pbrFrag.glsl';\r\n }\r\n getVertexMain() {\r\n return 'baseVert.glsl';\r\n }\r\n\r\n initAttributes(attributes) {\r\n for (var index = 0; index < attributes.length; index++) {\r\n var typeName = attributes[index].className();\r\n if ('PBRMaterial' === typeName) {\r\n this._material = attributes[index];\r\n } else if ('EditorLight' == typeName) {\r\n this._lights.push(attributes[index])\r\n } else if ('Material' === typeName) {\r\n this._originMaterial = attributes[index];\r\n } else if ('SkinningAttribute' === typeName) {\r\n this._skinning = attributes[index];\r\n } else if ('MorphAttribute' === typeName) {\r\n this._morphing = attributes[index];\r\n } else if ('UVTransformAttribute' == typeName) {\r\n //console.log('UVTRANSFORM');\r\n this._uvTransform = attributes[index];\r\n } else if ('UVProjectionAttribute' == typeName) {\r\n this._uvProjection = attributes[index];\r\n } else if ('StickerAttribute' == typeName) {\r\n this._sticker = attributes[index];\r\n } else if ('ShadowReceiveAttribute' == typeName) {\r\n this._shadows.push(attributes[index])\r\n } else if ('ChangeColorAttribute' === typeName) {\r\n this._changeColorAttribute = attributes[index]\r\n } else if ('DiamondAttribute' === typeName) {\r\n this._diamondAttribute = attributes[index]\r\n }\r\n }\r\n }\r\n\r\n initTextureAttributes(textureAttributes) {\r\n for (var index = 0; index < textureAttributes.length; index++) {\r\n var textureAttribute = textureAttributes[index];\r\n if (textureAttribute)\r\n for (var j = 0; j < textureAttribute.length; j++) {\r\n var target = textureAttribute[j];\r\n this._targetByUnit[index] = target;\r\n var typeName = target.className();\r\n if ('TextureEnvironment' === typeName) {\r\n var channel = target.getChannel();\r\n if ('SpecularPBR' === channel) {\r\n this._envSpecular = target;\r\n } else if ('IntegrateBRDF' === channel) {\r\n this._envBrdf = target;\r\n }\r\n }\r\n\r\n if (\"ShadowTexture\" === typeName || \"ShadowTextureAtlas\" === typeName) {\r\n this._shadowsTextures.push(target)\r\n }\r\n\r\n }\r\n }\r\n }\r\n\r\n defineShaderName() {\r\n this._vertDefines.push('#define SHADER_NAME ' + this.getVertexShaderName());\r\n this._fragDefines.push(\r\n '#define SHADER_NAME ' + this.getFragmentShaderName(),\r\n );\r\n }\r\n\r\n getFragmentShaderName() {\r\n var compilerName = this.getCompilerName();\r\n var materialName = this._originMaterial && this._originMaterial.getName()\r\n if (materialName)\r\n compilerName += '(' + (materialName = materialName.replace(/[^a-zA-Z0-9]+/g, '_').slice(0, 20)) + ')'\r\n compilerName += this._material.getHasOpacityMap() || this._material.getOpacityFactor() < 1 ? '_BLEND' : '_OPAQUE';\r\n\r\n // , material = this._material && this._material.getName();\r\n // material && (compilerName += \"(\" + (material = material.replace(/[^a-zA-Z0-9]+/g, \"_\").slice(0, 20)) + \")\");\r\n // var renderMode, channels = this._channels && this._channels.Opacity\r\n // var type = channels && channels.isEffective() && channels.get(\"type\");\r\n // if (renderMode = \"alphaBlend\" === type || \"additive\" === type ? \"Blend\" : \"refraction\" === type ? \"Refract\" : \"dithering\" === type ? \"Dither\" : \"Opaque\",\r\n // this._channels && this._channels.AlphaMask && this._channels.AlphaMask.isEffective() && (renderMode = \"AlphaMask\" + renderMode),\r\n // renderMode) {\r\n // var name = this.getCompilerName();\r\n // compilerName = compilerName.replace(name, name + \"_\" + renderMode)\r\n // }\r\n return compilerName;\r\n }\r\n\r\n getVertexShaderName() {\r\n return this.getFragmentShaderName();\r\n }\r\n\r\n getDebugIdentifier() {\r\n var vert = this.getVertexShaderName();\r\n var frag = this.getFragmentShaderName();\r\n return vert === frag ? frag : vert + '|' + frag;\r\n }\r\n\r\n createShader(isFrag) {\r\n var mainSource = isFrag ? this.getFragmentMain() : this.getVertexMain();\r\n\r\n var defines = isFrag ? this._fragDefines : this._vertDefines;\r\n\r\n defines = shaderProcessor.getSortedUnique(defines);\r\n var defineStr = '';\r\n for (var index = 0; index < defines.length; ++index) {\r\n if (defines[index]) defineStr += defines[index] + '\\n';\r\n }\r\n defineStr =\r\n '#define SHADER_NAME ' + this.getFragmentShaderName() + '\\n' + defineStr;\r\n\r\n if (isFrag && this._diamondAttribute) {\r\n defineStr += diamondShader\r\n\r\n } else {\r\n defineStr += '#pragma include \"' + mainSource + '\"';\r\n }\r\n\r\n\r\n return shaderProcessor.processShader(defineStr);\r\n }\r\n\r\n createFragmentShader() {\r\n return this.createShader(true);\r\n }\r\n\r\n createVertexShader() {\r\n return this.createShader(false);\r\n }\r\n\r\n declareAndAssignTexCoord(unit, t) { }\r\n\r\n _getTexCoordTransforms(e, t) { }\r\n\r\n getChannelUV(channel) { }\r\n\r\n defineOpacity() {\r\n if (this._material.getHasOpacityMap()) {\r\n this._fragDefines.push('#define HAS_OPACITYMAP');\r\n }\r\n if (this._material._invertAlpha) {\r\n this._fragDefines.push('#define INVERT_ALPHA');\r\n }\r\n }\r\n\r\n defineChannel(channel) {\r\n var channelName = channel.getName();\r\n }\r\n\r\n defineVertexColorAndAlpha() {\r\n if (this._material && this._material.getVertexColorEnable()) {\r\n this._fragDefines.push('#define HAS_VERTEX_COLOR');\r\n this._vertDefines.push('#define HAS_VERTEX_COLOR');\r\n }\r\n }\r\n\r\n defineEnvironment() {\r\n if (this._envSpecular) {\r\n this._fragDefines.push('#define LUV');\r\n if (this._envSpecular.getIsCubemap()) {\r\n this._fragDefines.push('#define ENV_CUBEMAP');\r\n } else {\r\n this._fragDefines.push('#define ENV_PANORAMA');\r\n }\r\n }\r\n }\r\n defineSsr() { }\r\n defineSkinning() {\r\n if (this._skinning) {\r\n this._vertDefines.push('#define HAS_SKINNING');\r\n this._vertDefines.push(\r\n '#define NUM_BONES ' + this._skinning.getBoneUniformSize(),\r\n );\r\n }\r\n }\r\n defineMorphing() {\r\n if (!this._morphing) return;\r\n\r\n if (this._morphing.hasTarget('Vertex')) {\r\n this._vertDefines.push('#define HAS_MORPHING');\r\n this._vertDefines.push(\r\n '#define NUM_TARGETS ' + this._morphing.getNumTargets(),\r\n );\r\n }\r\n\r\n if (this._morphing.hasTarget('Normal')) {\r\n this._vertDefines.push('#define HAS_MORPHING_NORMAL');\r\n }\r\n\r\n if (this._morphing.hasTarget('Tangent')) {\r\n this._vertDefines.push('#define HAS_MORPHING_TANGENT');\r\n }\r\n }\r\n defineChannels() {\r\n var channels = this._channels;\r\n for (var key in channels) {\r\n this.defineChannel(channels[key]);\r\n }\r\n if (this._changeColorAttribute) {\r\n this._fragDefines.push('#define CHANGE_COLOR');\r\n if (this._changeColorAttribute.isUseSourceColor()) {\r\n this._fragDefines.push('#define CHANGE_COLOR_SOURCE');\r\n } else {\r\n this._fragDefines.push('#define FETCH_LOD');\r\n }\r\n\r\n }\r\n if (this._material.getHasNormalMap()) {\r\n this._fragDefines.push('#define HAS_NORMALMAP');\r\n }\r\n if (this._material.getHasClearcoat()) {\r\n this._fragDefines.push('#define HAS_CLEARCOAT');\r\n }\r\n\r\n if (this._material.getHasAOMap()) {\r\n this._fragDefines.push('#define HAS_AOMAP');\r\n }\r\n\r\n if (this._material.getHasDisplacementMap()) {\r\n this._vertDefines.push('#define HAS_DISPLACEMENT');\r\n this._vertDefines.push('#define HAS_MODEL_NORMAL');\r\n\r\n }\r\n if (!this._material.getMetalnessWorkFlow()) {\r\n this._fragDefines.push('#define SPECULAR_GLOSSINESS');\r\n }\r\n }\r\n\r\n defineUV() {\r\n\r\n if (this._uvTransform) {\r\n this._fragDefines.push('#define UV_TRANSFORM');\r\n this._vertDefines.push('#define UV_TRANSFORM');\r\n }\r\n\r\n if (this._uvProjection) {\r\n const mode = this._uvProjection.getMode()\r\n this._fragDefines.push('#define ' + mode)\r\n this._vertDefines.push('#define ' + mode)\r\n }\r\n }\r\n\r\n defineSticker() {\r\n\r\n if (this._sticker) {\r\n const num = this._sticker._feature._stickers.length\r\n if (num > 0) {\r\n this._fragDefines.push('#define HAS_STICKER ');\r\n this._fragDefines.push('#define STICKER_NUM ' + num);\r\n }\r\n }\r\n }\r\n\r\n defineCompression() { }\r\n definePointSize() { }\r\n defineUnLit() {\r\n if (this._material.getUnLit()) {\r\n this._fragDefines.push('#define UNLIT');\r\n }\r\n }\r\n initDefines() {\r\n if (isMobile) this._fragDefines.push('#define MOBILE');\r\n this.defineChannels();\r\n // this.defineVertexColorAndAlpha(),\r\n this.defineLights(),\r\n this.defineShadows(),\r\n this.defineEnvironment();\r\n // this.defineSsr(),\r\n this.defineMorphing();\r\n this.defineSkinning();\r\n this.defineUV();\r\n this.defineOpacity();\r\n this.defineSticker()\r\n this.defineUnLit()\r\n // this.defineCompression(),\r\n // this.definePointSize();\r\n }\r\n}\r\n\r\nosg.setStateAttributeConfig(PBRCompiler, {\r\n attribute: [\r\n 'PBRMaterial',\r\n 'EditorLight0',\r\n 'EditorLight1',\r\n 'EditorLight2',\r\n 'EditorLight3',\r\n \"ShadowReceive0\",\r\n \"ShadowReceive1\",\r\n \"ShadowReceive2\",\r\n \"ShadowReceive3\",\r\n 'Material', 'Morph', 'Skinning', 'UVTransformAttribute', 'UVProjectionAttribute', 'StickerAttribute', 'ChangeColorAttribute', 'DiamondAttribute'],\r\n textureAttribute: ['Texture'],\r\n});\r\n\r\nexport default PBRCompiler;","import osg from \"../osg/osg\";\r\nimport PBRCompiler from \"./PBRCompiler\";\r\nclass OutlineCompiler extends PBRCompiler {\r\n constructor(attr, textureAttr) {\r\n super(attr, textureAttr);\r\n }\r\n getCompilerName() {\r\n return 'OutLine';\r\n }\r\n getFragmentMain() {\r\n return 'outline.frag';\r\n }\r\n getVertexMain() {\r\n return 'outline.vert';\r\n }\r\n\r\n getFragmentShaderName() {\r\n var compilerName = this.getCompilerName();\r\n return compilerName;\r\n }\r\n}\r\n\r\nosg.setStateAttributeConfig(OutlineCompiler, {\r\n attribute: [\r\n 'VertexCompression',\r\n 'PBRMaterial',\r\n 'Morph',\r\n 'Skinning',\r\n 'PointSize',\r\n 'UVTransformAttribute', \r\n 'UVProjectionAttribute'\r\n ],\r\n textureAttribute: ['Texture'],\r\n});\r\n\r\nexport default OutlineCompiler;","import osg from \"../osg/osg\";\r\nimport DiamondAttribute from \"./DiamondAttribute\";\r\nimport PBRCompiler from './PBRCompiler';\r\nimport osgShader from \"../osgShader/osgShader\";\r\nconst shaderProcessor = osgShader.NextShaderProcessor;\r\n\r\n\r\nclass EarlyZCompiler extends PBRCompiler {\r\n constructor(attr, textureAttr) {\r\n super(attr, textureAttr);\r\n }\r\n getCompilerName () {\r\n return 'EarlyZ'\r\n }\r\n getFragmentMain () {\r\n return 'earlyZFrag.glsl'\r\n }\r\n initDefines() {\r\n super.initDefines()\r\n if(this._material.getOnlyDepthMaskNoShading())\r\n this._fragDefines.push('#define ONLY_DEPTH_NO_SHADE');\r\n if (this._diamondAttribute) \r\n this._fragDefines.push('#define DIAMOND')\r\n }\r\n createShader(isFrag) {\r\n var mainSource = isFrag ? this.getFragmentMain(): this.getVertexMain();\r\n\r\n var defines = isFrag ? this._fragDefines : this._vertDefines;\r\n\r\n defines = shaderProcessor.getSortedUnique(defines);\r\n var defineStr = '';\r\n for (var index = 0; index < defines.length; ++index) {\r\n if (defines[index]) defineStr += defines[index] + '\\n';\r\n }\r\n defineStr =\r\n '#define SHADER_NAME ' + this.getFragmentShaderName() + '\\n' + defineStr;\r\n\r\n defineStr += '#pragma include \"' + mainSource + '\"'; \r\n return shaderProcessor.processShader(defineStr);\r\n }\r\n}\r\n\r\nosg.setStateAttributeConfig(EarlyZCompiler, {\r\n attribute: ['PBRMaterial', 'Material', 'Morph', 'Skinning', 'UVTransformAttribute', 'UVProjectionAttribute', 'DiamondAttribute'],\r\n textureAttribute: ['Texture'],\r\n});\r\n\r\nexport default EarlyZCompiler;","\r\n\r\n\r\nimport osg from \"../osg/osg\";\r\nimport osgShader from \"../osgShader/osgShader\";\r\n\r\nimport EditorCompiler from './EditorCompiler';\r\nimport isMobile from './isMobile';\r\nconst shaderProcessor = osgShader.NextShaderProcessor;\r\nclass ShadowCastCompiler extends EditorCompiler {\r\n constructor(attr, textureAttr) {\r\n super(attr, textureAttr);\r\n }\r\n getCompilerName() {\r\n return \"ShadowCast\"\r\n }\r\n getFragmentMain() {\r\n return \"shadowCastFrag.glsl\"\r\n }\r\n getVertexMain() {\r\n return \"shadowing/shadowCast.vert\"\r\n }\r\n\r\n initAttributes(attributes) {\r\n for (var index = 0; index < attributes.length; index++) {\r\n var typeName = attributes[index].className();\r\n if ('PBRMaterial' === typeName) {\r\n this._material = attributes[index];\r\n } else if ('EditorLight' == typeName) { \r\n this._lights.push(attributes[index])\r\n }else if ('Material' === typeName) {\r\n this._originMaterial = attributes[index];\r\n } else if ('SkinningAttribute' === typeName) {\r\n this._skinning = attributes[index];\r\n } else if ('MorphAttribute' === typeName) {\r\n this._morphing = attributes[index];\r\n } else if ('UVTransformAttribute' == typeName) {\r\n //console.log('UVTRANSFORM');\r\n this._uvTransform = attributes[index];\r\n } else if ('UVProjectionAttribute' == typeName) {\r\n this._uvProjection = attributes[index];\r\n } else if ('StickerAttribute' == typeName) { \r\n this._sticker = attributes[index];\r\n }else if ('ShadowReceiveAttribute' == typeName) { \r\n this._shadows.push(attributes[index])\r\n }\r\n }\r\n }\r\n\r\n initTextureAttributes(textureAttributes) {\r\n for (var index = 0; index < textureAttributes.length; index++) {\r\n var textureAttribute = textureAttributes[index];\r\n if (textureAttribute)\r\n for (var j = 0; j < textureAttribute.length; j++) {\r\n var target = textureAttribute[j];\r\n this._targetByUnit[index] = target;\r\n var typeName = target.className();\r\n if ('TextureEnvironment' === typeName) {\r\n var channel = target.getChannel();\r\n if ('SpecularPBR' === channel) {\r\n this._envSpecular = target;\r\n } else if ('IntegrateBRDF' === channel) {\r\n this._envBrdf = target;\r\n }\r\n }\r\n if(\"ShadowTexture\" === typeName || \"ShadowTextureAtlas\" === typeName){\r\n this._shadowsTextures.push(target)\r\n }\r\n \r\n }\r\n }\r\n }\r\n\r\n defineShaderName() {\r\n this._vertDefines.push('#define SHADER_NAME ' + this.getVertexShaderName());\r\n this._fragDefines.push(\r\n '#define SHADER_NAME ' + this.getFragmentShaderName(),\r\n );\r\n }\r\n\r\n getFragmentShaderName() {\r\n var compilerName = this.getCompilerName();\r\n var materialName = this._originMaterial && this._originMaterial.getName()\r\n if(materialName)\r\n compilerName += '(' + (materialName = materialName.replace(/[^a-zA-Z0-9]+/g, '_').slice(0, 20)) + ')'\r\n compilerName += this._material.getHasOpacityMap() || this._material.getOpacityFactor() < 1 ? '_BLEND' : '_OPAQUE';\r\n\r\n // , material = this._material && this._material.getName();\r\n // material && (compilerName += \"(\" + (material = material.replace(/[^a-zA-Z0-9]+/g, \"_\").slice(0, 20)) + \")\");\r\n // var renderMode, channels = this._channels && this._channels.Opacity\r\n // var type = channels && channels.isEffective() && channels.get(\"type\");\r\n // if (renderMode = \"alphaBlend\" === type || \"additive\" === type ? \"Blend\" : \"refraction\" === type ? \"Refract\" : \"dithering\" === type ? \"Dither\" : \"Opaque\",\r\n // this._channels && this._channels.AlphaMask && this._channels.AlphaMask.isEffective() && (renderMode = \"AlphaMask\" + renderMode),\r\n // renderMode) {\r\n // var name = this.getCompilerName();\r\n // compilerName = compilerName.replace(name, name + \"_\" + renderMode)\r\n // }\r\n return compilerName;\r\n }\r\n\r\n getVertexShaderName() {\r\n return this.getFragmentShaderName();\r\n }\r\n\r\n getDebugIdentifier() {\r\n var vert = this.getVertexShaderName();\r\n var frag = this.getFragmentShaderName();\r\n return vert === frag ? frag : vert + '|' + frag;\r\n }\r\n\r\n createShader(isFrag) {\r\n var mainSource = isFrag ? this.getFragmentMain() : this.getVertexMain();\r\n var defines = isFrag ? this._fragDefines : this._vertDefines;\r\n\r\n defines = shaderProcessor.getSortedUnique(defines);\r\n var defineStr = '';\r\n for (var index = 0; index < defines.length; ++index) {\r\n if (defines[index]) defineStr += defines[index] + '\\n';\r\n }\r\n defineStr =\r\n '#define SHADER_NAME ' + this.getFragmentShaderName() + '\\n' + defineStr;\r\n defineStr += '#pragma include \"' + mainSource + '\"';\r\n\r\n return shaderProcessor.processShader(defineStr);\r\n }\r\n\r\n createFragmentShader() {\r\n return this.createShader(true);\r\n }\r\n\r\n createVertexShader() {\r\n return this.createShader(false);\r\n }\r\n\r\n declareAndAssignTexCoord(unit, t) {}\r\n\r\n _getTexCoordTransforms(e, t) {}\r\n\r\n getChannelUV(channel) {}\r\n\r\n defineOpacity() {\r\n if (this._material.getHasOpacityMap()) {\r\n this._fragDefines.push('#define HAS_OPACITYMAP');\r\n }\r\n if(this._material._invertAlpha){\r\n this._fragDefines.push('#define INVERT_ALPHA');\r\n }\r\n }\r\n\r\n defineChannel(channel) {\r\n var channelName = channel.getName();\r\n }\r\n\r\n defineVertexColorAndAlpha() {\r\n if (this._material && this._material.getVertexColorEnable()) {\r\n this._fragDefines.push('#define HAS_VERTEX_COLOR');\r\n this._vertDefines.push('#define HAS_VERTEX_COLOR');\r\n }\r\n }\r\n\r\n defineEnvironment() {\r\n if (this._envSpecular) {\r\n this._fragDefines.push('#define LUV');\r\n if (this._envSpecular.getIsCubemap()) {\r\n this._fragDefines.push('#define ENV_CUBEMAP');\r\n } else {\r\n this._fragDefines.push('#define ENV_PANORAMA');\r\n }\r\n }\r\n }\r\n defineSsr() {}\r\n defineSkinning() {\r\n if (this._skinning) {\r\n this._vertDefines.push('#define HAS_SKINNING');\r\n this._vertDefines.push(\r\n '#define NUM_BONES ' + this._skinning.getBoneUniformSize(),\r\n );\r\n }\r\n } \r\n defineMorphing() {\r\n if (!this._morphing) return;\r\n\r\n if (this._morphing.hasTarget('Vertex')) {\r\n this._vertDefines.push('#define HAS_MORPHING');\r\n this._vertDefines.push(\r\n '#define NUM_TARGETS ' + this._morphing.getNumTargets(),\r\n );\r\n }\r\n\r\n if (this._morphing.hasTarget('Normal')) {\r\n this._vertDefines.push('#define HAS_MORPHING_NORMAL');\r\n }\r\n\r\n if (this._morphing.hasTarget('Tangent')) {\r\n this._vertDefines.push('#define HAS_MORPHING_TANGENT');\r\n }\r\n }\r\n defineChannels() {\r\n var channels = this._channels;\r\n for (var key in channels) {\r\n this.defineChannel(channels[key]);\r\n }\r\n if (this._material.getHasNormalMap()) {\r\n this._fragDefines.push('#define HAS_NORMALMAP');\r\n }\r\n if (this._material.getHasAOMap()) {\r\n this._fragDefines.push('#define HAS_AOMAP');\r\n }\r\n }\r\n\r\n defineUV() {\r\n \r\n if (this._uvTransform) {\r\n this._fragDefines.push('#define UV_TRANSFORM');\r\n } \r\n\r\n if (this._uvProjection) {\r\n const mode = this._uvProjection.getMode() \r\n switch (mode) {\r\n case UVProjectionAttribute.ProjectionMode.POLAR:\r\n this._fragDefines.push('#define ' + mode)\r\n break\r\n case UVProjectionAttribute.ProjectionMode.TRIPLANAR: \r\n this._fragDefines.push('#define ' + mode)\r\n break\r\n case UVProjectionAttribute.ProjectionMode.ORTHOGONAL:\r\n this._fragDefines.push('#define ' + mode)\r\n break\r\n default:\r\n break\r\n } \r\n } \r\n }\r\n \r\n\r\n\r\n defineCompression() {}\r\n definePointSize() {}\r\n\r\n initDefines() {\r\n if (isMobile) this._fragDefines.push('#define MOBILE');\r\n\r\n this.defineMorphing();\r\n this.defineSkinning();\r\n this.defineUV();\r\n this.defineOpacity();\r\n }\r\n}\r\n\r\nosg.setStateAttributeConfig(ShadowCastCompiler, {\r\n attribute: ['ShadowCastCompiler',\r\n \"VertexCompression\", \"PBRMaterial\", \"Morph\", \"Skinning\", \"ShadowCast\"],\r\n textureAttribute: ['Texture'],\r\n});\r\n\r\nexport default ShadowCastCompiler;","import osg from \"../osg/osg\";\r\nimport osgShader from \"../osgShader/osgShader\";\r\n\r\nimport Material from './Material';\r\nimport EditorCompiler from './EditorCompiler';\r\nimport OutlineCompiler from './OutlineCompiler';\r\nimport PBRCompiler from './PBRCompiler';\r\nimport EarlyZCompiler from './EarlyZCompiler';\r\nimport ShadowCastCompiler from './ShadowCastCompiler'\r\nconst ShaderGenerator = osgShader.ShaderGenerator;\r\n\r\nclass EditorShaderGenerator extends ShaderGenerator {\r\n constructor(shaderCompiler, compilerType) {\r\n super();\r\n this.compilingProgramNum = -1;\r\n this.setShaderCompiler(shaderCompiler),\r\n (this._materialHashCompiler = compilerType || Material.SHADING_COMPILER);\r\n }\r\n getOrCreateProgram(e) {\r\n Material.CURRENT_COMPILER = this._materialHashCompiler;\r\n return ShaderGenerator.prototype.getOrCreateProgram.call(this, e);\r\n }\r\n _getProgram(hash, state, attributes, textureattributes) {\r\n var cache = this._cache[hash];\r\n if (cache && -1 === cache.getAsyncCompiling()) {\r\n return cache;\r\n } else {\r\n if (cache) {\r\n if (cache.getAsyncLinkingStatus()) {\r\n cache.getLinkResult(state.getGraphicContext()),\r\n (this.compilingProgramNum -= 1),\r\n (attributes.length = 0),\r\n (textureattributes.length = 0),\r\n this.getActiveAttributeList(state, attributes),\r\n this.getActiveTextureAttributeList(state, textureattributes),\r\n cache.setActiveUniforms(\r\n this.getActiveUniforms(state, attributes, textureattributes),\r\n );\r\n return cache;\r\n } else {\r\n state.getUserData().app._frameManager.draw();\r\n return cache._placeHolder;\r\n }\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n }\r\n\r\n _createProgram(hash, state, attributes, textureattributes) {\r\n var program = ShaderGenerator.prototype._createProgram.call(\r\n this,\r\n hash,\r\n state,\r\n attributes,\r\n textureattributes,\r\n );\r\n if (-1 !== program.getAsyncCompiling()) {\r\n this._waitingProgram ||\r\n ((this._waitingProgram = this._createWaitingProgram(\r\n state,\r\n attributes,\r\n textureattributes,\r\n )),\r\n (this._waitingProgram._name = 'placeHolder')),\r\n program.enableAsyncCompilation(\r\n this._waitingProgram,\r\n state._frameStamp._frame,\r\n );\r\n compilingProgramNum += 1;\r\n return this._waitingProgram;\r\n } else {\r\n return program;\r\n }\r\n }\r\n}\r\n\r\nvar addShaderGenerator = function(shaderGeneratorProxy, name, shaderCompiler, compilerType) {\r\n shaderGeneratorProxy.addShaderGenerator(name, new EditorShaderGenerator(shaderCompiler, compilerType));\r\n};\r\n\r\nconst registerShaderGenerator = function(shaderGeneratorProxy) {\r\n if (shaderGeneratorProxy.HAS_REGISTED) return;\r\n shaderGeneratorProxy.HAS_REGISTED = true;\r\n\r\n addShaderGenerator(\r\n shaderGeneratorProxy,\r\n 'outline',\r\n OutlineCompiler,\r\n Material.SHADOWCAST_COMPILER,\r\n );\r\n addShaderGenerator(\r\n shaderGeneratorProxy,\r\n 'earlyz',\r\n EarlyZCompiler,\r\n Material.EARLYZ_COMPILER,\r\n );\r\n addShaderGenerator(shaderGeneratorProxy, 'PBR', PBRCompiler);\r\n addShaderGenerator(shaderGeneratorProxy, 'shadowcast', ShadowCastCompiler, Material.SHADOWCAST_COMPILER);\r\n return;\r\n addShaderGenerator(shaderGeneratorProxy, 'lit-classic', EditorCompiler);\r\n addShaderGenerator(shaderGeneratorProxy, 'lit-pbr', EditorCompiler);\r\n addShaderGenerator(shaderGeneratorProxy, 'shadeless-classic', et);\r\n addShaderGenerator(shaderGeneratorProxy, 'shadeless-pbr', et);\r\n addShaderGenerator(shaderGeneratorProxy, 'matcap', nt);\r\n addShaderGenerator(shaderGeneratorProxy, 'ground', ot);\r\n addShaderGenerator(shaderGeneratorProxy, 'shadow-ao-bake', dt);\r\n \r\n addShaderGenerator(\r\n shaderGeneratorProxy,\r\n 'wireframe',\r\n xt,\r\n Material.WIREFRAME_COMPILER,\r\n );\r\n addShaderGenerator(shaderGeneratorProxy, 'shadow-ar', Ct);\r\n addShaderGenerator(shaderGeneratorProxy, 'inspector', Rt);\r\n addShaderGenerator(shaderGeneratorProxy, 'controller', Pt);\r\n addShaderGenerator(shaderGeneratorProxy, 'debugNormal', Ot);\r\n addShaderGenerator(shaderGeneratorProxy, 'debugTangent', Lt);\r\n addShaderGenerator(shaderGeneratorProxy, 'debugGeometry', kt);\r\n addShaderGenerator(shaderGeneratorProxy, 'debugSkinning', Gt);\r\n addShaderGenerator(shaderGeneratorProxy, 'debugBoneBox', jt);\r\n};\r\n\r\nexport default registerShaderGenerator;","import osg from '../osg/osg';\r\n\r\nconst tempXY = [0, 0];\r\nexport default class CanvasPixelRatio {\r\n\r\n init (canvas, pixelRatio) {\r\n this._dynamicResolutionScaling = [1.0, 1.0];\r\n this._canvasPixelRatio = pixelRatio\r\n this._canvas = canvas\r\n this._pixelRatio = [1, 1]\r\n }\r\n getCanvasCoord (event, coord) {\r\n coord = coord || tempXY\r\n if (event.center || event.touches) {\r\n if (event.center)\r\n (coord[0] = event.center.x), (coord[1] = event.center.y);\r\n else {\r\n coord[0] = coord[1] = 0;\r\n for (let i = event.touches.length, n = 0; n < i; ++n)\r\n (coord[0] += event.touches[n].clientX / i),\r\n (coord[1] += event.touches[n].clientY / i);\r\n }\r\n let a = event.target.getBoundingClientRect();\r\n (coord[0] += -a.left), (coord[1] += -a.top);\r\n } else\r\n (coord[0] = undefined === event.offsetX ? event.layerX : event.offsetX),\r\n (coord[1] = undefined === event.offsetY ? event.layerY : event.offsetY);\r\n return coord;\r\n }\r\n getPixelRatio () {\r\n let scaling = this._dynamicResolutionScaling;\r\n this._pixelRatio[0] = this._canvasPixelRatio * scaling[0];\r\n this._pixelRatio[1] = this._canvasPixelRatio * scaling[1];\r\n return this._pixelRatio;\r\n }\r\n canvasCoordToGL (x, y, result) {\r\n let canvas = this._canvas\r\n result = result || osg.vec2.create()\r\n pixelratio = this.getPixelRatio();\r\n result[0] = x * pixelratio[0]\r\n result[1] = (canvas.clientHeight - y) * pixelratio[1]\r\n return result;\r\n }\r\n glCoordToCanvas (x, y, result) {\r\n let canvas = this._canvas\r\n result = result || osg.vec2.create()\r\n let pixelratoi = this.getPixelRatio()\r\n result[0] = x / pixelratoi[0]\r\n result[1] = canvas.clientHeight - y / pixelratoi[1]\r\n return result;\r\n }\r\n};\r\n","export default \"vec4 encodeDepthAlphaProfileScatter(const in float depth, const in float alpha, const in float profile, const in float scatter) {\\r\\n vec4 pack = vec4(0.0);\\r\\n pack.a = alpha;\\r\\n if(profile == 0.0) {\\r\\n const vec3 code = vec3(1.0, 255.0, 65025.0);\\r\\n pack.rgb = vec3(code * depth);\\r\\n pack.gb = fract(pack.gb);\\r\\n pack.rg -= pack.gb * (1.0 / 256.0);\\r\\n }\\r\\n else {\\r\\n pack.g = fract(depth * 255.0);\\r\\n pack.r = depth - pack.g / 255.0;\\r\\n pack.b = floor(0.5 + scatter * 63.0) * 4.0 / 255.0;\\r\\n }\\r\\n pack.b -= mod(pack.b, 4.0 / 255.0);\\r\\n pack.b += profile / 255.0;\\r\\n return pack;\\r\\n}\\r\\nuniform int uDrawOpaque;\\r\\nuniform float uOpacityFactor;\\r\\nuniform vec2 uNearFar;\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec4 vVertexColor;\\r\\nvarying vec3 vAutoUVCoord;\\r\\nvarying vec3 vWorldNormal;\\r\\n\\r\\n\\r\\nvec2 uv;\\r\\n\\r\\n#ifdef UV_TRANSFORM\\r\\nuniform vec4 uUVTransform;\\r\\n#endif\\r\\n\\r\\nvec2 transformUV(vec2 uv) { \\r\\n\\r\\n #ifdef UV_TRANSFORM \\r\\n vec3 transformeduv = mat3(\\r\\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\\r\\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\\r\\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\\r\\n\\r\\n return transformeduv.xy;\\r\\n #else\\r\\n return uv;\\r\\n #endif\\r\\n\\r\\n}\\r\\n\\r\\nuniform sampler2D opacityMap;\\r\\n\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\n\\r\\n#ifdef TRIPLANAR_PROJECTION\\r\\n#pragma include \\\"triplanar_projection.glsl\\\"\\r\\n#endif\\r\\n\\r\\n\\r\\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\\r\\n\\r\\n vec4 color;\\r\\n\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n vec3 coord = vAutoUVCoord * 0.01;\\r\\n color = triplanlar_projection(transformUV(coord.zy), transformUV(coord.xz), transformUV(coord.xy), texture);\\r\\n #else\\r\\n color = texture2D(texture, uv);\\r\\n #endif\\r\\n\\r\\n return color;\\r\\n\\r\\n}\\r\\n\\r\\n\\r\\nfloat getMaterialOpacity() {\\r\\n float alpha = 1.0;\\r\\n#ifdef HAS_OPACITYMAP\\r\\n alpha = fetchTexture(opacityMap, uv).r;\\r\\n#endif\\r\\n alpha *= uOpacityFactor;\\r\\n#ifdef INVERT_ALPHA\\r\\n alpha = 1.0 - alpha;\\r\\n#endif\\r\\n return alpha;\\r\\n}\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n uv = vTexCoord0;\\r\\n \\r\\n #ifdef UV_TRANSFORM\\r\\n uv = transformUV(uv);\\r\\n #endif\\r\\n\\r\\n \\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\\r\\n #endif\\r\\n\\r\\n\\r\\n float depth = (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x);\\r\\n float scatter = 0.0;\\r\\n float profile = 0.0;\\r\\n float alpha = getMaterialOpacity();\\r\\n \\r\\n #ifndef DIAMOND\\r\\n if (uDrawOpaque == 1 && alpha < 9.9999e-1) discard;\\r\\n alpha = uDrawOpaque == 1 ? 1.0 : alpha;\\r\\n #ifdef ONLY_DEPTH_NO_SHADE\\r\\n alpha = 0.0;\\r\\n #endif\\r\\n #else\\r\\n alpha = 1.0;\\r\\n #endif\\r\\n gl_FragColor = encodeDepthAlphaProfileScatter(depth, alpha, profile, scatter);\\r\\n}\\r\\n\";","export default \"uniform samplerCube sSpecularPBR;\\r\\n\\r\\nuniform mat3 uEnvironmentTransform;\\r\\nuniform float uLod;\\r\\nuniform float uEnvironmentExposure;\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\\r\\n#ifdef ENV_CUBEMAP\\r\\n#extension GL_EXT_shader_texture_lod : enable\\r\\n#endif\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\\r\\n\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec3 vLocalVertex;\\r\\n\\r\\n#pragma include \\\"cubemapSampler.glsl\\\"\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\n\\r\\nvoid main() {\\r\\n vec3 direction = normalize( vViewNormal);\\r\\n //direction = normalize(vViewVertex.xyz); // for cube geometry\\r\\n direction = uEnvironmentTransform * direction;\\r\\n#ifdef ENV_CUBEMAP\\r\\n vec3 color = uEnvironmentExposure * textureCubeLodEXTFixed(sSpecularPBR, direction, uLod ).rgb;\\r\\n#else\\r\\n vec3 color = uEnvironmentExposure * textureCubeFixed( sSpecularPBR, direction ).rgb;\\r\\n#endif\\r\\n //color = textureCube(uEnvironment, direction ).rgb;\\r\\n gl_FragColor = vec4( linearTosRGB(color ), 1.0);\\r\\n}\\r\\n\";","export default \"#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\n\\r\\n\\r\\nvec3 scaleDirection(const in float scale, const in vec3 dirIn)\\r\\n{\\r\\n vec3 dir = dirIn;\\r\\n float M = max(max(abs(dir.x), abs(dir.y)), abs(dir.z));\\r\\n if (abs(dir.x) != M) dir.x *= scale;\\r\\n if (abs(dir.y) != M) dir.y *= scale;\\r\\n if (abs(dir.z) != M) dir.z *= scale;\\r\\n return dir;\\r\\n}\\r\\n\\r\\nvec3 textureCubemapLod(const in samplerCube tex, const in vec3 dir, const in float lod )\\r\\n{\\r\\n#ifdef ENV_CUBEMAP\\r\\n vec4 rgba = textureCubeLodEXT( tex, dir, lod );\\r\\n#else\\r\\n vec4 rgba = textureCube( tex, dir );\\r\\n#endif\\r\\n#ifdef FLOAT\\r\\n return rgba.rgb;\\r\\n#endif\\r\\n#ifdef RGBE\\r\\n return RGBEToRGB( rgba );\\r\\n#endif\\r\\n#ifdef RGBM\\r\\n return RGBMToRGB( rgba );\\r\\n#endif\\r\\n#ifdef LUV\\r\\n return LUVToRGB( rgba );\\r\\n#endif\\r\\n}\\r\\n\\r\\nvec3 textureCubemap(const in samplerCube tex, const in vec3 dir )\\r\\n{\\r\\n vec4 rgba = textureCube( tex, dir );\\r\\n#ifdef FLOAT\\r\\n return rgba.rgb;\\r\\n#endif\\r\\n#ifdef RGBE\\r\\n return RGBEToRGB( rgba );\\r\\n#endif\\r\\n#ifdef RGBM\\r\\n return RGBMToRGB( rgba );\\r\\n#endif\\r\\n#ifdef LUV\\r\\n return LUVToRGB( rgba );\\r\\n#else\\r\\n return rgba.rgb;\\r\\n#endif\\r\\n}\\r\\n\\r\\n\\r\\n\\r\\nvec3 cubemapSeamlessFixDirection(const in vec3 direction, const in float scale )\\r\\n{\\r\\n vec3 dir = direction;\\r\\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\\r\\n float M = max(max(abs(dir.x), abs(dir.y)), abs(dir.z));\\r\\n\\r\\n if (abs(dir.x) != M) dir.x *= scale;\\r\\n if (abs(dir.y) != M) dir.y *= scale;\\r\\n if (abs(dir.z) != M) dir.z *= scale;\\r\\n\\r\\n return dir;\\r\\n}\\r\\n\\r\\nvec3 textureCubeLodEXTFixed(const in samplerCube tex, const in vec3 direction, const in float lodInput )\\r\\n{\\r\\n\\r\\n float lod = min( uTextureEnvironmentSpecularPBRLodRange[0], lodInput );\\r\\n\\r\\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\\r\\n float scale = 1.0 - exp2(lod) / uTextureEnvironmentSpecularPBRTextureSize[0];\\r\\n vec3 dir = cubemapSeamlessFixDirection( direction, scale);\\r\\n\\r\\n return textureCubemapLod( tex, dir, lod ).rgb;\\r\\n}\\r\\n\\r\\n\\r\\n// seamless cubemap for background ( no lod )\\r\\nvec3 textureCubeFixed(const in samplerCube tex, const in vec3 direction )\\r\\n{\\r\\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\\r\\n float scale = 1.0 - 1.0 / uTextureEnvironmentSpecularPBRTextureSize[0];\\r\\n vec3 dir = cubemapSeamlessFixDirection( direction, scale);\\r\\n return textureCubemap( tex, dir );\\r\\n}\\r\\n\";","export default \"attribute vec3 Vertex;\\r\\nattribute vec3 Normal;\\r\\nattribute vec2 TexCoord0;\\r\\nattribute vec4 Tangent;\\r\\n\\r\\nuniform mat4 uModelViewMatrix;\\r\\nuniform mat4 uModelMatrix;\\r\\nuniform mat4 uProjectionMatrix;\\r\\nuniform mat3 uModelViewNormalMatrix;\\r\\n\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec3 vLocalVertex;\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0));\\r\\n vViewNormal = uModelViewNormalMatrix * Normal;\\r\\n vLocalVertex = Vertex;\\r\\n\\r\\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\\r\\n vTexCoord0 = TexCoord0;\\r\\n\\r\\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);\\r\\n}\\r\\n\";","export default \"\\r\\n#define PI 3.1415926535897932384626433832795\\r\\n#define PI_2 (2.0*3.1415926535897932384626433832795)\\r\\n#define INV_PI 1.0/PI\\r\\n#define INV_LOG2 1.4426950408889634073599246810019\\r\\n\";","export default \"uniform vec3 uMaskRange;\\r\\nuniform vec3 uTargetColor;\\r\\nuniform float uMask;\\r\\nuniform float uSourceLod;\\r\\nuniform vec3 uSourceColor;\\r\\n\\r\\nfloat deltaE94(vec3 labA, vec3 labB) {\\r\\n \\r\\n float deltaL = labA.x - labB.x;\\r\\n float deltaA = labA.y - labB.y;\\r\\n float deltaB = labA.z - labB.z;\\r\\n\\r\\n float c1 = length(labA.yz);\\r\\n float c2 = length(labB.yz);\\r\\n vec2 deltaAB = vec2(deltaA, deltaB);\\r\\n float deltaC = c1 - c2;\\r\\n float deltaH = dot(deltaAB, deltaAB) - deltaC * deltaC;\\r\\n deltaH = (deltaH > 0.)? sqrt(deltaH) : 0.;\\r\\n float sc = 1. + 0.045 * c1;\\r\\n float sh = 1. + 0.015 * c1;\\r\\n \\r\\n vec3 diffVector;\\r\\n diffVector.x = deltaL;\\r\\n diffVector.y = deltaC / sc;\\r\\n diffVector.z = deltaH / sh;\\r\\n return length(diffVector);\\r\\n}\\r\\n\\r\\nfloat histogram_scan(float gray, float position, float contrast) {\\r\\n\\r\\n float t = 1.0 - position;\\r\\n float A = (max(t, 0.5) - 0.5) * 2.0;\\r\\n float B = min(t * 2.0, 1.0);\\r\\n \\r\\n float X = clamp(contrast * 0.5, 0., 1.);\\r\\n float minInput = mix(A, B, X); //0.95 /2\\r\\n float maxInput = mix(B, A, X); // 1- 0.95 /2\\r\\n\\r\\n return clamp((gray - minInput) / (maxInput - minInput), 0., 1.);\\r\\n}\\r\\n\\r\\nfloat deltaE2000(vec3 labA, vec3 labB) {\\r\\n \\r\\n \\r\\n float lBarPrime = 0.5 * (labA.x + labB.x);\\r\\n float c1 = length(labA.yz);\\r\\n float c2 = length(labB.yz);\\r\\n float cBar = 0.5 * (c1 + c2);\\r\\n float cBar7 = pow(cBar, 7.0);\\r\\n float g = 0.5 * (1.0 - sqrt(cBar7 / (cBar7 + 6103515625.0)));\\r\\n float a1Prime = labA.y * (1.0 + g);\\r\\n float a2Prime = labB.y * (1.0 + g);\\r\\n float c1Prime = sqrt(a1Prime * a1Prime + labA.z * labA.z);\\r\\n float c2Prime = sqrt(a2Prime * a2Prime + labB.z * labB.z);\\r\\n float cBarPrime = 0.5 * (c1Prime + c2Prime);\\r\\n float h1Prime = atan(labA.z, a1Prime); //rad\\r\\n float dhPrime;\\r\\n\\r\\n if (h1Prime < 0.0) {\\r\\n h1Prime += PI_2;\\r\\n }\\r\\n \\r\\n float h2Prime = atan(labB.z, a2Prime);\\r\\n if (h2Prime < 0.0) {\\r\\n h2Prime += PI_2;\\r\\n }\\r\\n \\r\\n float hBarPrime = (abs(h1Prime - h2Prime) > PI) ? (0.5 * (h1Prime + h2Prime + PI_2)) : (0.5 * (h1Prime + h2Prime));\\r\\n float t = 1.0 - 0.17 * cos(hBarPrime - PI / 6.0) + 0.24 * cos(2.0 * hBarPrime) + 0.32 * cos(3.0 * hBarPrime + PI / 30.0) - 0.20 * cos(4.0 * hBarPrime - 0.35 * PI);\\r\\n \\r\\n if (abs(h2Prime - h1Prime) <= PI) {\\r\\n dhPrime = h2Prime - h1Prime;\\r\\n }\\r\\n else {\\r\\n dhPrime = (h2Prime <= h1Prime) ? (h2Prime - h1Prime + PI_2) : (h2Prime - h1Prime - PI_2);\\r\\n }\\r\\n \\r\\n float dLPrime = labB.x - labA.x;\\r\\n float dCPrime = c2Prime - c1Prime;\\r\\n float dHPrime = 2.0 * sqrt(c1Prime * c2Prime) * sin(0.5 * dhPrime);\\r\\n float sL = 1.0 + (0.015 * (lBarPrime - 50.0) * (lBarPrime - 50.0)) / sqrt(20.0 + (lBarPrime - 50.0) * (lBarPrime - 50.0));\\r\\n float sC = 1.0 + 0.045 * cBarPrime;\\r\\n float sH = 1.0 + 0.015 * cBarPrime * t;\\r\\n float temp = (hBarPrime - (275.0 * PI / 180.)) / (25.0 * PI / 180.);\\r\\n float dTheta = PI / 3.0 * exp(-(temp * temp));\\r\\n float cBarPrime7 = pow(cBarPrime, 7.0);\\r\\n float rC = sqrt(cBarPrime7 / (cBarPrime7 + 6103515625.0));\\r\\n float rT = -2.0 * rC * sin(dTheta);\\r\\n return sqrt((dLPrime / sL) * (dLPrime / sL) + (dCPrime / sC) * (dCPrime / sC) + (dHPrime / sH) * (dHPrime / sH) + (dCPrime / sC) * (dHPrime / sH) * rT);\\r\\n \\r\\n}\\r\\n\\r\\nvec3 Lab2LCHab(vec3 X) {\\r\\n \\r\\n float l = X.x;\\r\\n float c = length(X.yz);\\r\\n float h = 180.0 * atan(X.z, X.y) / PI;\\r\\n if (h < 0.0) {\\r\\n h += 360.0;\\r\\n }\\r\\n return vec3(l, c, h);\\r\\n}\\r\\n\\r\\nvec3 XYZ2Lab(vec3 X) {\\r\\n vec3 Y = X / vec3(0.95047, 1.0, 1.08883); //D65\\r\\n vec3 Z;\\r\\n float powN = 1./3.;\\r\\n float constN = 16./116.;\\r\\n Z.x = (Y.x > 0.008856)? pow(Y.x, powN) : (7.787 * Y.x) + constN;\\r\\n Z.y = (Y.y > 0.008856)? pow(Y.y, powN) : (7.787 * Y.y) + constN;\\r\\n Z.z = (Y.z > 0.008856)? pow(Y.z, powN) : (7.787 * Y.z) + constN;\\r\\n return vec3((116. * Z.y) - 16., 500. * (Z.x - Z.y), 200. * (Z.y - Z.z));\\r\\n}\\r\\nvec3 sRGB2XYZ(vec3 X) {\\r\\n vec3 linear = sRGBToLinear(X);\\r\\n return linear * mat3(0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9505);\\r\\n}\\r\\n\\r\\nvec3 sRGB2Lab(vec3 X) { \\r\\n return XYZ2Lab(sRGB2XYZ(X));\\r\\n}\\r\\n\\r\\nvec3 sRGB2LCHab(vec3 X) {\\r\\n return Lab2LCHab(sRGB2Lab(X));\\r\\n}\\r\\n\\r\\nvec3 LCHab2Lab(vec3 X) {\\r\\n \\r\\n float l = X.x;\\r\\n float a = X.y * cos(X.z * PI / 180.0);\\r\\n float b = X.y * sin(X.z * PI / 180.0);\\r\\n return vec3(l, a, b);\\r\\n}\\r\\n\\r\\nvec3 Lab2XYZ(vec3 X) {\\r\\n float fy = (X.x + 16.0) / 116.0;\\r\\n float fx = 0.002 * X.y + fy;\\r\\n float fz = fy - 0.005 * X.z;\\r\\n \\r\\n float fx3 = fx * fx * fx;\\r\\n float fz3 = fz * fz * fz;\\r\\n \\r\\n float m_kE = 216.0 / 24389.0;\\r\\n float m_kK = 24389.0 / 27.0;\\r\\n\\r\\n float xr = (fx3 > m_kE) ? fx3 : ((116.0 * fx - 16.0) / m_kK);\\r\\n float yr = (X.x > 8.0) ? pow((X.x + 16.0) / 116.0, 3.0) : (X.x / m_kK);\\r\\n float zr = (fz3 > m_kE) ? fz3 : ((116.0 * fz - 16.0) / m_kK);\\r\\n \\r\\n return vec3(xr, yr, zr) * vec3(0.95047, 1.0, 1.08883);\\r\\n \\r\\n}\\r\\n\\r\\nvec3 XYZ2sRGB(vec3 X) {\\r\\n \\r\\n vec3 linear = X * mat3(3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252);\\r\\n return linearTosRGB(linear);\\r\\n}\\r\\n\\r\\nvec3 LCHab2sRGB(vec3 X) {\\r\\n return XYZ2sRGB(Lab2XYZ(LCHab2Lab(X)));\\r\\n}\\r\\n\\r\\n\\r\\nfloat luma(vec3 X){\\r\\n float linearY = dot(sRGBToLinear(X), vec3(0.2126, 0.7152, 0.0722));\\r\\n return linearTosRGB(linearY);\\r\\n}\\r\\n\\r\\n\\r\\n// vec3 RGBtoHCL(vec3 RGB)\\r\\n// {\\r\\n// vec3 HCL;\\r\\n// float H = 0.;\\r\\n// float U = min(RGB.r, min(RGB.g, RGB.b));\\r\\n// float V = max(RGB.r, max(RGB.g, RGB.b));\\r\\n// float Q = 0.03;\\r\\n// HCL.y = V - U;\\r\\n// if (HCL.y != 0.)\\r\\n// {\\r\\n// H = atan(RGB.g - RGB.b, RGB.r - RGB.g) / PI;\\r\\n// Q *= U / V;\\r\\n// }\\r\\n// Q = exp(Q);\\r\\n// HCL.x = fract(H / 2. - min(fract(H), fract(-H)) / 6.);\\r\\n// HCL.y *= Q;\\r\\n// HCL.z = mix(-U, V, Q) / (0.530454533953517 * 2.);\\r\\n// return HCL;\\r\\n// }\\r\\n\\r\\n \\r\\n// vec3 HCLtoRGB(vec3 HCL)\\r\\n// {\\r\\n// vec3 RGB = vec3(0.);\\r\\n// if (HCL.z != 0.)\\r\\n// {\\r\\n// float H = HCL.x;\\r\\n// float C = HCL.y;\\r\\n// float L = HCL.z * 0.530454533953517;\\r\\n// float Q = exp((1. - C / (2. * L)) * 0.03);\\r\\n// float U = (2. * L - C) / (2. * Q - 1.);\\r\\n// float V = C / Q;\\r\\n// float A = (H + min(fract(2. * H) / 4., fract(-2. * H) / 8.)) * PI * 2.;\\r\\n// float T;\\r\\n// H *= 6.;\\r\\n// if (H <= 0.999)\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.r = 1.;\\r\\n// RGB.g = T / (1. + T);\\r\\n// }\\r\\n// else if (H <= 1.001)\\r\\n// {\\r\\n// RGB.r = 1.;\\r\\n// RGB.g = 1.;\\r\\n// }\\r\\n// else if (H <= 2.)\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.r = (1. + T) / T;\\r\\n// RGB.g = 1.;\\r\\n// }\\r\\n// else if (H <= 3.)\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.g = 1.;\\r\\n// RGB.b = 1. + T;\\r\\n// }\\r\\n// else if (H <= 3.999)\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.g = 1. / (1. + T);\\r\\n// RGB.b = 1.;\\r\\n// }\\r\\n// else if (H <= 4.001)\\r\\n// {\\r\\n// RGB.g = 0.;\\r\\n// RGB.b = 1.;\\r\\n// }\\r\\n// else if (H <= 5.)\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.r = -1. / T;\\r\\n// RGB.b = 1.;\\r\\n// }\\r\\n// else\\r\\n// {\\r\\n// T = tan(A);\\r\\n// RGB.r = 1.;\\r\\n// RGB.b = -T;\\r\\n// }\\r\\n// RGB = RGB * V + U;\\r\\n// }\\r\\n// return RGB;\\r\\n// }\\r\\nvec3 RGB2HCL(vec3 X){\\r\\n float L = dot(X, vec3(0.299, 0.587, 0.114));\\r\\n float M = max(X.r, max(X.g, X.b));\\r\\n float m = min(X.r, min(X.g, X.b));\\r\\n float C = M - m;\\r\\n float H;\\r\\n if(abs(C) <= 0.0001) {\\r\\n H = 0.0;\\r\\n } \\r\\n else if(abs(M - X.r) <= 0.0001) {\\r\\n H = mod((X.g - X.b) / C, 6.0);\\r\\n } \\r\\n else if(abs(M - X.g) <= 0.0001) {\\r\\n H = (X.b - X.r) / C + 2.0;\\r\\n } \\r\\n else if(abs(M - X.b) <= 0.0001) {\\r\\n H = (X.r - X.g) / C + 4.0;\\r\\n } else {\\r\\n H = 1.0;\\r\\n }\\r\\n \\r\\n H = H / 6.0;\\r\\n return vec3(H, C, L);\\r\\n}\\r\\n\\r\\nvec3 HCL2RGB(vec3 X) { \\r\\n\\r\\n float H6 = X.x * 6.0;\\r\\n float temp = (1.0 - abs(mod(H6, 2.0) - 1.0)) * X.y;\\r\\n vec3 tempRGB;\\r\\n\\r\\n if(0.0 <= H6 && H6 <= 1.0) {\\r\\n tempRGB = vec3(X.y, temp, 0.0);\\r\\n } \\r\\n else if(1.0 < H6 && H6 <= 2.0){\\r\\n tempRGB = vec3(temp, X.y, 0.0);\\r\\n }\\r\\n else if(2.0 < H6 && H6 <= 3.0){\\r\\n tempRGB = vec3(0.0, X.y, temp);\\r\\n }\\r\\n else if(3.0 < H6 && H6 <= 4.0){\\r\\n tempRGB = vec3(0.0, temp, X.y);\\r\\n }\\r\\n else if(4.0 < H6 && H6 <= 5.0){\\r\\n tempRGB = vec3(temp, 0.0, X.y);\\r\\n }\\r\\n else if(5.0 < H6 && H6 <= 6.0){\\r\\n tempRGB = vec3(X.y, 0.0, temp);\\r\\n } else {\\r\\n tempRGB= vec3(0.0);\\r\\n }\\r\\n float tempLuma = dot(tempRGB, vec3(0.299, 0.587, 0.114));\\r\\n vec3 RGB = tempRGB + vec3(X.z - tempLuma);\\r\\n return RGB;\\r\\n}\\r\\n\\r\\n\\r\\nvec3 changeColor(vec3 originalColor, vec3 sourceColor) {\\r\\n\\r\\n vec3 ohcl = RGB2HCL(originalColor);\\r\\n vec3 shcl = RGB2HCL(sourceColor);\\r\\n \\r\\n vec3 deltaHcl = ohcl - shcl;\\r\\n float absDeltaH = abs(deltaHcl.x);\\r\\n\\r\\n float deltaH = min(1.0 - absDeltaH, absDeltaH);\\r\\n float deltaC = abs(deltaHcl.y);\\r\\n float deltaL = abs(deltaHcl.z);\\r\\n \\r\\n float hRange = uMaskRange.x / 720.0;\\r\\n float cRange = uMaskRange.y * 0.5;\\r\\n float lRange = uMaskRange.z * 0.5;\\r\\n \\r\\n if(uMask == 1.0 && ((deltaH > hRange) || (deltaC > cRange) || (deltaL > lRange))) {\\r\\n return originalColor;\\r\\n } else {\\r\\n vec3 thcl = RGB2HCL(uTargetColor);\\r\\n float H = mod(thcl.x, 1.0);\\r\\n float C = max(deltaHcl.y + thcl.y, 0.0);\\r\\n float L = max(deltaHcl.z + thcl.z, 0.0);\\r\\n return HCL2RGB(vec3(H, C, L));\\r\\n }\\r\\n \\r\\n}\\r\\n\";","export default \"#pragma include \\\"math.glsl\\\"\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\nvec2 computeUVForMipmap( const in float level, const in vec2 uv, const in float size, const in float maxLOD ) {\\r\\n\\r\\n // width for level\\r\\n float widthForLevel = exp2( maxLOD-level);\\r\\n\\r\\n // the height locally for the level in pixel\\r\\n // to opimitize a bit we scale down the v by two in the inputs uv\\r\\n float heightForLevel = widthForLevel * 0.5;\\r\\n\\r\\n\\r\\n#if 0\\r\\n float texelSize = 1.0 / size;\\r\\n\\r\\n float resizeX = (widthForLevel - 2.0) * texelSize;\\r\\n float resizeY = (heightForLevel - 2.0) * texelSize;\\r\\n\\r\\n float uvSpaceLocalX = texelSize + uv.x * resizeX;\\r\\n float uvSpaceLocalY = texelSize + uv.y * resizeY;\\r\\n\\r\\n uvSpaceLocalY += (size - widthForLevel ) / size;\\r\\n\\r\\n return vec2( uvSpaceLocalX, uvSpaceLocalY);\\r\\n\\r\\n#else\\r\\n // compact version\\r\\n float texelSize = 1.0/size;\\r\\n vec2 uvSpaceLocal = vec2(1.0) + uv * vec2(widthForLevel - 2.0, heightForLevel - 2.0);\\r\\n uvSpaceLocal.y += size - widthForLevel;\\r\\n return uvSpaceLocal * texelSize;\\r\\n#endif\\r\\n\\r\\n}\\r\\n\\r\\n//for y up\\r\\nvec2 normalToPanoramaUVY( const in vec3 dir )\\r\\n{\\r\\n float n = length(dir.xz);\\r\\n\\r\\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\\r\\n vec2 pos = vec2( (n>0.0000001) ? max(-1.0,dir.x / n) : 0.0, dir.y);\\r\\n\\r\\n // fix edge bleeding\\r\\n if ( pos.x > 0.0 ) pos.x = min( 0.999999, pos.x );\\r\\n\\r\\n pos = acos(pos)*INV_PI;\\r\\n\\r\\n pos.x = (dir.z > 0.0) ? pos.x*0.5 : 1.0-(pos.x*0.5);\\r\\n\\r\\n // shift u to center the panorama to -z\\r\\n pos.x = mod(pos.x-0.25+1.0, 1.0 );\\r\\n pos.y = 1.0-pos.y;\\r\\n return pos;\\r\\n}\\r\\n\\r\\n\\r\\n// for z up\\r\\nvec2 normalToPanoramaUVZ( const in vec3 dir )\\r\\n{\\r\\n float n = length(dir.xy);\\r\\n\\r\\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\\r\\n vec2 pos = vec2( (n>0.0000001) ? max(-1.0,dir.x / n) : 0.0, dir.z);\\r\\n\\r\\n // fix edge bleeding\\r\\n if ( pos.x > 0.0 ) pos.x = min( 0.999999, pos.x );\\r\\n\\r\\n pos = acos(pos)*INV_PI;\\r\\n\\r\\n // to avoid bleeding the limit must be set to 0.4999999 instead of 0.5\\r\\n pos.x = (dir.y > 0.0) ? pos.x*0.5 : 1.0-(pos.x*0.5);\\r\\n\\r\\n // shift u to center the panorama to -y\\r\\n pos.x = mod(pos.x-0.25+1.0, 1.0 );\\r\\n pos.y = 1.0-pos.y;\\r\\n return pos;\\r\\n}\\r\\n\\r\\n#define normalToPanoramaUV normalToPanoramaUVY\\r\\n\\r\\n\\r\\nvec3 texturePanorama(const in sampler2D tex, const in vec2 uv)\\r\\n{\\r\\n vec4 rgba = texture2D(tex, uv );\\r\\n#ifdef FLOAT\\r\\n return rgba.rgb;\\r\\n#endif\\r\\n#ifdef RGBE\\r\\n return RGBEToRGB( rgba );\\r\\n#endif\\r\\n#ifdef RGBM\\r\\n return RGBMToRGB( rgba );\\r\\n#endif\\r\\n#ifdef LUV\\r\\n return LUVToRGB( rgba );\\r\\n#else\\r\\n return rgba.rgb;\\r\\n#endif\\r\\n}\\r\\n\\r\\nvec3 texturePanoramaLod(const in sampler2D tex,\\r\\n const in vec2 size ,\\r\\n const in vec3 direction,\\r\\n const in float lodInput,\\r\\n const in float maxLOD ) {\\r\\n\\r\\n float lod = min( maxLOD, lodInput );\\r\\n vec2 uvBase = normalToPanoramaUV( direction );\\r\\n\\r\\n // // we scale down v here because it avoid to do twice in sub functions\\r\\n // uvBase.y *= 0.5;\\r\\n\\r\\n float lod0 = floor(lod);\\r\\n vec2 uv0 = computeUVForMipmap(lod0, uvBase, size.x, maxLOD );\\r\\n vec3 texel0 = texturePanorama( tex, uv0.xy);\\r\\n\\r\\n float lod1 = ceil(lod);\\r\\n vec2 uv1 = computeUVForMipmap(lod1, uvBase, size.x, maxLOD );\\r\\n vec3 texel1 = texturePanorama( tex, uv1.xy);\\r\\n\\r\\n return mix(texel0, texel1, fract( lod ) );\\r\\n}\\r\\n\\r\\n\";","export default \"\\r\\n// require:\\r\\n// uniform int uEnvironmentMaxLod\\r\\n// samplerCube uEnvironmentCube\\r\\n// uniform sampler2D sIntegrateBRDF;\\r\\n// #pragma include \\\"sphericalHarmonics.glsl\\\"\\r\\n\\r\\n\\r\\n// frostbite, lagarde paper p67\\r\\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf\\r\\nfloat linRoughnessToMipmap( float roughnessLinear )\\r\\n{\\r\\n //return roughnessLinear;\\r\\n return sqrt(roughnessLinear);\\r\\n}\\r\\n\\r\\nvec3 prefilterEnvMap( float roughnessLinear, const in vec3 R )\\r\\n{\\r\\n#ifdef ENV_CUBEMAP\\r\\n\\r\\n float lod = linRoughnessToMipmap(roughnessLinear) * uTextureEnvironmentSpecularPBRLodRange[1]; //( uEnvironmentMaxLod - 1.0 );\\r\\n return textureCubeLodEXTFixed( sSpecularPBR, R, lod ).rgb;\\r\\n\\r\\n#elif defined(ENV_PANORAMA)\\r\\n float lod = linRoughnessToMipmap(roughnessLinear) * uTextureEnvironmentSpecularPBRLodRange[1];\\r\\n\\r\\n vec2 uvBase = normalToPanoramaUV( R );\\r\\n vec3 texel = texturePanoramaLod( sSpecularPBR,\\r\\n uTextureEnvironmentSpecularPBRTextureSize,\\r\\n R,\\r\\n lod,\\r\\n uTextureEnvironmentSpecularPBRLodRange[0] );\\r\\n return texel;\\r\\n#else \\r\\n return vec3(1.0);\\r\\n#endif\\r\\n\\r\\n\\r\\n// #endif\\r\\n}\\r\\n\\r\\nvec3 integrateBRDF(const in vec3 specular, float r, float NoV ,const in float f90)\\r\\n{\\r\\n vec4 rgba = texture2D( sIntegrateBRDF, vec2(NoV, r ) );\\r\\n\\r\\n const float div = 1.0/65535.0;\\r\\n float b = (rgba[3] * 65280.0 + rgba[2] * 255.0);\\r\\n float a = (rgba[1] * 65280.0 + rgba[0] * 255.0);\\r\\n\\r\\n return (specular * a + b * f90) * div;\\r\\n}\\r\\n\\r\\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile\\r\\nvec3 integrateBRDFApprox( const in vec3 specular, float roughness, float NoV )\\r\\n{\\r\\n const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022 );\\r\\n const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04 );\\r\\n vec4 r = roughness * c0 + c1;\\r\\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\\r\\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\\r\\n return specular * AB.x + AB.y;\\r\\n}\\r\\n\\r\\nvec3 approximateSpecularIBL( const in vec3 specularColor,\\r\\n float rLinear,\\r\\n const in vec3 N,\\r\\n const in vec3 V,\\r\\n const in float f90)\\r\\n{\\r\\n float roughnessLinear = max( rLinear, 0.0);\\r\\n float NoV = dot( N, V );\\r\\n vec3 R = normalize( (2.0 * NoV ) * N - V);\\r\\n\\r\\n\\r\\n // From Sebastien Lagarde Moving Frostbite to PBR page 69\\r\\n // so roughness = linRoughness * linRoughness\\r\\n vec3 dominantR = getSpecularDominantDir( N, R, roughnessLinear*roughnessLinear );\\r\\n\\r\\n vec3 dir = uEnvironmentTransform * dominantR;\\r\\n vec3 prefilteredColor = prefilterEnvMap( roughnessLinear, dir );\\r\\n\\r\\n\\r\\n // marmoset tricks specular occlusion\\r\\n // prefilteredColor *= occlusionHorizon( dominantR, vViewNormal, ao );\\r\\n\\r\\n#ifdef MOBILE\\r\\n return uEnvironmentExposure * prefilteredColor * integrateBRDFApprox( specularColor, roughnessLinear, NoV );\\r\\n#else\\r\\n vec3 envBRDF = integrateBRDF(specularColor, roughnessLinear, NoV, f90 );\\r\\n return uEnvironmentExposure * prefilteredColor * envBRDF;\\r\\n#endif\\r\\n}\\r\\n\\r\\n\\r\\nvec3 computeIBL_UE4( const in vec3 normal,\\r\\n const in vec3 view,\\r\\n const in vec3 albedo,\\r\\n const in float roughness,\\r\\n const in vec3 specular,\\r\\n const in float ao,\\r\\n const in float f90)\\r\\n{\\r\\n\\r\\n vec3 color = vec3(0.0);\\r\\n if ( albedo != color ) { // skip if no diffuse\\r\\n color += uEnvironmentExposure * albedo * ao * evaluateDiffuseSphericalHarmonics(normal,\\r\\n view );\\r\\n }\\r\\n\\r\\n color += approximateSpecularIBL(specular, roughness, normal, view, f90);\\r\\n\\r\\n return color;\\r\\n}\";","export default \"#define PI 3.1415926535897932384626433832795\\r\\n#define PI_2 (2.0*3.1415926535897932384626433832795)\\r\\n#define INV_PI 1.0/PI\\r\\n#define INV_LOG2 1.4426950408889634073599246810019\\r\\n\\r\\n\\r\\nuniform mat3 uEnvironmentTransform;\\r\\nuniform float uRGBMRange;\\r\\n#ifdef ENV_CUBEMAP\\r\\nuniform samplerCube sSpecularPBR;\\r\\n#elif defined(ENV_PANORAMA)\\r\\nuniform sampler2D sSpecularPBR;\\r\\n#endif\\r\\n\\r\\n#if defined(ENV_CUBEMAP) || defined(FETCH_LOD)\\r\\n#extension GL_EXT_shader_texture_lod : enable\\r\\n#endif\\r\\n\\r\\n\\r\\nuniform int uDrawOpaque;\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\\r\\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\\r\\nuniform float uEnvironmentExposure;\\r\\n\\r\\nuniform sampler2D sIntegrateBRDF; // ue4\\r\\n\\r\\nuniform vec3 uDiffuseSPH[9];\\r\\n\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec3 vWorldNormal;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec4 vVertexColor;\\r\\n#ifdef HAS_SHADOW\\r\\n varying vec3 vModelNormal;\\r\\n varying vec3 vModelVertex;\\r\\n#endif\\r\\nvarying vec3 vAutoUVCoord;\\r\\n\\r\\nuniform float uOpacityFactor;\\r\\n#define uNormalMapFactor 1.0\\r\\n// uniform float uNormalMapFactor;\\r\\nuniform int uNormalMapFlipY;\\r\\nuniform sampler2D albedoMap;\\r\\n\\r\\n\\r\\nuniform sampler2D metallicMap;\\r\\nuniform sampler2D roughnessMap;\\r\\nuniform sampler2D normalMap;\\r\\nuniform sampler2D opacityMap;\\r\\nuniform sampler2D aoMap;\\r\\n\\r\\n// uniform sampler2D emissiveMap;\\r\\n// uniform float uGlossinessFactor;\\r\\n// uniform int uSpecularPeak;\\r\\n// uniform int uOcclusionHorizon;\\r\\n\\r\\n#pragma include \\\"sphericalHarmonics.glsl\\\"\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\n#ifdef CHANGE_COLOR\\r\\n#pragma include \\\"changeColor.glsl\\\"\\r\\n#endif\\r\\n\\r\\n#if defined(HAS_LIGHT)\\r\\n#pragma include \\\"utils/lightsPBR.glsl\\\"\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_SHADOW\\r\\n#define OPT_DISTANCE\\r\\n#pragma include \\\"shadowing/shadowReceive.glsl\\\"\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_STICKER\\r\\n#pragma include \\\"sticker.glsl\\\"\\r\\n#endif\\r\\n\\r\\n// From Sebastien Lagarde Moving Frostbite to PBR page 69\\r\\n// We have a better approximation of the off specular peak\\r\\n// but due to the other approximations we found this one performs better.\\r\\n// N is the normal direction\\r\\n// R is the mirror vector\\r\\n// This approximation works fine for G smith correlated and uncorrelated\\r\\nvec3 getSpecularDominantDir(const in vec3 N, const in vec3 R, const in float realRoughness)\\r\\n{\\r\\n vec3 dominant;\\r\\n // if ( uSpecularPeak == 1 ) {\\r\\n float smoothness = 1.0 - realRoughness;\\r\\n float lerpFactor = smoothness * (sqrt(smoothness) + realRoughness);\\r\\n // The result is not normalized as we fetch in a cubemap\\r\\n dominant = mix(N, R, lerpFactor);\\r\\n // } else {\\r\\n // dominant = R;\\r\\n // }\\r\\n return dominant;\\r\\n}\\r\\n\\r\\n\\r\\nvec2 uv;\\r\\n#ifdef UV_TRANSFORM\\r\\nuniform vec4 uUVTransform;\\r\\n#endif\\r\\n\\r\\nvec2 transformUV(vec2 uv) {\\r\\n\\r\\n #ifdef UV_TRANSFORM \\r\\n vec3 transformeduv = mat3(\\r\\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\\r\\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\\r\\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\\r\\n\\r\\n return transformeduv.xy;\\r\\n #else\\r\\n return uv;\\r\\n #endif\\r\\n\\r\\n}\\r\\n\\r\\n\\r\\n#ifdef TRIPLANAR_PROJECTION\\r\\n#pragma include \\\"triplanar_projection.glsl\\\"\\r\\n#endif\\r\\n\\r\\n\\r\\n// #define TRIPLANAR_PROJECTION\\r\\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\\r\\n\\r\\n vec4 color;\\r\\n\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n vec3 coord = vAutoUVCoord * 0.01;\\r\\n vec2 yz = transformUV(coord.yz);\\r\\n vec2 xz = transformUV(coord.xz);\\r\\n vec2 yx = transformUV(coord.yx);\\r\\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\\r\\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\\r\\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\\r\\n color = triplanlar_projection(yz, xz, yx, texture);\\r\\n #else\\r\\n color = texture2D(texture, uv);\\r\\n #endif\\r\\n return color;\\r\\n}\\r\\n\\r\\n#ifdef FETCH_LOD\\r\\n#ifdef TRIPLANAR_PROJECTION\\r\\nvec4 triplanlar_projection_lod(vec2 x, vec2 y, vec2 z, sampler2D texture, float lod)\\r\\n{\\r\\n vec3 triweight = gTriWeight;\\r\\n\\r\\n vec4 color = vec4(0);\\r\\n\\r\\n if (triweight.x > 0.0) {\\r\\n color += triweight.x * texture2DLodEXT(texture, x, lod); // yz\\r\\n }\\r\\n if (triweight.y > 0.0) {\\r\\n color += triweight.y * texture2DLodEXT(texture, y, lod); // xy\\r\\n }\\r\\n if (triweight.z > 0.0) {\\r\\n color += triweight.z * texture2DLodEXT(texture, z, lod); // yx\\r\\n }\\r\\n return color;\\r\\n}\\r\\n#endif\\r\\nvec4 fetchTextureLod(sampler2D texture, vec2 uv, float lod) {\\r\\n\\r\\n vec4 color;\\r\\n\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n vec3 coord = vAutoUVCoord * 0.01;\\r\\n vec2 yz = transformUV(coord.yz);\\r\\n vec2 xz = transformUV(coord.xz);\\r\\n vec2 yx = transformUV(coord.yx);\\r\\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\\r\\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\\r\\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\\r\\n color = triplanlar_projection_lod(yz, xz, yx, texture, lod);\\r\\n #else\\r\\n color = texture2DLodEXT(texture, uv, lod);\\r\\n #endif\\r\\n return color;\\r\\n}\\r\\n#endif\\r\\n\\r\\n\\r\\nfloat occlusionHorizon( const in vec3 R, const in vec3 normal, const in float ao)\\r\\n{\\r\\n // if ( uOcclusionHorizon == 0)\\r\\n return 1.0;\\r\\n\\r\\n // http://marmosetco.tumblr.com/post/81245981087\\r\\n // marmoset uses 1.3, we force it to 1.0\\r\\n // float factor = clamp( 1.0 + dot(R, normal), 0.0, 1.0 );\\r\\n // return factor * factor;\\r\\n float d = dot(normal, R) + ao;\\r\\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\\r\\n}\\r\\n\\r\\n\\r\\nvec3 evaluateDiffuseSphericalHarmonics( const in vec3 N,\\r\\n const in vec3 V ) {\\r\\n return sphericalHarmonics( uDiffuseSPH, uEnvironmentTransform * N );\\r\\n}\\r\\n\\r\\n\\r\\n#ifdef ENV_CUBEMAP\\r\\n#pragma include \\\"cubemapSampler.glsl\\\"\\r\\n#else\\r\\n#pragma include \\\"panoramaSampler.glsl\\\"\\r\\n#endif\\r\\n// \\r\\n\\r\\n\\r\\n\\r\\n#pragma include \\\"pbr_ue4.glsl\\\"\\r\\n\\r\\n\\r\\nvec3 computeNormalFromTangentSpaceNormalMap(const in vec4 tangent, const in vec3 normal, in vec3 texnormal)\\r\\n{\\r\\n vec3 tang = vec3(0.0,1.0,0.0);\\r\\n if (length(tangent.xyz) != 0.0) {\\r\\n tang = normalize(tangent.xyz);\\r\\n }\\r\\n vec3 B = tangent.w * cross(normal, tang);\\r\\n texnormal.xy = uNormalMapFactor * texnormal.xy;\\r\\n vec3 outnormal = texnormal.x*tang + texnormal.y*B + texnormal.z*normal;\\r\\n return normalize(outnormal);\\r\\n}\\r\\n\\r\\nvec3 textureNormal(const in vec3 rgb) {\\r\\n vec3 n = normalize((rgb-vec3(0.5)));\\r\\n n.y = uNormalMapFlipY == 1 ? -n.y : n.y;\\r\\n return n;\\r\\n}\\r\\n\\r\\nfloat adjustRoughness( const in float roughness, const in vec3 normal ) {\\r\\n // Based on The Order : 1886 SIGGRAPH course notes implementation (page 21 notes)\\r\\n float normalLen = length(normal*2.0-1.0);\\r\\n if ( normalLen < 1.0) {\\r\\n float normalLen2 = normalLen * normalLen;\\r\\n float kappa = ( 3.0 * normalLen - normalLen2 * normalLen )/( 1.0 - normalLen2 );\\r\\n // http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/\\r\\n // page 91 : they use 0.5/kappa instead\\r\\n return min(1.0, sqrt( roughness * roughness + 1.0/kappa ));\\r\\n }\\r\\n return roughness;\\r\\n}\\r\\n\\r\\nfloat getMaterialOpacity() {\\r\\n float alpha = 1.0;\\r\\n#ifdef HAS_OPACITYMAP\\r\\n alpha = (fetchTexture(opacityMap, uv).r);\\r\\n#endif\\r\\n alpha *= uOpacityFactor;\\r\\n#ifdef INVERT_ALPHA\\r\\n alpha = 1.0 - alpha;\\r\\n#endif\\r\\n return alpha;\\r\\n}\\r\\n\\r\\n\\r\\nfloat GTR1(float NdotH, float a)\\r\\n{\\r\\n if (a >= 1.) return 1./PI;\\r\\n float a2 = a*a;\\r\\n float t = 1. + (a2-1.)*NdotH*NdotH;\\r\\n return (a2-1.) / (PI*log(a2)*t);\\r\\n}\\r\\n\\r\\nfloat smithG_GGX(float NdotV, float alphaG)\\r\\n{\\r\\n float a = alphaG*alphaG;\\r\\n float b = NdotV*NdotV;\\r\\n return 1. / (NdotV + sqrt(a + b - a*b));\\r\\n}\\r\\n\\r\\n#ifdef HAS_CLEARCOAT\\r\\n\\r\\nuniform vec2 uClearcoatParam;\\r\\n\\r\\nvec3 clearcoatBRDF(float clearcoatRoughness, vec3 eyeVector, vec3 eyeLightDir, vec3 normal) { \\r\\n vec3 H = normalize(eyeVector + eyeLightDir);\\r\\n float NdotH = clamp(dot(normal, H), 0., 1.);\\r\\n float NdotV = clamp(dot(normal, eyeVector), 0., 1.);\\r\\n float NdotL = clamp(dot(normal, eyeLightDir), 0., 1.);\\r\\n float LdotH = clamp(dot(eyeLightDir, H), 0., 1.);\\r\\n // clearcoat (ior = 1.5 -> F0 = 0.04)\\r\\n float Dr = GTR1(NdotH, mix(.001, 0.1, clearcoatRoughness));\\r\\n vec3 Fr = F_Schlick(vec3(.04), 1.0, LdotH);\\r\\n float Gr = smithG_GGX(NdotL, .25) * smithG_GGX(NdotV, .25);\\r\\n return vec3(.25 * uClearcoatParam.x * Gr * Dr) * Fr;\\r\\n}\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_SHEEN\\r\\nfloat sheenLobe(const float sheenRoughness, const float NdotV, const float NdotL, const float NdotH) {\\r\\n float r = sheenRoughness * sheenRoughness;\\r\\n float invAlpha = 1.0 / r;\\r\\n float cos2h = NdotH * NdotH;\\r\\n float sin2h = max(1.0 - cos2h, 0.0078125);\\r\\n float D = (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * 3.141593);\\r\\n float V = clamp(1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV)), 0.0, 1.0);\\r\\n return (D * V);\\r\\n}\\r\\nvec3 sheenColor = vec3(0.);\\r\\n#define uSheenColorFactor vec3(1.0, 1.0, 1.0)\\r\\n#define uSheenFactor 1.0\\r\\n#define uSheenRoughnessFactor 1.0\\r\\nfloat getMaterialSheenRoughness() {\\r\\n return uSheenRoughnessFactor;\\r\\n}\\r\\nvec3 computeSheen(const vec3 normal, const vec3 lightDir, const vec3 eyeVector, const float sheenRoughness) {\\r\\n float NdotL = dot(normal, lightDir);\\r\\n float NdotV = dot(normal, eyeVector);\\r\\n vec3 H = normalize(lightDir + eyeVector);\\r\\n float NdotH = dot(normal, H);\\r\\n float sheenContribution = sheenLobe(max(0.04, sheenRoughness), NdotV, NdotL, NdotH);\\r\\n vec3 sheenColor = uSheenFactor * uSheenColorFactor;\\r\\n return max(vec3(0.0), sheenContribution * sheenColor);\\r\\n}\\r\\n#endif\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n vec3 normal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\\r\\n vec3 eye = -normalize(vViewVertex);\\r\\n vec4 tangent = vViewTangent;\\r\\n uv = vTexCoord0.xy; \\r\\n uv = transformUV(uv); \\r\\n \\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\\r\\n #endif\\r\\n\\r\\n float alpha = 1.0;\\r\\n alpha = getMaterialOpacity();\\r\\n if (alpha == 0.0 || (uDrawOpaque == 1 && alpha < 9.9999e-1) || (uDrawOpaque == 0 && alpha >= 9.9999e-1)) discard; \\r\\n const vec3 dielectricColor = vec3(0.04);\\r\\n float minRoughness = 1.e-4;\\r\\n vec4 albedoSource = fetchTexture( albedoMap, uv );\\r\\n\\r\\n#ifdef CHANGE_COLOR\\r\\n #ifdef CHANGE_COLOR_SOURCE\\r\\n albedoSource.rgb = changeColor(albedoSource.rgb, uSourceColor);\\r\\n #else\\r\\n albedoSource.rgb = changeColor(albedoSource.rgb, fetchTextureLod(albedoMap, uv, uSourceLod).rgb);\\r\\n #endif\\r\\n#endif\\r\\n vec3 albedo = sRGBToLinear( albedoSource.rgb );\\r\\n\\r\\n\\r\\n#ifdef HAS_VERTEX_COLOR\\r\\n vec3 vertexColorLinear = sRGBToLinear( vVertexColor.rgb );\\r\\n // Check non zero non completely transparent\\r\\n if(vertexColorLinear.rgb != vec3(0.0) && vVertexColor.a != 0.0){\\r\\n albedo *= vertexColorLinear;\\r\\n albedoSource.a *= vVertexColor.a;\\r\\n }\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_NORMALMAP\\r\\n vec3 normalTexel;\\r\\n #ifdef TRIPLANAR_PROJECTION \\r\\n normalTexel = fetchTexture(normalMap, uv).rgb;\\r\\n if ( length(normalTexel) > 0.0001 ) {\\r\\n vec3 realNormal = textureNormal( normalTexel );\\r\\n normal = computeNormalFromTangentSpaceNormalMap( tangent, normal, realNormal );\\r\\n }\\r\\n \\r\\n #else \\r\\n normalTexel = texture2D( normalMap, uv ).rgb;\\r\\n if ( length(normalTexel) > 0.0001 ) {\\r\\n vec3 realNormal = textureNormal( normalTexel );\\r\\n normal = computeNormalFromTangentSpaceNormalMap( tangent, normal, realNormal );\\r\\n }\\r\\n #endif\\r\\n\\r\\n#endif\\r\\n\\r\\n#ifdef SPECULAR_GLOSSINESS\\r\\n float roughness = fetchTexture( roughnessMap, uv ).g;\\r\\n roughness = 1.0 - roughness;\\r\\n#else\\r\\n float roughness = fetchTexture( roughnessMap, uv ).g;\\r\\n#endif\\r\\n roughness = max( minRoughness , roughness );\\r\\n float ao = 1.0;\\r\\n\\r\\n#ifdef HAS_NORMALMAP\\r\\n roughness = adjustRoughness( roughness, normalTexel);\\r\\n#endif\\r\\n\\r\\n#ifdef HAS_AOMAP\\r\\n ao = fetchTexture( aoMap, uv ).r;\\r\\n#endif\\r\\n vec3 specular;\\r\\n\\r\\n #ifdef SPECULAR_GLOSSINESS\\r\\n specular = sRGBToLinear( fetchTexture( metallicMap, uv ) ).rgb;\\r\\n #else \\r\\n float metallic = fetchTexture( metallicMap, uv ).g;\\r\\n vec3 albedoReduced = albedo * (1.0 - metallic);\\r\\n specular = mix( dielectricColor, albedo, metallic);\\r\\n albedo = albedoReduced;\\r\\n #endif\\r\\n\\r\\n #ifdef UNLIT\\r\\n vec3 resultIBL = albedo;\\r\\n #else\\r\\n float materialF90 = clamp(50.0 * specular.g, 0.0, 1.0);\\r\\n vec3 resultIBL = computeIBL_UE4( normal, eye, albedo, roughness, specular, ao, materialF90 );\\r\\n\\r\\n #ifdef HAS_CLEARCOAT\\r\\n // float clearcoatRoughness\\r\\n // clearcoat \\r\\n float uClearcoatIntensity = uClearcoatParam.x;\\r\\n float uClearcoatRoughness = uClearcoatParam.y;\\r\\n float clearCoatPerceptualRoughness = clamp(uClearcoatRoughness, 0.089, 1.0);\\r\\n float clearcoatRoughness = clearCoatPerceptualRoughness * clearCoatPerceptualRoughness;\\r\\n resultIBL += approximateSpecularIBL(vec3(0.04), clearcoatRoughness, normal, eye, 1.0) * uClearcoatIntensity; \\r\\n #endif\\r\\n\\r\\n #ifdef HAS_SHEEN\\r\\n float sheenRoughness = getMaterialSheenRoughness();\\r\\n resultIBL += computeSheen(normal, getSpecularDominantDir(normal, reflect(-eye, normal), sheenRoughness), eye, sheenRoughness); \\r\\n #endif\\r\\n\\r\\n #ifdef HAS_LIGHT\\r\\n float attenuation, dotNL;\\r\\n vec3 eyeLightDir;\\r\\n bool lighted;\\r\\n vec3 lightSpecular;\\r\\n vec3 lightDiffuse;\\r\\n vec4 prepGGX = precomputeGGX(normal, eye, max(0.045, roughness));\\r\\n #endif\\r\\n\\r\\n #ifdef HAS_SHADOW\\r\\n float shadow;\\r\\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\\r\\n #endif\\r\\n\\r\\n %UNROLL 4%\\r\\n #ifdef LIGHT_TYPE_%ID%\\r\\n\\r\\n #if LIGHT_TYPE_%ID% == LIGHT_DIRECTION\\r\\n precomputeSun(normal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\\r\\n #endif\\r\\n\\r\\n computeLightLambertGGX(normal, eye, dotNL, prepGGX, albedo, specular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, lightDiffuse, lightSpecular, lighted);\\r\\n #ifdef HAS_CLEARCOAT\\r\\n lightSpecular += clearcoatBRDF(clearcoatRoughness, eye, eyeLightDir, normal);\\r\\n #endif\\r\\n\\r\\n #ifdef HAS_SHADOW_%ID%\\r\\n #ifdef _ATLAS_SHADOW\\r\\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, Texture12, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\r\\n #else\\r\\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\\r\\n #endif \\r\\n\\r\\n lightDiffuse *= shadow;\\r\\n lightSpecular *= shadow;\\r\\n\\r\\n #endif\\r\\n\\r\\n resultIBL += lightDiffuse;\\r\\n resultIBL += lightSpecular;\\r\\n #endif // LIGHT_TYPE\\r\\n %% \\r\\n #endif\\r\\n\\r\\n\\r\\n\\r\\n// #ifdef EMISSIVE\\r\\n// vec3 emissiveChannel = sRGBToLinear( texture2D( emissiveMap, uv ) ).rgb;\\r\\n// resultIBL = resultIBL + emissiveChannel;\\r\\n// #endif\\r\\n //vec4 result = vec4( resultIBL, albedoSource.a );\\r\\n // vec3 frag = linearTosRGB(resultIBL );\\r\\n \\r\\n #if HAS_STICKER\\r\\n resultIBL = getStickColor(vec4(resultIBL, alpha)).rgb;\\r\\n #endif \\r\\n resultIBL *= alpha;\\r\\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(resultIBL, uRGBMRange) : vec4(resultIBL, alpha);\\r\\n}\\r\\n\";","export default \"#ifdef GL_ES\\r\\nprecision highp float;\\r\\n#endif\\r\\nattribute vec3 Vertex;\\r\\nattribute vec3 Normal;\\r\\nattribute vec2 TexCoord0;\\r\\nattribute vec4 Tangent;\\r\\nattribute vec4 Color;\\r\\nuniform float uDisplay2D;\\r\\nuniform mat4 uModelViewMatrix;\\r\\nuniform mat4 uProjectionMatrix;\\r\\nuniform mat4 uModelMatrix;\\r\\nuniform mat3 uModelViewNormalMatrix;\\r\\nuniform mat3 uModelNormalMatrix;\\r\\nuniform mat4 uViewMatrix;\\r\\nuniform vec2 uGlobalTexRatio;\\r\\nuniform vec2 uGlobalTexSize;\\r\\nuniform vec4 uHalton;\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec3 vWorldNormal;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec4 vVertexColor;\\r\\nvarying vec3 vNormalObject;\\r\\nvarying vec3 vAutoUVCoord;\\r\\n\\r\\n#if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\\r\\n varying vec3 vModelVertex;\\r\\n#endif\\r\\n\\r\\n#if defined(HAS_DISPLACEMENT)\\r\\n uniform float uDisplacementAmount;\\r\\n uniform sampler2D displacementMap;\\r\\n#endif\\r\\n\\r\\nvec2 uv;\\r\\n\\r\\n#ifdef UV_TRANSFORM\\r\\nuniform vec4 uUVTransform;\\r\\n#endif\\r\\n\\r\\nvec2 transformUV(vec2 uv) { \\r\\n\\r\\n #ifdef UV_TRANSFORM \\r\\n vec3 transformeduv = mat3(\\r\\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\\r\\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\\r\\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\\r\\n\\r\\n return transformeduv.xy;\\r\\n #else\\r\\n return uv;\\r\\n #endif\\r\\n\\r\\n}\\r\\n\\r\\n#ifdef TRIPLANAR_PROJECTION\\r\\n#pragma include \\\"triplanar_projection.glsl\\\"\\r\\n#endif\\r\\n\\r\\n\\r\\n// #define TRIPLANAR_PROJECTION\\r\\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\\r\\n\\r\\n vec4 color;\\r\\n\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n vec3 coord = vAutoUVCoord * 0.01;\\r\\n vec2 yz = transformUV(coord.yz);\\r\\n vec2 xz = transformUV(coord.xz);\\r\\n vec2 yx = transformUV(coord.yx);\\r\\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\\r\\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\\r\\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\\r\\n color = triplanlar_projection(yz, xz, yx, texture);\\r\\n #else\\r\\n color = texture2D(texture, uv);\\r\\n #endif\\r\\n return color;\\r\\n}\\r\\n\\r\\n\\r\\n#if defined(HAS_MODEL_NORMAL)\\r\\n varying vec3 vModelNormal;\\r\\n#endif\\r\\n\\r\\n\\r\\nuniform mat4 uInverseScopeModelMatrix;\\r\\n\\r\\n\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n vec3 localVertex = Vertex.xyz;\\r\\n\\r\\n #if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\\r\\n vModelVertex = (uModelMatrix * vec4(localVertex, 1.0)).xyz;\\r\\n #endif\\r\\n\\r\\n vec3 localNormal = Normal;\\r\\n #if defined(HAS_MODEL_NORMAL)\\r\\n vModelNormal = uModelNormalMatrix * localNormal;\\r\\n #endif \\r\\n\\r\\n vViewNormal = uModelViewNormalMatrix * localNormal;\\r\\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\\r\\n\\r\\n vTexCoord0 = TexCoord0;\\r\\n uv = vTexCoord0.xy; \\r\\n uv = transformUV(uv);\\r\\n \\r\\n vVertexColor = Color;\\r\\n \\r\\n //vWorldNormal = (uModelMatrix * vec4(Normal, 0.)).rgb;\\r\\n vWorldNormal = mat3(uInverseScopeModelMatrix) * uModelNormalMatrix * Normal; \\r\\n vAutoUVCoord = vec3(uInverseScopeModelMatrix * uModelMatrix * vec4(localVertex, 1.0));\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\\r\\n #endif\\r\\n mat4 jitteredProjection = uProjectionMatrix;\\r\\n #if defined(SHADOW_CAST)\\r\\n float doPersp = jitteredProjection[3][3] == 0.0 ? 1.0 : 0.0;\\r\\n vec2 jitter = (abs(uHalton.z) == 2.0 ? 1.0 : 0.0) * (uHalton.xy / uShadowMapSize.xy);\\r\\n jitteredProjection[2].xy += doPersp * jitter;\\r\\n jitteredProjection[3].xy += (1.0 - doPersp) * jitter;\\r\\n #elif !defined(NO_JITTER)\\r\\n jitteredProjection[2].xy += (1.0 - uDisplay2D) * (uHalton.xy * uGlobalTexRatio.xy / uGlobalTexSize.xy);\\r\\n #endif\\r\\n\\r\\n\\r\\n #if defined(HAS_DISPLACEMENT)\\r\\n float displacement = (fetchTexture(displacementMap, uv).g - 0.5) * uDisplacementAmount * (1.0 - uDisplay2D);\\r\\n // float displacement = (COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT).PACK_DISPLACEMENT) - 0.5) * uDisplacementAmount * (1.0 - uDisplay2D);\\r\\n vModelVertex += normalize(vModelNormal) * displacement;\\r\\n vViewVertex = vec3(uViewMatrix * vec4(vModelVertex, 1.0));\\r\\n #else\\r\\n vViewVertex = vec3(uModelViewMatrix * vec4(localVertex, 1.0));\\r\\n #endif\\r\\n\\r\\n gl_Position = jitteredProjection * vec4(vViewVertex, 1.0);\\r\\n}\\r\\n\";","export default \"#ifdef DEBUG\\r\\n#define PI 3.1415926535897932384626433832795\\r\\n\\r\\nvec3 shCoefs[9];\\r\\n\\r\\nvoid createCoef() {\\r\\n\\r\\n // vec3( 1.0/(2.0*sqrt(PI) ) ),\\r\\n\\r\\n // vec3( -( sqrt(3.0/PI)*0.5 * y ) ),\\r\\n // vec3( ( sqrt(3.0/PI)*0.5 * z ) ),\\r\\n // vec3( -( sqrt(3.0/PI)*0.5 * x ) ),\\r\\n\\r\\n // vec3( ( sqrt(15.0/PI)*0.5 * x * y ) ),\\r\\n // vec3( -( sqrt(15.0/PI)*0.5 * y * z ) ),\\r\\n // vec3( ( sqrt(5.0/PI)* 0.25 * ( 3.0*z*z - 1.0) ) ),\\r\\n // vec3( -( sqrt(15.0/PI)* 0.5 * x *z ) ),\\r\\n // vec3( ( sqrt(15.0/PI) * 0.25 * (x*x - y*y )) ),\\r\\n\\r\\n shCoefs[0] = vec3( 1.0/(2.0*sqrt(PI) ) );\\r\\n\\r\\n shCoefs[1] = vec3( -( sqrt(3.0/PI)*0.5 ) );\\r\\n shCoefs[2] = -shCoefs[1];\\r\\n shCoefs[3] = shCoefs[1];\\r\\n\\r\\n shCoefs[4] = vec3( sqrt(15.0/PI)*0.5 );\\r\\n shCoefs[5] = -shCoefs[4];\\r\\n shCoefs[6] = vec3( sqrt(5.0/PI)* 0.25 );\\r\\n shCoefs[7] = shCoefs[5];\\r\\n shCoefs[8] = vec3( sqrt(15.0/PI) * 0.25 );\\r\\n\\r\\n}\\r\\n\\r\\nvec3 sphericalHarmonics( const in vec3 normal )\\r\\n{\\r\\n float x = normal.x;\\r\\n float y = normal.y;\\r\\n float z = normal.z;\\r\\n\\r\\n createCoef();\\r\\n vec3 result = (\\r\\n shCoefs[0] * uSph[0] +\\r\\n\\r\\n shCoefs[1] * uSph[1] * y +\\r\\n shCoefs[2] * uSph[2] * z +\\r\\n shCoefs[3] * uSph[3] * x +\\r\\n\\r\\n shCoefs[4] * uSph[4] * y * x +\\r\\n shCoefs[5] * uSph[5] * y * z +\\r\\n shCoefs[6] * uSph[6] * (3.0 * z * z - 1.0) +\\r\\n shCoefs[7] * uSph[7] * (z * x) +\\r\\n shCoefs[8] * uSph[8] * (x*x - y*y)\\r\\n );\\r\\n}\\r\\n\\r\\n#else\\r\\n// expect shCoefs uniform\\r\\n// https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\\r\\nvec3 sphericalHarmonics( const vec3 sph[9], const in vec3 normal )\\r\\n{\\r\\n float x = normal.x;\\r\\n float y = normal.y;\\r\\n float z = normal.z;\\r\\n\\r\\n vec3 result = (\\r\\n sph[0] +\\r\\n\\r\\n sph[1] * y +\\r\\n sph[2] * z +\\r\\n sph[3] * x +\\r\\n\\r\\n sph[4] * y * x +\\r\\n sph[5] * y * z +\\r\\n sph[6] * (3.0 * z * z - 1.0) +\\r\\n sph[7] * (z * x) +\\r\\n sph[8] * (x*x - y*y)\\r\\n );\\r\\n\\r\\n return max(result, vec3(0.0));\\r\\n}\\r\\n\\r\\n#endif\\r\\n\";","export default \"\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec3 vLocalVertex;\\r\\n\\r\\nuniform vec3 uDiffuseSPH[9];\\r\\nuniform mat3 uEnvironmentTransform;\\r\\n\\r\\n\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n#pragma include \\\"sphericalHarmonics.glsl\\\"\\r\\n\\r\\n\\r\\nvoid main() {\\r\\n\\r\\n vec3 n = normalize( vViewNormal );\\r\\n n = uEnvironmentTransform * n;\\r\\n vec3 color = sphericalHarmonics( uDiffuseSPH, n );\\r\\n gl_FragColor = vec4( linearTosRGB(color), 1.0);\\r\\n\\r\\n}\\r\\n\";","export default \"attribute vec3 Vertex;\\r\\nattribute vec3 Normal;\\r\\nattribute vec2 TexCoord0;\\r\\nattribute vec4 Tangent;\\r\\n\\r\\nuniform mat4 uModelViewMatrix;\\r\\nuniform mat4 uProjectionMatrix;\\r\\nuniform mat3 uModelViewNormalMatrix;\\r\\n\\r\\n\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec3 vLocalVertex;\\r\\n\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0));\\r\\n vViewNormal = uModelViewNormalMatrix * Normal;\\r\\n vLocalVertex = Vertex;\\r\\n\\r\\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\\r\\n vTexCoord0 = TexCoord0;\\r\\n\\r\\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);\\r\\n}\\r\\n\";","export default \"\\r\\nvec3 gTriWeight;\\r\\n\\r\\nuniform float uTriplanarBlendWeight;\\r\\n\\r\\nvec3 calculateTriplanlartriweight(vec3 triNormal) { \\r\\n\\r\\n float blendIntensity = uTriplanarBlendWeight;\\r\\n vec3 triweight = vec3(0.0, 0.0, 0.0);\\r\\n\\r\\n triNormal = vec3(abs(triNormal.x), abs(triNormal.y), abs(triNormal.z));\\r\\n triNormal /= (triNormal.x + triNormal.y + triNormal.z);\\r\\n float blendLimit = 0.5 * (1.0 + blendIntensity);\\r\\n\\r\\n if (triNormal.x > blendLimit * (triNormal.x + triNormal.y) && triNormal.x > blendLimit * (triNormal.x + triNormal.z)) {\\r\\n triweight.x = 1.0;\\r\\n }\\r\\n else if (triNormal.y > blendLimit * (triNormal.x + triNormal.y) && triNormal.y > blendLimit * (triNormal.y + triNormal.z)) {\\r\\n triweight.y = 1.0;\\r\\n }\\r\\n else if (triNormal.z > blendLimit * (triNormal.x + triNormal.z) && triNormal.z > blendLimit * (triNormal.y + triNormal.z)) {\\r\\n triweight.z = 1.0;\\r\\n }\\r\\n else if (blendIntensity > 0.0) {\\r\\n if (triNormal.z < (1.0 - blendLimit) * (triNormal.y + triNormal.x)) {\\r\\n triweight.x = triNormal.x / (triNormal.x + triNormal.y);\\r\\n triweight.x = clamp((triweight.x - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\\r\\n triweight.y = 1.0 - triweight.x;\\r\\n } else if (triNormal.x < (1.0 - blendLimit) * (triNormal.y + triNormal.z)) {\\r\\n triweight.y = triNormal.y / (triNormal.y + triNormal.z);\\r\\n triweight.y = clamp((triweight.y - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\\r\\n triweight.z = 1.0 - triweight.y;\\r\\n }\\r\\n else if (triNormal.y < (1.0 - blendLimit) * (triNormal.x + triNormal.z)) {\\r\\n triweight.x = triNormal.x / (triNormal.x + triNormal.z);\\r\\n triweight.x = clamp((triweight.x - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\\r\\n triweight.z = 1.0 - triweight.x;\\r\\n }\\r\\n else {\\r\\n triweight.x = ((2.0 - blendLimit) * triNormal.x + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\\r\\n triweight.y = ((2.0 - blendLimit) * triNormal.y + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\\r\\n triweight.z = ((2.0 - blendLimit) * triNormal.z + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\\r\\n }\\r\\n } else {\\r\\n triweight.x = 1.0;\\r\\n }\\r\\n return triweight;\\r\\n}\\r\\n\\r\\n\\r\\nvec4 triplanlar_projection(vec2 x, vec2 y, vec2 z, sampler2D texture)\\r\\n{\\r\\n vec3 triweight = gTriWeight;\\r\\n\\r\\n vec4 color = vec4(0);\\r\\n\\r\\n if (triweight.x > 0.0) {\\r\\n color += triweight.x * texture2D(texture, x); // yz\\r\\n }\\r\\n if (triweight.y > 0.0) {\\r\\n color += triweight.y * texture2D(texture, y); // xy\\r\\n }\\r\\n if (triweight.z > 0.0) {\\r\\n color += triweight.z * texture2D(texture, z); // yx\\r\\n }\\r\\n return color;\\r\\n}\\r\\n\";","export default \"\\r\\nuniform int uDrawOpaque;\\r\\nuniform float uOpacityFactor;\\r\\nuniform vec2 uNearFar;\\r\\nuniform vec4 uShadowDepthRange;\\r\\nvarying vec3 vViewVertex;\\r\\nvarying vec3 vViewNormal;\\r\\nvarying vec2 vTexCoord0;\\r\\nvarying vec4 vViewTangent;\\r\\nvarying vec4 vVertexColor;\\r\\nvarying vec3 vAutoUVCoord;\\r\\nvarying vec3 vWorldNormal;\\r\\n\\r\\n\\r\\nvec2 uv;\\r\\n\\r\\n#ifdef UV_TRANSFORM\\r\\nuniform vec4 uUVTransform;\\r\\n#endif\\r\\n\\r\\nvec2 transformUV(vec2 uv) { \\r\\n\\r\\n #ifdef UV_TRANSFORM \\r\\n vec3 transformeduv = mat3(\\r\\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\\r\\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\\r\\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\\r\\n\\r\\n return transformeduv.xy;\\r\\n #else\\r\\n return uv;\\r\\n #endif\\r\\n\\r\\n}\\r\\n\\r\\nuniform sampler2D opacityMap;\\r\\n\\r\\n#pragma include \\\"utils/functions.glsl\\\"\\r\\n\\r\\n\\r\\n#ifdef TRIPLANAR_PROJECTION\\r\\n#pragma include \\\"triplanar_projection.glsl\\\"\\r\\n#endif\\r\\n\\r\\nvec4 encodeFloatRGBA( float v ) {\\r\\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\\r\\n enc = fract(enc);\\r\\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\\r\\n return enc;\\r\\n}\\r\\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\\r\\n\\r\\n vec4 color;\\r\\n\\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n vec3 coord = vAutoUVCoord * 0.01;\\r\\n color = triplanlar_projection(transformUV(coord.zy), transformUV(coord.xz), transformUV(coord.xy), texture);\\r\\n #else\\r\\n color = texture2D(texture, uv);\\r\\n #endif\\r\\n\\r\\n return color;\\r\\n\\r\\n}\\r\\n\\r\\n\\r\\n\\r\\nfloat getMaterialOpacity() {\\r\\n float alpha = 1.0;\\r\\n#ifdef HAS_OPACITYMAP\\r\\n alpha = fetchTexture(opacityMap, uv).r;\\r\\n#endif\\r\\n alpha *= uOpacityFactor;\\r\\n#ifdef INVERT_ALPHA\\r\\n alpha = 1.0 - alpha;\\r\\n#endif\\r\\n return alpha;\\r\\n}\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n uv = vTexCoord0;\\r\\n \\r\\n #ifdef UV_TRANSFORM\\r\\n uv = transformUV(uv);\\r\\n #endif\\r\\n\\r\\n \\r\\n #ifdef TRIPLANAR_PROJECTION\\r\\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\\r\\n #endif\\r\\n\\r\\n if (getMaterialOpacity() < 9.9999e-1) discard;\\r\\n gl_FragColor = encodeFloatRGBA((-vViewVertex.z - uShadowDepthRange.x) / (uShadowDepthRange.y - uShadowDepthRange.x));\\r\\n}\\r\\n\";","export default \"#ifdef STICKER_NUM\\r\\n\\r\\n#extension GL_OES_standard_derivatives:enable\\r\\n\\r\\nuniform float uHighlight[STICKER_NUM];\\r\\nuniform mat3 uMat[STICKER_NUM];\\r\\nuniform mat4 uT[STICKER_NUM];\\r\\nuniform vec4 uBoundSphere[STICKER_NUM];\\r\\nuniform sampler2D uStickerMap[STICKER_NUM];\\r\\nuniform vec3 uPos[STICKER_NUM];\\r\\nuniform vec3 uNormal[STICKER_NUM];\\r\\nuniform float uVisible[STICKER_NUM];\\r\\n\\r\\nuniform float uAnchors[8];\\r\\n\\r\\n\\r\\nvec2 sphericalMapping(vec3 n) {\\r\\n float phi = acos(n.z);\\r\\n float theta = atan(n.y,n.x);\\r\\n return vec2(theta, PI - phi);\\r\\n}\\r\\n\\r\\nfloat sign(vec2 p1,vec2 p2,vec2 p3) {\\r\\n return (p1.x-p3.x)*(p2.y-p3.y)-(p2.x-p3.x)*(p1.y-p3.y);\\r\\n}\\r\\n\\r\\nint pointInTriangle(vec2 pt,vec2 v1,vec2 v2,vec2 v3) {\\r\\n float d1,d2,d3;\\r\\n d1=sign(pt,v1,v2);\\r\\n d2=sign(pt,v2,v3);\\r\\n d3=sign(pt,v3,v1);\\r\\n \\r\\n int result=0;\\r\\n if(!(((d1<0.)||(d2<0.)||(d3<0.))&&((d1>0.)||(d2>0.)||(d3>0.)))){\\r\\n result=1;\\r\\n }\\r\\n return result;\\r\\n}\\r\\n\\r\\nfloat getSignedDist(vec2 uv) {\\r\\n vec2 d = abs(uv - vec2(0.5)) - vec2(0.5);\\r\\n return length(max(d, vec2(0.))) + min(max(d.x, d.y), 0.0);\\r\\n}\\r\\n\\r\\nfloat sdfArchers( vec2 p0, vec2 p1, vec2 p2, vec2 p3, float r )\\r\\n{\\r\\n return min(min(length(p0) - r, length(p1) - r), min(length(p2) - r, length(p3) - r));\\r\\n}\\r\\n\\r\\nvec4 getStickColor(vec4 backcolor){\\r\\n \\r\\n vec4 finalColor = backcolor;\\r\\n\\r\\n // ---- UNROLL ---- \\r\\n for (int id = 0; id < STICKER_NUM; id++) {\\r\\n if (uVisible[id] > 0.5) {\\r\\n vec3 n = (normalize(vAutoUVCoord - uBoundSphere[id].xyz));\\r\\n n = (uT[id] * vec4(n, 0.)).xyz;\\r\\n vec2 uv = (uMat[id] * vec3(sphericalMapping(n), 1.0)).xy;\\r\\n vec4 tex = texture2D(uStickerMap[id], uv);\\r\\n vec3 P = uPos[id];\\r\\n vec3 N = uNormal[id];\\r\\n //N = normalize(gl_FrontFacing ? N : -N);\\r\\n vec3 worldN = normalize(gl_FrontFacing ? vWorldNormal : -vWorldNormal);\\r\\n \\r\\n float d = length(P - vAutoUVCoord);\\r\\n if (dot(worldN, N) >= 0.) {\\r\\n\\r\\n tex.rgb = sRGBToLinear(tex.rgb);\\r\\n float highlight = uHighlight[id];\\r\\n float l = getSignedDist(uv);\\r\\n\\r\\n if (d <= uBoundSphere[id].w && l <= highlight * 0.02) {\\r\\n if (l <= 0.0) { \\r\\n finalColor.rgb = mix(finalColor.rgb, tex.rgb, tex.a);\\r\\n finalColor.a = clamp(finalColor.a * (1.0 - tex.a) + tex.a, 0., 1.); \\r\\n } else {\\r\\n finalColor = vec4(0.102, 0.5922, 0.8, 1.0); \\r\\n }\\r\\n }\\r\\n\\r\\n if (highlight > 0.0) {\\r\\n float archer = sdfArchers(\\r\\n uv - vec2(uAnchors[0], uAnchors[1]),\\r\\n uv - vec2(uAnchors[2], uAnchors[3]),\\r\\n uv - vec2(uAnchors[4], uAnchors[5]),\\r\\n uv - vec2(uAnchors[6], uAnchors[7]),\\r\\n 0.01); \\r\\n if (archer <= 0.02)\\r\\n finalColor = vec4(0.0, 0.0, 1.0, 1.0);\\r\\n }\\r\\n }\\r\\n } \\r\\n }\\r\\n // ---- UNROLL ---- \\r\\n\\r\\n return finalColor;\\r\\n \\r\\n}\\r\\n\\r\\n#endif\";","import { Events } from \"../../comm/events\";\r\nimport osg from '../../osg/osg';\r\nimport KdTreeBuilder from \"../../osg/KdTreeBuilder\";\r\nimport MaterialUtils from \"../material/MaterialUtils\";\r\n\r\n\r\n\r\nclass Scene extends Events {\r\n constructor() {\r\n super();\r\n\r\n this._root = null;\r\n\r\n this.nodeGrid = null;\r\n this.nodeGizmo = null;\r\n this.nodeRuler = null;\r\n\r\n this.shoes = []; //{isLeft, shoe, id};\r\n\r\n this.mainShoe = null;\r\n\r\n this.initRoot();\r\n }\r\n\r\n initRoot() {\r\n this._root = new osg.MatrixTransform();\r\n this._root.setMatrix(osg.mat4.fromValues(\r\n 1, 0, 0, 0,\r\n 0, 1, 0, 0,\r\n 0, 0, 1, 0,\r\n 0, 0, 0, 1\r\n ))\r\n let stateSet = this._root.getOrCreateStateSet();\r\n this._uInverseMat = osg.Uniform.createMatrix4('uInverseScopeModelMatrix')\r\n\r\n stateSet.addUniform(this._uInverseMat)\r\n stateSet.setShaderGeneratorName('PBR');\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.AO_TEXTURE_UNIT, 'aoMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.ALBEDO_TEXTURE_UNIT, 'albedoMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.METALLIC_TEXTURE_UNIT, 'metallicMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.ROUGHNESS_TEXTURE_UNIT, 'roughnessMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.NORMAL_TEXTURE_UNIT, 'normalMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.OPACITY_TEXTURE_UNIT, 'opacityMap'),\r\n );\r\n stateSet.addUniform(\r\n osg.Uniform.createInt(MaterialUtils.DISPLACEMENT_TEXTURE_UNIT, 'displacementMap'),\r\n );\r\n const stickerUnit = MaterialUtils.STICKER_TEXTURE_UNIT\r\n stateSet.addUniform(\r\n //osg.Uniform.createInt(MaterialUtils.STICKER_TEXTURE_UNIT, 'uStickerMap'),\r\n \r\n osg.Uniform.createIntArray([stickerUnit, stickerUnit+1, stickerUnit+2, stickerUnit+3], 'uStickerMap')\r\n );\r\n\r\n }\r\n\r\n //显示网格\r\n showGrid(show) {\r\n\r\n }\r\n\r\n //gizmo\r\n gizmoAttach(node) {}\r\n\r\n showGizmo(show) {}\r\n\r\n //显示标尺\r\n showRuler(show) {\r\n\r\n }\r\n\r\n isShoeInScene(shoe, isLeft) {\r\n let shoes = this.shoes;\r\n let n = shoes.length;\r\n while (n--) {\r\n if (shoes[n].shoe == shoe && shoes[n].isLeft == isLeft) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n //添加鞋子\r\n addChildShoe(shoe, isLeft = true) {\r\n\r\n let id = Date.now();\r\n this.shoes.push({ id, shoe, isLeft });\r\n let node = isLeft ? shoe.nodeLeft : shoe.nodeRight;\r\n let udata = node.getUserData() || {};\r\n udata[\"shoeId\"] = id;\r\n node.setUserData(udata);\r\n\r\n this.addChild(node);\r\n\r\n return node;\r\n }\r\n\r\n //移除鞋子\r\n removeChildShoe(shoe, isLeft = true) {\r\n let node = isLeft ? shoe.nodeLeft : shoe.nodeRight;\r\n let n = this.shoes.length;\r\n while (n--) {\r\n if (this.shoes[n].shoe == shoe && this.shoes[n].isLeft == isLeft) {\r\n this.shoes.splice(n, 1);\r\n break;\r\n }\r\n }\r\n this.removeChild(node);\r\n }\r\n\r\n //根据node 判定当前是那只鞋子\r\n shoeTest(goemNode) {\r\n\r\n }\r\n\r\n //添加模型\r\n addChild(node) {\r\n let _root = this._root;\r\n _root.setNodeMask(0x0);\r\n _root.addChild(node);\r\n _root.setNodeMask(~0x0);\r\n _root.dirtyBound();\r\n\r\n this.emit(\"change\");\r\n }\r\n\r\n //移除模型\r\n removeChild(node) {\r\n let _root = this._root;\r\n _root.setNodeMask(0x0);\r\n _root.removeChild(node);\r\n _root.setNodeMask(~0x0);\r\n _root.dirtyBound();\r\n\r\n this.emit(\"change\");\r\n }\r\n\r\n //清空场景\r\n clean() {\r\n this._root.removeChildren();\r\n }\r\n\r\n updateKdTree() {\r\n let _rootModel = this._root;\r\n let treeBuilder = new KdTreeBuilder({\r\n _numVerticesProcessed: 0,\r\n _targetNumTrianglesPerLeaf: 50,\r\n _maxNumLevels: 20,\r\n });\r\n treeBuilder.apply(_rootModel);\r\n }\r\n}\r\n\r\nexport { Scene };","import NodeVisitor from \"../osg/NodeVisitor\";\r\nimport Geometry from \"../osg/Geometry\";\r\nimport osg from \"../osg/osg\";\r\nimport MatrixTransform from \"../osg/MatrixTransform\";\r\n\r\nclass ExplodeSetupVisitor extends NodeVisitor {\r\n constructor(explodeCenter) {\r\n super();\r\n this._explodeCenter = explodeCenter || [0, 0, 0];\r\n }\r\n\r\n setCenter(center) {\r\n this._explodeCenter = center;\r\n }\r\n\r\n apply(node) {\r\n if (node instanceof Geometry) {\r\n let parents = node.getParents();\r\n if (parents.length > 1) {\r\n console.warn(\"insert explode node has more than one parent\");\r\n }\r\n\r\n let explodeNode;\r\n if (\r\n parents[0] instanceof MatrixTransform &&\r\n parents[0].explode &&\r\n parents[0].getUserData().uniqueID === node._uniqueID\r\n ) {\r\n explodeNode = parents[0];\r\n } else {\r\n explodeNode = new MatrixTransform();\r\n explodeNode.explode = true;\r\n parents.forEach(parent=>{\r\n parent.addChild(explodeNode);\r\n parent.removeChild(node);\r\n })\r\n explodeNode.addChild(node);\r\n explodeNode.setUserData(\r\n Object.assign(explodeNode.getUserData() || {}, {\r\n uniqueID: node._uniqueID,\r\n })\r\n );\r\n }\r\n\r\n let worldMat = osg.mat4.create();\r\n let worldTraslation = osg.vec3.create();\r\n let offset = osg.vec3.create();\r\n let dir = osg.vec3.create();\r\n\r\n explodeNode.getWorldMatrix(undefined, worldMat);\r\n\r\n let sphere = explodeNode.getBoundingSphere() //local\r\n sphere.transformMat4(sphere, worldMat); //world \r\n let worldCenter = osg.vec3.clone(sphere.center());\r\n\r\n //computeCentroid\r\n // let worldCenter = osg.vec3.create()\r\n // let localCentroid = node.computeCentroid()\r\n // osg.vec3.transformMat4(worldCenter, localCentroid, worldMat)\r\n //\r\n\r\n osg.mat4.getTranslation(worldTraslation, worldMat);\r\n\r\n osg.vec3.sub(offset, worldCenter, worldTraslation);\r\n osg.vec3.sub(dir, worldCenter, this._explodeCenter);\r\n explodeNode.setUserData(\r\n Object.assign(explodeNode.getUserData() || {}, {\r\n offset,\r\n dir,\r\n explodeCenter: this._explodeCenter,\r\n })\r\n );\r\n }\r\n this.traverse(node);\r\n }\r\n}\r\n\r\nclass ExplodeVisitor extends NodeVisitor {\r\n constructor() {\r\n super();\r\n this._scale = 1;\r\n }\r\n\r\n setScale(scale) {\r\n this._scale = scale;\r\n }\r\n\r\n apply(node) {\r\n if (node.explode === true) {\r\n let userData = node.getUserData();\r\n let newCenter = osg.vec3.create();\r\n let newDir = osg.vec3.create();\r\n let newPos = osg.vec3.create();\r\n osg.vec3.scale(newDir, userData.dir, this._scale);\r\n osg.vec3.add(newCenter, userData.explodeCenter, newDir);\r\n osg.vec3.sub(newPos, newCenter, userData.offset);\r\n\r\n let parentWorldMat = osg.mat4.create();\r\n let parents = node.getParents()\r\n if (parents.length !== 1) {\r\n console.warn(\"explode error: explode node has more than one parent\");\r\n }\r\n let parent = parents[0]\r\n parent.getWorldMatrix(undefined, parentWorldMat);\r\n\r\n let targetWorldMat = osg.mat4.clone(parentWorldMat);\r\n osg.mat4.setTranslation(targetWorldMat, newPos);\r\n\r\n osg.mat4.invert(parentWorldMat, parentWorldMat);\r\n let newLocalMat = osg.mat4.create();\r\n osg.mat4.mul(newLocalMat, parentWorldMat, targetWorldMat);\r\n node.setMatrix(newLocalMat);\r\n }\r\n this.traverse(node);\r\n }\r\n}\r\n\r\nexport { ExplodeSetupVisitor, ExplodeVisitor };\r\n","import { Events } from '../comm/events';\r\nimport Config from './Config';\r\n\r\nimport osg from '../osg/osg';\r\nimport baseShaderChunks from './shaders/baseShaderChunks';\r\nimport postProcessShaderChunks from './shaders/postProcessShaderChunks';\r\nimport FeatureEventManager from './FeatureEventManager.js';\r\nimport FeatureManager from './FeatureManager.js';\r\nimport LightingFeature from './features/Lighting.js';\r\nimport PostProcessFeature from './features/PostProcess.js';\r\nimport EnvironmentFeature from './features/Environment';\r\nimport BackgroundFeature from './features/Background';\r\nimport ScreenShotFeature from './features/ScreenShot';\r\nimport StickerFeature from './features/StickerFeature'\r\nimport OutlineFeature from './features/Outline';\r\nimport FrameManager from './FrameManager.js';\r\nimport SuperSample from './SuperSample.js';\r\nimport SwitchManipulator from './SwitchManipulator.js';\r\nimport CullVisitor from './CullVisitor.js';\r\nimport registerShaderGenerator from './EditorShaderGenerator.js';\r\nimport osgViewer from \"../osgViewer/osgViewer\";\r\nimport NextShaderProcessor from \"../osgShader/NextShaderProcessor\";\r\nimport CanvasPixelRatio from './CanvasPixelRatio'\r\nimport PickMask from './PickMask';\r\nimport ResourceManager from './ResourceManager';\r\n\r\nimport earlyZFrag from './shaders/earlyZFrag.glsl';\r\nimport cubemapFragment from './shaders/cubemapFragment.glsl';\r\nimport cubemapSampler from './shaders/cubemapSampler.glsl';\r\nimport cubemapVertex from './shaders/cubemapVertex.glsl';\r\nimport math from './shaders/math.glsl';\r\nimport changeColor from './shaders/changeColor.glsl';\r\nimport panoramaSampler from './shaders/panoramaSampler.glsl';\r\n// import panoramaVertex from './shaders/panoramaVertex.glsl';\r\nimport pbr_ue4 from './shaders/pbr_ue4.glsl';\r\nimport pbrFrag from './shaders/pbrFrag.glsl';\r\nimport baseVert from './shaders/baseVert.glsl';\r\nimport sphericalHarmonics from './shaders/sphericalHarmonics.glsl';\r\nimport sphericalHarmonicsFragment from './shaders/sphericalHarmonicsFragment.glsl';\r\nimport sphericalHarmonicsVertex from './shaders/sphericalHarmonicsVertex.glsl';\r\nimport triplanar_projection from './shaders/triplanar_projection.glsl';\r\nimport shadowCastFrag from './shaders/shadowCastFrag.glsl';\r\nimport stickerglsl from './shaders/sticker.glsl';\r\nimport { Model } from 'backbone';\r\nimport { Scene } from \"./objects/Scene\";\r\nimport ShaderMaker from './ShaderMaker'\r\nimport CreatePromise from './CreatePromise'\r\nimport PresetLights from './PresetLights'\r\nimport NodeVisitor from \"../osg/NodeVisitor\";\r\nimport osgUtil from '../osgUtil/osgUtil';\r\nimport { ExplodeSetupVisitor,ExplodeVisitor } from './Explode';\r\nimport MaterialUtils from './material/MaterialUtils';\r\n\r\nvar shaderChunks = Object.assign({\r\n 'earlyZFrag.glsl': earlyZFrag,\r\n 'cubemapFragment.glsl': cubemapFragment,\r\n 'cubemapSampler.glsl': cubemapSampler,\r\n 'cubemapVertex.glsl': cubemapVertex,\r\n 'math.glsl': math,\r\n 'changeColor.glsl': changeColor,\r\n 'panoramaSampler.glsl': panoramaSampler,\r\n // 'panoramaVertex.glsl': panoramaVertex,\r\n 'pbr_ue4.glsl': pbr_ue4,\r\n 'pbrFrag.glsl': pbrFrag,\r\n 'baseVert.glsl': baseVert,\r\n 'sphericalHarmonics.glsl': sphericalHarmonics,\r\n 'sphericalHarmonicsFragment.glsl': sphericalHarmonicsFragment,\r\n 'sphericalHarmonicsVertex.glsl': sphericalHarmonicsVertex,\r\n 'triplanar_projection.glsl': triplanar_projection,\r\n 'shadowCastFrag.glsl': shadowCastFrag,\r\n 'sticker.glsl':stickerglsl\r\n },\r\n baseShaderChunks,\r\n postProcessShaderChunks,\r\n);\r\n\r\nclass ReleaseVisitor extends NodeVisitor {\r\n constructor(traversalMode){\r\n super(traversalMode)\r\n }\r\n\r\n apply(node) {\r\n node.releaseGLObjects();\r\n this.traverse(node);\r\n }\r\n}\r\n\r\nclass Application extends Events {\r\n constructor(canvas, options) {\r\n super();\r\n this._releaseVisitor = new ReleaseVisitor()\r\n this._explodeSetup = new ExplodeSetupVisitor()\r\n this._explode = new ExplodeVisitor()\r\n this._explodeRoot = undefined\r\n this._canvasPixelRatio = new CanvasPixelRatio()\r\n this.backgroundUniform = {\r\n ambient: osg.Uniform.createInt1(0, 'uAmbient'),\r\n texture0: osg.Uniform.createInt1(0, 'uTexture0'),\r\n backgroundExposure: osg.Uniform.createFloat(1, 'uBackgroundExposure'),\r\n size: osg.Uniform.createFloat(1, 'uSize'),\r\n color: osg.Uniform.createFloat3(osg.vec3.fromValues(0, 0, 1), 'uBackgroundColor'),\r\n scale: osg.Uniform.createFloat2(osg.vec2.fromValues(1, 1), 'uFixedScale'),\r\n };\r\n this._finishPromise = CreatePromise()\r\n this.envUniform = {\r\n environmentTransform: osg.Uniform.createMatrix3('uEnvironmentTransform'),\r\n exposure: osg.Uniform.createFloat1(1, 'uEnvironmentExposure'),\r\n diffuseSPH: osg.Uniform.createFloat3Array(new Float32Array(27), 'uDiffuseSPH'),\r\n textureSpecularPBR: osg.Uniform.createInt1('sSpecularPBR'),\r\n textureIntegrateBRDF: osg.Uniform.createInt1('sIntegrateBRDF'),\r\n factorShadowEnv0: osg.Uniform.createFloat(0, 'uFactorShadowEnv0'),\r\n };\r\n\r\n this.postProcessUniform = {\r\n uProjFactor: osg.Uniform.createFloat('uProjFactor'),\r\n uSsaoRadius: osg.Uniform.createFloat('uSsaoRadius'),\r\n uSsaoIntensity: osg.Uniform.createFloat('uSsaoIntensity'),\r\n uSsaoBias: osg.Uniform.createFloat('uSsaoBias'),\r\n uSsaoProjectionInfo: osg.Uniform.createFloat4('uSsaoProjectionInfo'),\r\n uSsaoProjectionScale: osg.Uniform.createFloat(1, 'uSsaoProjectionScale'),\r\n uDofBlurNearFarFocal: osg.Uniform.createFloat3('uDofBlurNearFarFocal'),\r\n uDofCross: osg.Uniform.createFloat3(osg.vec3.create(), 'uDofCross'),\r\n uDofScale: osg.Uniform.createFloat(1, 'uDofScale'),\r\n uBloomFactor: osg.Uniform.createFloat('uBloomFactor'),\r\n uBloomThreshold: osg.Uniform.createFloat('uBloomThreshold'),\r\n uBloomRadius: osg.Uniform.createFloat('uBloomRadius'),\r\n uChromaFactor: osg.Uniform.createFloat('uChromaFactor'),\r\n uColorBalanceLow: osg.Uniform.createFloat3('uColorBalanceLow'),\r\n uColorBalanceMid: osg.Uniform.createFloat3('uColorBalanceMid'),\r\n uColorBalanceHigh: osg.Uniform.createFloat3('uColorBalanceHigh'),\r\n uToneExposure: osg.Uniform.createFloat('uToneExposure'),\r\n uToneBrightness: osg.Uniform.createFloat('uToneBrightness'),\r\n uToneContrast: osg.Uniform.createFloat('uToneContrast'),\r\n uToneSaturation: osg.Uniform.createFloat('uToneSaturation'),\r\n uToneMethod: osg.Uniform.createInt('uToneMethod'),\r\n uDistortion: osg.Uniform.createFloat2('uDistortion'),\r\n uProjectionLeft: osg.Uniform.createFloat4('uProjectionLeft'),\r\n uUnprojectionLeft: osg.Uniform.createFloat4('uUnprojectionLeft'),\r\n uSharpFactor: osg.Uniform.createFloat('uSharpFactor'),\r\n uLensRadius: osg.Uniform.createFloat2('uLensRadius'),\r\n uTimeGrain: osg.Uniform.createFloat('uTimeGrain'),\r\n uGrainFactor: osg.Uniform.createFloat('uGrainFactor'),\r\n uTaaInvViewMatrixLeft: osg.Uniform.createMatrix4('uTaaInvViewMatrixLeft'),\r\n uTaaCurrentFramePVLeft: osg.Uniform.createMatrix4('uTaaCurrentFramePVLeft'),\r\n uTaaLastFramePVLeft: osg.Uniform.createMatrix4('uTaaLastFramePVLeft'),\r\n uTaaCornersCSLeft: osg.Uniform.createFloat4Array('uTaaCornersCSLeft', 2),\r\n uTaaEnabled: osg.Uniform.createFloat(1, 'uTaaEnabled'),\r\n uTaaInvViewMatrixRight: osg.Uniform.createMatrix4('uTaaInvViewMatrixRight'),\r\n uTaaCurrentFramePVRight: osg.Uniform.createMatrix4('uTaaCurrentFramePVRight'),\r\n uTaaLastFramePVRight: osg.Uniform.createMatrix4('uTaaLastFramePVRight'),\r\n uTaaCornersCSRight: osg.Uniform.createFloat4Array('uTaaCornersCSRight', 2),\r\n uVrFadeFactor: osg.Uniform.createFloat(0, 'uVrFadeFactor'),\r\n uVrVeilFactor: osg.Uniform.createFloat(1, 'uVrVeilFactor'),\r\n };\r\n\r\n this.globalUniform = {\r\n uInverseScopeModelMatrix: osg.Uniform.createMatrix4('uInverseScopeModelMatrix'),\r\n uDrawOpaque: osg.Uniform.createInt(-1, 'uDrawOpaque'),\r\n uEarlyZ: osg.Uniform.createInt(0, 'uEarlyZ'),\r\n uQVT: osg.Uniform.createFloat3('uQVT'),\r\n uQVS: osg.Uniform.createFloat3('uQVS'),\r\n uQW: osg.Uniform.createFloat2('uQW'),\r\n uQUV0: osg.Uniform.createFloat4('uQUV0'),\r\n uNearFar: osg.Uniform.createFloat2('uNearFar'),\r\n uBoxRadius: osg.Uniform.createFloat('uBoxRadius'),\r\n uOutputLinear: osg.Uniform.createInt(1, 'uOutputLinear'),\r\n uRGBMRange: osg.Uniform.createFloat('uRGBMRange'),\r\n uGlobalTexSize: osg.Uniform.createFloat2('uGlobalTexSize'),\r\n uGlobalTexRatio: osg.Uniform.createFloat2('uGlobalTexRatio'),\r\n uPixelRatio: osg.Uniform.createFloat2('uPixelRatio'),\r\n uPreviousGlobalTexSize: osg.Uniform.createFloat2('uPreviousGlobalTexSize'),\r\n uPreviousGlobalTexRatio: osg.Uniform.createFloat2('uPreviousGlobalTexRatio'),\r\n uPreviousHalton: osg.Uniform.createFloat4('uPreviousHalton'),\r\n uReprojectViewProj: osg.Uniform.createMatrix4('uReprojectViewProj'),\r\n uTaaCornersCSLeft: this.postProcessUniform.uTaaCornersCSLeft,\r\n uPreviousProjection: osg.Uniform.createMatrix4('uPreviousProjection'),\r\n uPreviousViewInvView: osg.Uniform.createMatrix4('uPreviousViewInvView'),\r\n uTextureToBeRefractedSize: osg.Uniform.createFloat2('uTextureToBeRefractedSize'),\r\n uHoverUV: osg.Uniform.createFloat2(osg.vec2.fromValues(1e6, 1e6), 'uHoverUV'),\r\n uDisplay2D: osg.Uniform.createFloat(0, 'uDisplay2D'),\r\n uSplitView: osg.Uniform.createFloat(0, 'uSplitView'),\r\n uInspectorView: osg.Uniform.createInt(0, 'uInspectorView'),\r\n uTimeViewer: osg.Uniform.createFloat('uTimeViewer'),\r\n uHalton: osg.Uniform.createFloat4('uHalton'),\r\n uSSAARestart: osg.Uniform.createFloat(0, 'uSSAARestart'),\r\n uScatteringFactorPacker: osg.Uniform.createFloat('uScatteringFactorPacker'),\r\n uNormalizeFactorThickness: osg.Uniform.createFloat('uNormalizeFactorThickness'),\r\n uStaticFrameNumShadow0: osg.Uniform.createFloat('uStaticFrameNumShadow0'),\r\n uStaticFrameNumShadow1: osg.Uniform.createFloat('uStaticFrameNumShadow1'),\r\n uStaticFrameNumShadow2: osg.Uniform.createFloat('uStaticFrameNumShadow2'),\r\n uStaticFrameNumShadow3: osg.Uniform.createFloat('uStaticFrameNumShadow3'),\r\n uShadowMapSize: osg.Uniform.createFloat2('uShadowMapSize'),\r\n uIsVr: osg.Uniform.createInt('uIsVr'),\r\n uFrameMod: osg.Uniform.createFloat(0, 'uFrameMod'),\r\n uFrameModTaaSS: osg.Uniform.createFloat(0, 'uFrameModTaaSS'),\r\n uSsrFactor: osg.Uniform.createFloat(1, 'uSsrFactor'),\r\n uQuality: osg.Uniform.createFloat(0, 'uQuality'),\r\n };\r\n\r\n this.clearOpaqueRGBA = osg.vec4.fromValues(0, 0, 0, 0);\r\n this.cameraMain = void 0;\r\n this.cameraEnvironment = void 0;\r\n this.nodePostProcessOut = void 0;\r\n this.nodeRootModel = void 0;\r\n\r\n this._canvas = canvas;\r\n this._shaderProcessor = NextShaderProcessor;\r\n this.readShaders();\r\n this._viewer = new osgViewer.Viewer(this._canvas, {\r\n powerPreference: 'high-performance',\r\n antialias: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: true,\r\n fullscreen: false,\r\n preserveDrawingBuffer: false,\r\n enableFrustumCulling: false,\r\n maxDevicePixelRatio: Config.maxDevicePixelRatio || 1.5,\r\n InputSources: {\r\n Mouse: {\r\n scrollwheel: true,\r\n },\r\n WebVR: {\r\n pollInterval: -1,\r\n },\r\n GamePad: {\r\n enable: false,\r\n },\r\n },\r\n // stats: true,\r\n // statsFilter: 'texture;browser;',\r\n });\r\n\r\n this._rootScene = new osg.MatrixTransform();\r\n\r\n this._rootScene.setName('root');\r\n\r\n this._features = {};\r\n this._featuresManager = null;\r\n this._eventEmiiter = new Model();\r\n\r\n this._viewer.init();\r\n this._viewer.getCamera().setClearColor([0.0, 0.0, 0.0, 0.0]);\r\n this._viewer.requestContinuousUpdate(false);\r\n\r\n registerShaderGenerator(this._viewer.getState().getShaderGeneratorProxy());\r\n\r\n const camera = this.getCamera();\r\n camera.getRenderer().setCullVisitor(new CullVisitor(this));\r\n var self = this;\r\n this._switchManipulator = new SwitchManipulator(\r\n this._viewer.getInputManager(),\r\n (param) => {\r\n if (param) {\r\n if (param === 'noJitter')\r\n this._frameManager.drawNoJitter();\r\n else\r\n this._frameManager.draw();\r\n }\r\n }\r\n )\r\n this._viewer.setupManipulator(this._switchManipulator);\r\n\r\n this._featureEventManager = new FeatureEventManager()\r\n this._featureEventManager.init(this._viewer.getInputManager());\r\n\r\n\r\n this._superSample = new SuperSample(this);\r\n this._frameManager = new FrameManager()\r\n this._frameManager.setViewer(this._viewer);\r\n this._frameManager.setSuperSample(this._superSample);\r\n this._superSample.setRoot(this._rootScene);\r\n this._viewer.setSceneData(this._rootScene);\r\n this._viewer.getManipulator().computeHomePosition();\r\n\r\n this.createScene();\r\n this._features.lighting = new LightingFeature(this);\r\n this._features.environment = new EnvironmentFeature(this);\r\n this._features.background = new BackgroundFeature(this);\r\n this._features.postProcess = new PostProcessFeature(this);\r\n this._features.outline = new OutlineFeature(this);\r\n this._features.screenShot = new ScreenShotFeature(this)\r\n this._features.sticker = new StickerFeature(this)\r\n // this._features.inspector = null;\r\n // this._upz = osg.vec3.fromValues(0.0, 0.0, 1.0);\r\n // this._tempMat = osg.mat4.create()\r\n // this._viewer.setupManipulator();\r\n this._viewer.renderBinded = function() {\r\n // self._rootScene.getMatrix(self._tempMat)\r\n // osg.mat4.rotate(self._tempMat, self._tempMat, -Math.PI / 1000, self._upz);\r\n // self._rootScene.setMatrix(self._tempMat)\r\n // self.redraw()\r\n self.emit('viewport:update', 0);\r\n this.render();\r\n }.bind(this._viewer);\r\n\r\n // var gl = this._viewer.getState().getGraphicContext();\r\n // console.log(gl.getSupportedExtensions());\r\n // console.log(gl.getExtension('OES_texture_float'));\r\n // var hasFloatLinear = gl.getExtension('OES_texture_float_linear');\r\n // console.log(hasFloatLinear);\r\n // var hasTextureLod = gl.getExtension('EXT_shader_texture_lod');\r\n // console.log(hasTextureLod);\r\n \r\n }\r\n\r\n displayGraph() {\r\n let rootscene = this._rootScene;\r\n let displayGraph = osgUtil.DisplayGraph.instance();\r\n displayGraph.setDisplayGraphRenderer(true);\r\n displayGraph.createGraph(rootscene);\r\n }\r\n\r\n getRootModel() {\r\n return this.scene._root;\r\n }\r\n\r\n featureFinished(scene) {\r\n this._featuresManager = new FeatureManager(this);\r\n this._finishPromise.resolve()\r\n return this._featuresManager.finished(scene);\r\n }\r\n _launchViewer(t, i) {\r\n this.featureFinished(this._rootScene);\r\n }\r\n createCamera(texture) {\r\n let camera = new osg.Camera();\r\n camera.setName('composer2D');\r\n camera.setReferenceFrame(osg.Transform.ABSOLUTE_RF);\r\n\r\n let geometry = osg.createTexturedQuadGeometry(-1, -1, 0, 2, 0, 0, 0, 2, 0);\r\n geometry.getOrCreateStateSet().setTextureAttributeAndModes(0, texture);\r\n camera.addChild(geometry);\r\n\r\n return camera;\r\n }\r\n getFeaturesManager() {\r\n return this._featuresManager\r\n }\r\n getSuperSample() {\r\n return this._superSample;\r\n }\r\n getCamera() {\r\n return this._viewer.getCamera();\r\n }\r\n getInputManager() {\r\n return this._viewer.getInputManager();\r\n }\r\n drawFrame() {\r\n this._viewer.requestRedraw(), this._viewer.frame();\r\n }\r\n\r\n getCanvas() {\r\n return this._viewer._canvas;\r\n }\r\n getFeatures() {\r\n return this._features;\r\n }\r\n\r\n getViewerOSGJS() {\r\n return this._viewer;\r\n }\r\n\r\n\r\n pick(x, y, fn, detail) {\r\n var canvas = this._canvas;\r\n var ratioX = canvas.width / canvas.clientWidth;\r\n var ratioY = canvas.height / canvas.clientHeight;\r\n // console.log(ratioX, ratioY)\r\n // console.log(ev.canvasX, ev.canvasY, canvas.clientHeight)\r\n var hits = this._viewer.computeIntersections(\r\n x * ratioX,\r\n (canvas.clientHeight - y) * ratioY,\r\n PickMask.PICK_GEOMETRY_FAST,\r\n );\r\n\r\n if (hits.length > 0) {\r\n hits.sort(function(a, b) {\r\n return a._ratio - b._ratio;\r\n });\r\n // this.setOutLine(hits[0]._drawable.getOrCreateStateSet())\r\n \r\n let ret = detail ? hits[0] : hits[0]._drawable;\r\n fn && fn(ret);\r\n return ret;\r\n }\r\n fn && fn();\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * @param {*} stateSet \r\n * @param {*} config \r\n * colorSelection: 高亮颜色 [r, g, b]\r\n * durationOutline: 外轮廓显示时间(毫秒)\r\n * durationHighlight: 内部高亮显示时间(毫秒)\r\n * outlineWidth:外轮廓宽度\r\n * \r\n */\r\n setOutLine(stateSet, config = {}) {\r\n const model = this._features.outline.model\r\n config.colorSelection && model.set('colorSelection', config.colorSelection)\r\n config.durationOutline && model.set('durationOutline', config.durationOutline)\r\n config.durationHighlight && model.set('durationHighlight', config.durationHighlight)\r\n config.outlineWidth && model.set('outlineWidth', config.outlineWidth)\r\n model.trigger('displayOutlineNoFocus', stateSet)\r\n this._frameManager.draw();\r\n }\r\n\r\n setEnvironmentRotation(rot) {\r\n this._features.environment.getModel().set('rotation', rot);\r\n }\r\n setBackgroundColor() {\r\n var color;\r\n if (arguments.length > 1)\r\n color = osg.vec3.fromValues(arguments[0], arguments[1], arguments[2]);\r\n else\r\n color = osg.vec3.fromValues(\r\n arguments[0][0],\r\n arguments[0][1],\r\n arguments[0][2],\r\n );\r\n this._features.background.getModel().set('color', color);\r\n }\r\n setBackgroundMode(mode) {\r\n this._features.background.getModel().set('enable', mode);\r\n }\r\n\r\n setBackgroundFixed(fixed) {\r\n this._features.background.getModel().set('fixed', fixed);\r\n }\r\n\r\n setEnvironmentExposure(exposure) {\r\n this._features.environment.getModel().set('exposure', exposure)\r\n }\r\n\r\n setEnvironmentModel(envModel) {\r\n this._features.environment.getModel().set('env', envModel)\r\n }\r\n\r\n setToneMappingExposure(exp) {\r\n this._features.postProcess.getModel().set('toneMappingExposure', exp)\r\n }\r\n setToneMappingBrightness(bright) {\r\n this._features.postProcess.getModel().set('toneMappingBrightness', bright)\r\n }\r\n setToneMappingContrast(contrast) {\r\n this._features.postProcess.getModel().set('toneMappingContrast', contrast)\r\n }\r\n setToneMappingSaturation(sat) {\r\n this._features.postProcess.getModel().set('toneMappingSaturation', sat)\r\n }\r\n setToneMappingMethod(method) {\r\n this._features.postProcess.getModel().set('toneMappingMethod', method)\r\n }\r\n\r\n setViewMode(mode, distance) {\r\n this._viewer.getManipulator().setViewMode(mode, distance)\r\n }\r\n\r\n setNoPan(value) {\r\n this._viewer.getManipulator().getCurrentManipulator().setNoPan(value)\r\n }\r\n\r\n setNoZoom(value) {\r\n this._viewer.getManipulator().getCurrentManipulator().setNoZoom(value)\r\n }\r\n takeScreenShot(w, h) {\r\n let canvas = this._features.screenShot.getScreenShot(w, h, this)\r\n // let adom = document.createElement('a')\r\n // document.body.appendChild(adom)\r\n // adom.style.display = 'none'\r\n // adom.href = canvas.toDataURL('image/jpeg')\r\n // adom.download = 'image.jpg'\r\n // adom.click()\r\n return canvas\r\n }\r\n\r\n readShaders() {\r\n this._shaderProcessor.addShaders(shaderChunks);\r\n }\r\n\r\n getEventEmitter() {\r\n return this._eventEmiiter;\r\n }\r\n\r\n redraw() {\r\n this._frameManager.draw();\r\n }\r\n\r\n\r\n createScene() {\r\n this.scene = new Scene();\r\n }\r\n\r\n resize(width, height) {}\r\n\r\n start() {\r\n this._launchViewer();\r\n this._viewer.run();\r\n\r\n\r\n //this._features.lighting.enable(true)\r\n //this._features.lighting.model.set('select', 0)\r\n //this._features.lighting.model.setPreset(\"ThreePointLight\")\r\n //this._features.lighting.showLighting(true)\r\n }\r\n\r\n captureMaterial(material) {\r\n MaterialUtils.captureMaterial(material)\r\n \r\n }\r\n destory(forceClean) {\r\n this._viewer.setDone(true);\r\n this._viewer.dispose();\r\n ShaderMaker.clearCache()\r\n forceClean && ResourceManager.getInstance().dirty()\r\n this._rootScene.accept(this._releaseVisitor);\r\n this._rootScene.removeChildren();\r\n this._rootScene = null;\r\n this._viewer.flushAllDeletedGLObjects()\r\n }\r\n\r\n getLightPresets() {\r\n return PresetLights\r\n }\r\n\r\n setThreeLightsJson(json, isPreset) { \r\n const lightsModel = this._features.lighting.model\r\n lightsModel.setJSON({ enable: lightsModel.get('enable'), lights: json}, isPreset)\r\n return true\r\n } \r\n\r\n setLightingEnable(flag) {\r\n const lightsModel = this._features.lighting.model\r\n lightsModel.set('enable', flag)\r\n return true\r\n }\r\n\r\n setEditLightingMode(flag) {\r\n this._features.lighting.showLighting(flag)\r\n return true\r\n }\r\n\r\n setLightSelect(index){\r\n this._features.lighting.setSelect(index)\r\n }\r\n\r\n setLightDir(index, theta, phi){ //theta range[0-180], phi range[0-360]\r\n let lightModel = this._features.lighting.model.get('lights')[index]\r\n let matrix = lightModel.get('matrix')\r\n let ymatrix = osg.mat4.create()\r\n osg.mat4.fromYRotation(ymatrix, Math.PI * theta / 180)\r\n let zmatrix = osg.mat4.create()\r\n osg.mat4.fromZRotation(zmatrix, Math.PI * phi / 180)\r\n osg.mat4.mul(matrix, zmatrix, ymatrix)\r\n lightModel.dirty()\r\n this._features.lighting.model.dirtyScene()\r\n this.redraw()\r\n }\r\n\r\n setAutoRotateMode(value) {\r\n this._switchManipulator.setAutoRotateMode(value)\r\n \r\n }\r\n\r\n initExplode(node) {\r\n this._explodeRoot = node\r\n let explodeCenter = osg.vec3.clone(this._explodeRoot.getBoundingSphere().center())\r\n this._explodeSetup.setCenter(explodeCenter)\r\n this._explodeSetup.apply(this._explodeRoot)\r\n }\r\n\r\n explode(scale) {\r\n if(!this._explodeRoot) return\r\n if(scale < 1) scale = 1\r\n this._explode.setScale(scale)\r\n this._explode.apply(this._explodeRoot)\r\n this.redraw()\r\n }\r\n}\r\n\r\nexport default Application;","import { Events } from './events';\r\n\r\nclass Bus extends Events {\r\n constructor() {\r\n super();\r\n\r\n this.root = null;\r\n this._hooks = {};\r\n }\r\n\r\n method(name, fn) {\r\n if (this._hooks[name] !== undefined) {\r\n throw new Error(\"can't override hook: \" + name);\r\n }\r\n this._hooks[name] = fn;\r\n }\r\n\r\n methodRemove(name) {\r\n delete this._hooks[name];\r\n }\r\n\r\n call(name) {\r\n if (this._hooks[name]) {\r\n var args = Array.prototype.slice.call(arguments, 1);\r\n\r\n try {\r\n return this._hooks[name].apply(null, args);\r\n } catch (ex) {\r\n console.info(\r\n '%c%s %c(editor.method error)',\r\n 'color: #06f',\r\n name,\r\n 'color: #f00',\r\n );\r\n console.error(ex);\r\n }\r\n } else {\r\n // console.info('%c%s %c - editor.method does not exist yet', 'color: #06f', name, 'color: #f00');\r\n }\r\n return null;\r\n }\r\n}\r\n\r\nexport { Bus };","import P from 'bluebird';\r\nimport utils from '../../osg/utils';\r\nimport TransformEnums from '../../osg/transformEnums';\r\n\r\nvar rejectObject = utils.rejectObject;\r\n\r\nvar osgWrapper = {};\r\n\r\nosgWrapper.Object = function(input, obj) {\r\n var jsonObj = input.getJSON();\r\n\r\n if (jsonObj.Name) obj.setName(jsonObj.Name);\r\n\r\n if (jsonObj.UserDataContainer) {\r\n var userdata = input.setJSON(jsonObj.UserDataContainer).readUserDataContainer();\r\n if (userdata !== undefined) {\r\n obj.setUserData(userdata);\r\n }\r\n }\r\n\r\n return obj;\r\n};\r\n/* jshint newcap: false */\r\nosgWrapper.Node = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n\r\n osgWrapper.Object(input, node);\r\n\r\n var promiseArray = [];\r\n\r\n if (jsonObj.UpdateCallbacks) {\r\n var cbAddCallback = node.addUpdateCallback.bind(node);\r\n for (var j = 0, l = jsonObj.UpdateCallbacks.length; j < l; j++) {\r\n var promise = input.setJSON(jsonObj.UpdateCallbacks[j]).readObject();\r\n promiseArray.push(promise);\r\n promise.then(cbAddCallback);\r\n }\r\n }\r\n\r\n if (jsonObj.StateSet) {\r\n var pp = input.setJSON(jsonObj.StateSet).readObject();\r\n promiseArray.push(pp);\r\n pp.then(node.setStateSet.bind(node));\r\n }\r\n\r\n var queue = [];\r\n // For each url, create a function call and add it to the queue\r\n if (jsonObj.Children) {\r\n for (var i = 0, k = jsonObj.Children.length; i < k; i++) {\r\n queue.push(input.setJSON(jsonObj.Children[i]).readObject());\r\n }\r\n }\r\n // Resolve first updateCallbacks and stateset.\r\n return P.all(promiseArray).then(function() {\r\n // Need to wait until the stateset and the all the callbacks are resolved\r\n return P.all(queue).then(function(queueNodes) {\r\n // All the results from P.all are on the argument as an array\r\n // Now insert children in the right order\r\n var len = queueNodes.length;\r\n for (var n = 0; n < len; n++) node.addChild(queueNodes[n]);\r\n return node;\r\n });\r\n });\r\n};\r\n\r\nosgWrapper.StateSet = function(input, stateSet) {\r\n var jsonObj = input.getJSON();\r\n\r\n osgWrapper.Object(input, stateSet);\r\n\r\n if (jsonObj.RenderingHint !== undefined) {\r\n stateSet.setRenderingHint(jsonObj.RenderingHint);\r\n }\r\n\r\n var promiseArray = [];\r\n\r\n var createAttribute = function(jsonAttribute) {\r\n var promise = input.setJSON(jsonAttribute).readObject();\r\n if (\r\n promise.isRejected() // sometimes we have some empty objects\r\n )\r\n return;\r\n promiseArray.push(promise);\r\n promise.then(stateSet.setAttributeAndModes.bind(stateSet));\r\n };\r\n\r\n if (jsonObj.AttributeList !== undefined) {\r\n for (var i = 0, l = jsonObj.AttributeList.length; i < l; i++) {\r\n createAttribute(jsonObj.AttributeList[i]);\r\n }\r\n }\r\n\r\n var createTextureAttribute = function(unit, textureAttribute) {\r\n var promise = input.setJSON(textureAttribute).readObject();\r\n if (\r\n promise.isRejected() // sometimes we have some empty objects\r\n )\r\n return;\r\n promiseArray.push(promise);\r\n promise.then(stateSet.setTextureAttributeAndModes.bind(stateSet, unit));\r\n };\r\n\r\n if (jsonObj.TextureAttributeList) {\r\n var textures = jsonObj.TextureAttributeList;\r\n for (var t = 0, lt = textures.length; t < lt; t++) {\r\n var textureAttributes = textures[t];\r\n for (var a = 0, al = textureAttributes.length; a < al; a++) {\r\n createTextureAttribute(t, textureAttributes[a]);\r\n }\r\n }\r\n }\r\n\r\n return P.all(promiseArray).then(function() {\r\n return stateSet;\r\n });\r\n};\r\n\r\nosgWrapper.Material = function(input, material) {\r\n var jsonObj = input.getJSON();\r\n if (\r\n !jsonObj.Diffuse ||\r\n !jsonObj.Emission ||\r\n !jsonObj.Specular ||\r\n jsonObj.Shininess === undefined\r\n ) {\r\n return rejectObject('Material', jsonObj);\r\n }\r\n\r\n osgWrapper.Object(input, material);\r\n\r\n material.setAmbient(jsonObj.Ambient);\r\n material.setDiffuse(jsonObj.Diffuse);\r\n material.setEmission(jsonObj.Emission);\r\n material.setSpecular(jsonObj.Specular);\r\n material.setShininess(jsonObj.Shininess);\r\n return P.resolve(material);\r\n};\r\n\r\nosgWrapper.BlendFunc = function(input, blend) {\r\n var jsonObj = input.getJSON();\r\n if (\r\n !jsonObj.SourceRGB ||\r\n !jsonObj.SourceAlpha ||\r\n !jsonObj.DestinationRGB ||\r\n !jsonObj.DestinationAlpha\r\n ) {\r\n return rejectObject('BlendFunc', jsonObj);\r\n }\r\n\r\n osgWrapper.Object(input, blend);\r\n\r\n blend.setSourceRGB(jsonObj.SourceRGB);\r\n blend.setSourceAlpha(jsonObj.SourceAlpha);\r\n blend.setDestinationRGB(jsonObj.DestinationRGB);\r\n blend.setDestinationAlpha(jsonObj.DestinationAlpha);\r\n return P.resolve(blend);\r\n};\r\n\r\nosgWrapper.CullFace = function(input, attr) {\r\n var jsonObj = input.getJSON();\r\n if (jsonObj.Mode === undefined) return rejectObject('CullFace', jsonObj);\r\n\r\n osgWrapper.Object(input, attr);\r\n attr.setMode(jsonObj.Mode);\r\n return P.resolve(attr);\r\n};\r\n\r\nosgWrapper.BlendColor = function(input, attr) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.ConstantColor) return rejectObject('BlendColor', jsonObj);\r\n\r\n osgWrapper.Object(input, attr);\r\n attr.setConstantColor(jsonObj.ConstantColor);\r\n return P.resolve(attr);\r\n};\r\n\r\nosgWrapper.Light = function(input, light) {\r\n var jsonObj = input.getJSON();\r\n\r\n if (\r\n !jsonObj.Ambient ||\r\n !jsonObj.Diffuse ||\r\n !jsonObj.Direction ||\r\n !jsonObj.Position ||\r\n !jsonObj.Specular ||\r\n jsonObj.LightNum === undefined ||\r\n jsonObj.SpotCutoff === undefined ||\r\n jsonObj.LinearAttenuation === undefined ||\r\n jsonObj.ConstantAttenuation === undefined ||\r\n jsonObj.QuadraticAttenuation === undefined\r\n ) {\r\n return rejectObject('Light', jsonObj);\r\n }\r\n\r\n osgWrapper.Object(input, light);\r\n light.setAmbient(jsonObj.Ambient);\r\n light.setConstantAttenuation(jsonObj.ConstantAttenuation);\r\n light.setDiffuse(jsonObj.Diffuse);\r\n light.setDirection(jsonObj.Direction);\r\n light.setLightNumber(jsonObj.LightNum);\r\n light.setLinearAttenuation(jsonObj.LinearAttenuation);\r\n light.setPosition(jsonObj.Position);\r\n light.setQuadraticAttenuation(jsonObj.QuadraticAttenuation);\r\n light.setSpecular(jsonObj.Specular);\r\n light.setSpotCutoff(jsonObj.SpotCutoff);\r\n light.setSpotBlend(0.01);\r\n if (jsonObj.SpotExponent !== undefined) {\r\n light.setSpotBlend(jsonObj.SpotExponent / 128.0);\r\n }\r\n return P.resolve(light);\r\n};\r\n\r\nosgWrapper.Texture = function(input, texture) {\r\n var jsonObj = input.getJSON();\r\n\r\n osgWrapper.Object(input, texture);\r\n\r\n if (jsonObj.MinFilter) texture.setMinFilter(jsonObj.MinFilter);\r\n if (jsonObj.MagFilter) texture.setMagFilter(jsonObj.MagFilter);\r\n if (jsonObj.WrapT) texture.setWrapT(jsonObj.WrapT);\r\n if (jsonObj.WrapS) texture.setWrapS(jsonObj.WrapS);\r\n\r\n // no file return dummy texture\r\n var file = jsonObj.File;\r\n if (file === undefined) {\r\n file = 'no-image-provided';\r\n }\r\n\r\n return input.readImageURL(file).then(function(img) {\r\n texture.setImage(img);\r\n return texture;\r\n });\r\n};\r\n\r\nosgWrapper.Projection = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Matrix) return rejectObject('Projection', jsonObj);\r\n\r\n var promise = osgWrapper.Node(input, node);\r\n node.setMatrix(jsonObj.Matrix);\r\n return promise;\r\n};\r\n\r\nosgWrapper.MatrixTransform = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Matrix) return rejectObject('MatrixTransform', jsonObj);\r\n\r\n var promise = osgWrapper.Node(input, node);\r\n node.setMatrix(jsonObj.Matrix);\r\n return promise;\r\n};\r\n\r\nosgWrapper.LightSource = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Light) return rejectObject('LightSource', jsonObj);\r\n\r\n var promise = osgWrapper.Node(input, node);\r\n return P.all([input.setJSON(jsonObj.Light).readObject(), promise]).then(function(args) {\r\n var light = args[0];\r\n //var lightsource = args[ 1 ];\r\n node.setLight(light);\r\n if (jsonObj.ReferenceFrame === 'ABSOLUTE_RF') {\r\n node.setReferenceFrame(TransformEnums.ABSOLUTE_RF);\r\n }\r\n return node;\r\n });\r\n};\r\n\r\n// not robust, but we probably don't want to complexify the function for now\r\nosgWrapper.functionSortAttributes = function(a, b) {\r\n if (a.indexOf('TexCoord') !== -1 && b.indexOf('TexCoord') !== -1) {\r\n return parseInt(a.substr(8), 10) - parseInt(b.substr(8), 10);\r\n }\r\n\r\n if (a < b) return -1;\r\n if (a > b) return 1;\r\n return 0;\r\n};\r\n\r\nosgWrapper.Geometry = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.VertexAttributeList) return rejectObject('Geometry', jsonObj);\r\n\r\n jsonObj.PrimitiveSetList = jsonObj.PrimitiveSetList || [];\r\n\r\n var arraysPromise = [];\r\n arraysPromise.push(osgWrapper.Node(input, node));\r\n\r\n var prims = node.getPrimitives();\r\n var cbAddPrimitives = prims.push.bind(prims);\r\n var i = 0;\r\n var l = jsonObj.PrimitiveSetList.length;\r\n for (i = 0; i < l; i++) {\r\n var promisePrimitive = input.setJSON(jsonObj.PrimitiveSetList[i]).readPrimitiveSet();\r\n arraysPromise.push(promisePrimitive);\r\n promisePrimitive.then(cbAddPrimitives);\r\n }\r\n\r\n var cbSetBuffer = function(name, buffer) {\r\n this.getVertexAttributeList()[name] = buffer;\r\n };\r\n\r\n var vList = jsonObj.VertexAttributeList;\r\n var keys = window.Object.keys(vList);\r\n\r\n // TexCoord10 should be sorted after TexCoord5 (in case of referenced attributes)\r\n // alternative is to resolve the referenced keys (2 passes method for example)\r\n keys.sort(osgWrapper.functionSortAttributes);\r\n\r\n l = keys.length;\r\n for (i = 0; i < l; i++) {\r\n var name = keys[i];\r\n var promiseBuffer = input.setJSON(vList[name]).readBufferArray();\r\n arraysPromise.push(promiseBuffer);\r\n promiseBuffer.then(cbSetBuffer.bind(node, name));\r\n }\r\n\r\n return P.all(arraysPromise).then(function() {\r\n return node;\r\n });\r\n};\r\n\r\nosgWrapper.PagedLOD = function(input, plod) {\r\n var jsonObj = input.getJSON();\r\n\r\n osgWrapper.Object(input, plod);\r\n // Parse center Mode\r\n if (jsonObj.CenterMode === 'USE_BOUNDING_SPHERE_CENTER') plod.setCenterMode(0);\r\n else if (jsonObj.CenterMode === 'UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED')\r\n plod.setCenterMode(2);\r\n\r\n // Parse center and radius\r\n plod.setCenter([jsonObj.UserCenter[0], jsonObj.UserCenter[1], jsonObj.UserCenter[2]]);\r\n plod.setRadius(jsonObj.UserCenter[3]);\r\n\r\n // Parse RangeMode\r\n if (jsonObj.RangeMode === 'PIXEL_SIZE_ON_SCREEN') plod.setRangeMode(1);\r\n\r\n var str;\r\n\r\n // Parse Ranges\r\n var o = jsonObj.RangeList;\r\n\r\n for (var i = 0; i < window.Object.keys(o).length; i++) {\r\n str = 'Range ' + i;\r\n var v = o[str];\r\n plod.setRange(i, v[0], v[1]);\r\n }\r\n // Parse Files\r\n o = jsonObj.RangeDataList;\r\n for (i = 0; i < window.Object.keys(o).length; i++) {\r\n str = 'File ' + i;\r\n plod.setFileName(i, o[str]);\r\n }\r\n // Set database path from options\r\n // TODO: Check also if we have a path from json\r\n plod.setDatabasePath(input.getDatabasePath());\r\n\r\n var queue = [];\r\n // For each url, create a function call and add it to the queue\r\n if (jsonObj.Children) {\r\n for (var j = 0, k = jsonObj.Children.length; j < k; j++) {\r\n queue.push(input.setJSON(jsonObj.Children[j]).readObject());\r\n }\r\n }\r\n\r\n return P.all(queue).then(function(queueNodes) {\r\n // All the results from P.all are on the argument as an array\r\n var len = queueNodes.length;\r\n for (i = 0; i < len; i++) plod.addChildNode(queueNodes[i]);\r\n return plod;\r\n });\r\n};\r\nexport default osgWrapper;\r\n","import P from 'bluebird';\r\nimport utils from '../../osg/utils';\r\nimport notify from '../../osg/notify';\r\nimport osgWrapper from './osg';\r\nimport Channel from '../../osgAnimation/channel';\r\nimport Animation from '../../osgAnimation/animation';\r\nimport ReaderParser from '../../osgDB/readerParser';\r\nimport StackedMatrix from '../../osgAnimation/StackedMatrix';\r\nimport StackedScale from '../../osgAnimation/StackedScale';\r\nimport MorphGeometry from '../../osgAnimation/MorphGeometry';\r\nimport Geometry from '../../osg/Geometry';\r\n\r\nvar rejectObject = utils.rejectObject;\r\n\r\nvar osgAnimationWrapper = {};\r\n\r\nvar channelCtor = function() {};\r\n\r\nvar registry = ReaderParser.registry();\r\nregistry.registerObject('osgAnimation.Vec3LerpChannel', channelCtor);\r\nregistry.registerObject('osgAnimation.FloatLerpChannel', channelCtor);\r\nregistry.registerObject('osgAnimation.QuatSlerpChannel', channelCtor);\r\nregistry.registerObject('osgAnimation.QuatLerpChannel', channelCtor);\r\nregistry.registerObject('osgAnimation.FloatCubicBezierChannel', channelCtor);\r\nregistry.registerObject('osgAnimation.Vec3CubicBezierChannel', channelCtor);\r\n// needs to be cleaned in c++\r\nregistry.registerObject('osgAnimation.StackedMatrixElement', StackedMatrix);\r\nregistry.registerObject('osgAnimation.StackedScaleElement', StackedScale);\r\n\r\nosgAnimationWrapper.Animation = function(input) {\r\n var jsonObj = input.getJSON();\r\n if (jsonObj.Name === undefined || !jsonObj.Channels || jsonObj.Channels.length === 0) {\r\n return rejectObject('Animation', jsonObj);\r\n }\r\n\r\n var arrayChannelsPromise = [];\r\n\r\n // channels\r\n for (var i = 0, l = jsonObj.Channels.length; i < l; i++) {\r\n var promise = input.setJSON(jsonObj.Channels[i]).readObject();\r\n arrayChannelsPromise.push(promise);\r\n }\r\n\r\n return P.all(arrayChannelsPromise).then(function(channels) {\r\n return Animation.createAnimation(channels, jsonObj.Name);\r\n });\r\n};\r\n\r\nosgAnimationWrapper.StandardVec3Channel = function(input, channel, creator) {\r\n var jsonObj = input.getJSON();\r\n if (\r\n jsonObj.TargetName === undefined ||\r\n !jsonObj.KeyFrames ||\r\n !jsonObj.Name ||\r\n !jsonObj.KeyFrames.Time ||\r\n !jsonObj.KeyFrames.Key ||\r\n jsonObj.KeyFrames.Key.length !== 3\r\n ) {\r\n return rejectObject('StandardVec3Channel', jsonObj);\r\n }\r\n\r\n var jsTime = input.setJSON(jsonObj.KeyFrames.Time).readBufferArray();\r\n var jsKeyX = input.setJSON(jsonObj.KeyFrames.Key[0]).readBufferArray();\r\n var jsKeyY = input.setJSON(jsonObj.KeyFrames.Key[1]).readBufferArray();\r\n var jsKeyZ = input.setJSON(jsonObj.KeyFrames.Key[2]).readBufferArray();\r\n\r\n return P.all([jsTime, jsKeyX, jsKeyY, jsKeyZ]).then(function(pArray) {\r\n var eTime = pArray[0].getElements();\r\n var eKeyX = pArray[1].getElements();\r\n var eKeyY = pArray[2].getElements();\r\n var eKeyZ = pArray[3].getElements();\r\n\r\n // the keys and time array are always create with a slightly biffer array buffer\r\n // (one additional element) in case we want to lerp between end and start\r\n var size = eTime.length;\r\n var keys = new Float32Array(new ArrayBuffer(4 * (size + 1) * 3), 0, size * 3);\r\n var times = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n\r\n for (var i = 0; i < size; i++) {\r\n var id = i * 3;\r\n times[i] = eTime[i];\r\n keys[id++] = eKeyX[i];\r\n keys[id++] = eKeyY[i];\r\n keys[id] = eKeyZ[i];\r\n }\r\n\r\n creator(keys, times, jsonObj.TargetName, jsonObj.Name, channel);\r\n return channel;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.StandardQuatChannel = function(input, channel, creator) {\r\n var jsonObj = input.getJSON();\r\n if (\r\n jsonObj.TargetName === undefined ||\r\n !jsonObj.KeyFrames ||\r\n !jsonObj.Name ||\r\n !jsonObj.KeyFrames.Time ||\r\n !jsonObj.KeyFrames.Key ||\r\n jsonObj.KeyFrames.Key.length !== 4\r\n ) {\r\n return rejectObject('StandardQuatChannel', jsonObj);\r\n }\r\n\r\n var jsTime = input.setJSON(jsonObj.KeyFrames.Time).readBufferArray();\r\n var jsKeyX = input.setJSON(jsonObj.KeyFrames.Key[0]).readBufferArray();\r\n var jsKeyY = input.setJSON(jsonObj.KeyFrames.Key[1]).readBufferArray();\r\n var jsKeyZ = input.setJSON(jsonObj.KeyFrames.Key[2]).readBufferArray();\r\n var jsKeyW = input.setJSON(jsonObj.KeyFrames.Key[3]).readBufferArray();\r\n\r\n return P.all([jsTime, jsKeyX, jsKeyY, jsKeyZ, jsKeyW]).then(function(pArray) {\r\n var eTime = pArray[0].getElements();\r\n var eKeyX = pArray[1].getElements();\r\n var eKeyY = pArray[2].getElements();\r\n var eKeyZ = pArray[3].getElements();\r\n var eKeyW = pArray[4].getElements();\r\n\r\n var size = eTime.length;\r\n var keys = new Float32Array(new ArrayBuffer(4 * (size + 1) * 4), 0, size * 4);\r\n var times = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n\r\n for (var i = 0; i < size; i++) {\r\n var id = i * 4;\r\n times[i] = eTime[i];\r\n keys[id++] = eKeyX[i];\r\n keys[id++] = eKeyY[i];\r\n keys[id++] = eKeyZ[i];\r\n keys[id] = eKeyW[i];\r\n }\r\n creator(keys, times, jsonObj.TargetName, jsonObj.Name, channel);\r\n return channel;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.StandardFloatChannel = function(input, channel, creator) {\r\n var jsonObj = input.getJSON();\r\n if (\r\n jsonObj.TargetName === undefined ||\r\n !jsonObj.KeyFrames ||\r\n !jsonObj.Name ||\r\n !jsonObj.KeyFrames.Time ||\r\n !jsonObj.KeyFrames.Key\r\n ) {\r\n return rejectObject('StandardFloatChannel', jsonObj);\r\n }\r\n\r\n var jsTime = input.setJSON(jsonObj.KeyFrames.Time).readBufferArray();\r\n var jsKey = input.setJSON(jsonObj.KeyFrames.Key).readBufferArray();\r\n\r\n return P.all([jsTime, jsKey]).then(function(pArray) {\r\n var eTime = pArray[0].getElements();\r\n var eKey = pArray[1].getElements();\r\n\r\n var size = eTime.length;\r\n var keys = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n var times = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n\r\n for (var i = 0; i < size; i++) {\r\n times[i] = eTime[i];\r\n keys[i] = eKey[i];\r\n }\r\n\r\n creator(keys, times, jsonObj.TargetName, jsonObj.Name, channel);\r\n return channel;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.Vec3LerpChannel = function(input, channel) {\r\n return osgAnimationWrapper.StandardVec3Channel(input, channel, Channel.createVec3Channel);\r\n};\r\n\r\nosgAnimationWrapper.QuatLerpChannel = function(input, channel) {\r\n return osgAnimationWrapper.StandardQuatChannel(input, channel, Channel.createQuatChannel);\r\n};\r\n\r\nosgAnimationWrapper.QuatSlerpChannel = function(input, channel) {\r\n // nlerp is less expensive than slerp\r\n return osgAnimationWrapper.StandardQuatChannel(input, channel, Channel.createQuatChannel);\r\n // return osgAnimationWrapper.StandardQuatChannel( input, channel, Channel.createQuatSlerpChannel );\r\n};\r\n\r\nosgAnimationWrapper.FloatLerpChannel = function(input, channel) {\r\n return osgAnimationWrapper.StandardFloatChannel(input, channel, Channel.createFloatChannel);\r\n};\r\n\r\nosgAnimationWrapper.FloatCubicBezierChannel = function(input, channel) {\r\n var jsonObj = input.getJSON();\r\n\r\n if (\r\n jsonObj.TargetName === undefined ||\r\n !jsonObj.KeyFrames ||\r\n !jsonObj.Name ||\r\n !jsonObj.KeyFrames.Time ||\r\n !jsonObj.KeyFrames.Position ||\r\n !jsonObj.KeyFrames.ControlPointOut ||\r\n !jsonObj.KeyFrames.ControlPointIn\r\n ) {\r\n return rejectObject('FloatCubicBezierChannel', jsonObj);\r\n }\r\n\r\n var arrayPromise = [];\r\n var keyFrames = window.Object.keys(jsonObj.KeyFrames);\r\n var i;\r\n for (i = 0; i < keyFrames.length; i++)\r\n arrayPromise.push(input.setJSON(jsonObj.KeyFrames[keyFrames[i]]).readBufferArray());\r\n\r\n return P.all(arrayPromise).then(function(pArray) {\r\n var controlPointIn = pArray[0].getElements();\r\n var controlPointOut = pArray[1].getElements();\r\n var position = pArray[2].getElements();\r\n var time = pArray[3].getElements();\r\n\r\n var size = time.length;\r\n var keys = new Float32Array(new ArrayBuffer(4 * (size + 1) * 3), 0, size * 3);\r\n var times = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n\r\n for (i = 0; i < size; i++) {\r\n var id = i * 3;\r\n\r\n times[i] = time[i];\r\n keys[id++] = position[i];\r\n keys[id++] = controlPointIn[i];\r\n keys[id] = controlPointOut[i];\r\n }\r\n Channel.createFloatCubicBezierChannel(\r\n keys,\r\n times,\r\n jsonObj.TargetName,\r\n jsonObj.Name,\r\n channel\r\n );\r\n return channel;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.Vec3CubicBezierChannel = function(input, channel) {\r\n var jsonObj = input.getJSON();\r\n\r\n if (\r\n jsonObj.TargetName === undefined ||\r\n !jsonObj.KeyFrames ||\r\n !jsonObj.Name ||\r\n !jsonObj.KeyFrames.Time ||\r\n !jsonObj.KeyFrames.Position ||\r\n !jsonObj.KeyFrames.ControlPointOut ||\r\n !jsonObj.KeyFrames.ControlPointIn ||\r\n jsonObj.KeyFrames.Position.length !== 3 ||\r\n jsonObj.KeyFrames.ControlPointIn.length !== 3 ||\r\n jsonObj.KeyFrames.ControlPointOut.length !== 3\r\n ) {\r\n return rejectObject('Vec3CubicBezierChannel', jsonObj);\r\n }\r\n\r\n var arrayPromise = [];\r\n\r\n //Reads all keyframes\r\n var keyFrames = window.Object.keys(jsonObj.KeyFrames);\r\n var i;\r\n for (i = 0; i < keyFrames.length; i++) {\r\n var key = keyFrames[i];\r\n var jsonAttribute = jsonObj.KeyFrames[key];\r\n if (key !== 'Time') {\r\n arrayPromise.push(input.setJSON(jsonAttribute[0]).readBufferArray());\r\n arrayPromise.push(input.setJSON(jsonAttribute[1]).readBufferArray());\r\n arrayPromise.push(input.setJSON(jsonAttribute[2]).readBufferArray());\r\n } else arrayPromise.push(input.setJSON(jsonAttribute).readBufferArray());\r\n }\r\n\r\n return P.all(arrayPromise).then(function(pArray) {\r\n var cpi0 = pArray[0].getElements();\r\n var cpi1 = pArray[1].getElements();\r\n var cpi2 = pArray[2].getElements();\r\n var cpo0 = pArray[3].getElements();\r\n var cpo1 = pArray[4].getElements();\r\n var cpo2 = pArray[5].getElements();\r\n var p0 = pArray[6].getElements();\r\n var p1 = pArray[7].getElements();\r\n var p2 = pArray[8].getElements();\r\n var time = pArray[9].getElements();\r\n\r\n var size = time.length;\r\n var keys = new Float32Array(new ArrayBuffer(4 * (size + 1) * 9), 0, size * 9);\r\n var times = new Float32Array(new ArrayBuffer(4 * (size + 1)), 0, size);\r\n\r\n for (i = 0; i < size; i++) {\r\n var id = i * 9;\r\n\r\n times[i] = time[i];\r\n keys[id++] = p0[i];\r\n keys[id++] = p1[i];\r\n keys[id++] = p2[i];\r\n\r\n keys[id++] = cpi0[i];\r\n keys[id++] = cpi1[i];\r\n keys[id++] = cpi2[i];\r\n\r\n keys[id++] = cpo0[i];\r\n keys[id++] = cpo1[i];\r\n keys[id] = cpo2[i];\r\n }\r\n Channel.createVec3CubicBezierChannel(\r\n keys,\r\n times,\r\n jsonObj.TargetName,\r\n jsonObj.Name,\r\n channel\r\n );\r\n return channel;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.BasicAnimationManager = function(input, manager) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Animations) return rejectObject('BasicAnimationManager', jsonObj);\r\n\r\n osgWrapper.Object(input, manager);\r\n\r\n var animPromises = [];\r\n\r\n for (var i = 0, l = jsonObj.Animations.length; i < l; i++) {\r\n var promiseAnimation = input.setJSON(jsonObj.Animations[i]).readObject();\r\n if (promiseAnimation.isRejected()) {\r\n notify.warn('An Animation failed on the parsing!');\r\n continue;\r\n }\r\n animPromises.push(promiseAnimation);\r\n }\r\n\r\n return P.all(animPromises).then(function(animations) {\r\n manager.init(animations);\r\n return manager;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.UpdateMatrixTransform = function(input, umt) {\r\n var jsonObj = input.getJSON();\r\n // some stackedTransform on bones has no name but the transform is usefull\r\n if (/*!jsonObj.Name ||*/ !jsonObj.StackedTransforms) {\r\n return rejectObject('UpdateMatrixTransform', jsonObj);\r\n }\r\n\r\n osgWrapper.Object(input, umt);\r\n\r\n var promiseArray = [];\r\n var i, l;\r\n for (i = 0, l = jsonObj.StackedTransforms.length; i < l; i++) {\r\n var promiseStacked = input.setJSON(jsonObj.StackedTransforms[i]).readObject();\r\n if (promiseStacked.isRejected()) {\r\n notify.warn('A stacked transforms failed on the parsing!');\r\n continue;\r\n }\r\n promiseArray.push(promiseStacked);\r\n }\r\n\r\n // when UpdateMatrixTransform is ready\r\n // compute the default value data\r\n return P.all(promiseArray).then(function(array) {\r\n var stack = umt.getStackedTransforms();\r\n for (i = 0, l = array.length; i < l; i++) stack.push(array[i]);\r\n umt.computeChannels();\r\n return umt;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.StackedTranslate = function(input, st) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Name || !jsonObj.Translate) return rejectObject('StackedTranslate', jsonObj);\r\n\r\n osgWrapper.Object(input, st);\r\n\r\n st.init(jsonObj.Translate);\r\n\r\n return P.resolve(st);\r\n};\r\n\r\nosgAnimationWrapper.StackedQuaternion = function(input, st) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Name || !jsonObj.Quaternion) return rejectObject('StackedQuaternion', jsonObj);\r\n\r\n osgWrapper.Object(input, st);\r\n\r\n st.init(jsonObj.Quaternion);\r\n\r\n return P.resolve(st);\r\n};\r\n\r\nosgAnimationWrapper.StackedRotateAxis = function(input, st) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Axis || jsonObj.Angle === undefined) {\r\n return rejectObject('StackedRotateAxis', jsonObj);\r\n }\r\n\r\n osgWrapper.Object(input, st);\r\n\r\n st.init(jsonObj.Axis, jsonObj.Angle);\r\n\r\n return P.resolve(st);\r\n};\r\n\r\nosgAnimationWrapper.StackedMatrix = function(input, sme) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Name || !jsonObj.Matrix) return rejectObject('StackedMatrix', jsonObj);\r\n\r\n osgWrapper.Object(input, sme);\r\n\r\n sme.init(jsonObj.Matrix);\r\n\r\n return P.resolve(sme);\r\n};\r\n\r\nosgAnimationWrapper.StackedScale = function(input, stc) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Name || !jsonObj.Scale) return rejectObject('StackedScale', jsonObj);\r\n\r\n osgWrapper.Object(input, stc);\r\n\r\n stc.init(jsonObj.Scale);\r\n\r\n return P.resolve(stc);\r\n};\r\n\r\nosgAnimationWrapper.Bone = function(input, bone) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.InvBindMatrixInSkeletonSpace) return rejectObject('Bone', jsonObj);\r\n\r\n var promise = osgWrapper.MatrixTransform(input, bone);\r\n\r\n bone.setInvBindMatrixInSkeletonSpace(jsonObj.InvBindMatrixInSkeletonSpace);\r\n\r\n if (jsonObj.BoundingBox) {\r\n // It is mandatory because we need it for shadows and culling\r\n var bbox = bone.getBoneBoundingBox();\r\n bbox.setMax(jsonObj.BoundingBox.max);\r\n bbox.setMin(jsonObj.BoundingBox.min);\r\n }\r\n\r\n return promise;\r\n};\r\n\r\nosgAnimationWrapper.UpdateBone = osgAnimationWrapper.UpdateMatrixTransform;\r\n\r\nosgAnimationWrapper.UpdateSkeleton = function(input, upSkl) {\r\n osgWrapper.Object(input, upSkl);\r\n return P.resolve(upSkl);\r\n};\r\n\r\nosgAnimationWrapper.Skeleton = osgWrapper.MatrixTransform;\r\n\r\nosgAnimationWrapper.RigGeometry = function(input, rigGeom) {\r\n var jsonObj = input.getJSON();\r\n\r\n // check boneMap\r\n if (!jsonObj.SourceGeometry) return rejectObject('RigGeometry', jsonObj);\r\n\r\n if (!jsonObj.BoneMap) notify.warn('No boneMap found in a RigGeometry !');\r\n\r\n //Import rigGeometry as Geometry + BoneMap\r\n var rigPromise = osgWrapper.Geometry(input, rigGeom);\r\n rigGeom._boneNameID = jsonObj.BoneMap;\r\n\r\n //Import source geometry and merge it with the rigGeometry\r\n var sourceGeometry = jsonObj.SourceGeometry['osg.Geometry'];\r\n var geomPromise;\r\n if (sourceGeometry) {\r\n input.setJSON(sourceGeometry);\r\n rigGeom.setSourceGeometry(new Geometry());\r\n geomPromise = osgWrapper.Geometry(input, rigGeom.getSourceGeometry());\r\n } else {\r\n sourceGeometry = jsonObj.SourceGeometry['osgAnimation.MorphGeometry'];\r\n if (sourceGeometry) {\r\n input.setJSON(sourceGeometry);\r\n rigGeom.setSourceGeometry(new MorphGeometry());\r\n geomPromise = osgAnimationWrapper.MorphGeometry(input, rigGeom.getSourceGeometry());\r\n } else {\r\n notify.warn('SourceGeometry type no recognized');\r\n }\r\n }\r\n\r\n // not sure if it's normal but rig geometry don't have UniqueID\r\n if (rigGeom._uniqueID === undefined) rigGeom._uniqueID = sourceGeometry.UniqueID;\r\n\r\n return P.all([rigPromise, geomPromise]).then(function() {\r\n rigGeom.mergeChildrenData();\r\n return rigGeom;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.MorphGeometry = function(input, morphGeometry) {\r\n var jsonObj = input.getJSON();\r\n\r\n if (!jsonObj.MorphTargets) return rejectObject('MorphGeometry', jsonObj);\r\n\r\n var morphTargets = jsonObj.MorphTargets;\r\n var arrayPromise = [];\r\n\r\n // arrayPromise[0] is the morphGeometry\r\n arrayPromise.push(osgWrapper.Geometry(input, morphGeometry));\r\n\r\n for (var i = 0, l = morphTargets.length; i < l; i++)\r\n arrayPromise.push(input.setJSON(morphTargets[i]).readObject());\r\n\r\n return P.all(arrayPromise).then(function(promiseResultArray) {\r\n var morphGeometryResolved = promiseResultArray[0];\r\n\r\n var targets = morphGeometryResolved.getMorphTargets();\r\n for (var j = 1, jn = promiseResultArray.length; j < jn; j++)\r\n targets.push(promiseResultArray[j]);\r\n\r\n morphGeometryResolved.mergeChildrenVertexAttributeList();\r\n return morphGeometryResolved;\r\n });\r\n};\r\n\r\nosgAnimationWrapper.UpdateMorph = function(input, updateMorph) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.TargetMap) return rejectObject('UpdateMorph', jsonObj);\r\n\r\n osgWrapper.Object(input, updateMorph);\r\n\r\n var keys = window.Object.keys(jsonObj.TargetMap);\r\n for (var i = 0, l = keys.length; i < l; i++) {\r\n var key = keys[i];\r\n updateMorph.addTarget(jsonObj.TargetMap[key], parseInt(key, 10));\r\n }\r\n\r\n return P.resolve(updateMorph);\r\n};\r\n\r\nosgAnimationWrapper.StackedMatrixElement = osgAnimationWrapper.StackedMatrix;\r\nosgAnimationWrapper.StackedScaleElement = osgAnimationWrapper.StackedScale;\r\n\r\nexport default osgAnimationWrapper;\r\n","import CullVisitor from '../osg/CullVisitor';\r\nimport utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { vec4 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport AutoTransform from '../osg/AutoTransform';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport Shape from '../osg/shape';\r\nimport Texture from '../osg/Texture';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport { quat } from '../osg/glMatrix';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport Node from '../osg/Node';\r\n/**\r\n * @class Text: Text 2D using a Canvas2D as a texture for a textured quad.\r\n * Notes: The OSGjs Text has been implemented like OSG osgText::Text as much as possible. However there are some\r\n * things that should be noted:\r\n * - This Text is far more simple than OSG ones, it only supports basic functionality.\r\n * - In contrast to OSG, Text inherits from AutoTransform in osgjs.\r\n * - Supported fonts are not the same in HTML than in OSG/C++.\r\n * - Vertical layout is not supported right now.\r\n * - BaseLine alignments are not supported, instead they are converted to supported ones if parsing a osgjs file.\r\n * - Set the color in the range [ 0 - 1 ], as if you were working with OSG.\r\n * - Texts are generated as a canvas 2D texture sticked in a quad. The size of the texture is the next power of two of the current size of the\r\n * text so the bigger is your characterSize, the more memory it will consume.\r\n */\r\nvar Text = function(text) {\r\n AutoTransform.call(this);\r\n // create a canvas element\r\n this._canvas = document.createElement('canvas');\r\n this._context = this._canvas.getContext('2d');\r\n this._matrixTransform = new MatrixTransform();\r\n this.addChild(this._matrixTransform);\r\n this._text = '';\r\n if (text !== undefined) this._text = text;\r\n this._font = 'monospace';\r\n // Vec4 value to load/return\r\n this._color = vec4.fromValues(0.0, 0.0, 0.0, 1.0);\r\n // This determines the text color, it can take a hex value or rgba value (e.g. rgba(255,0,0,0.5))\r\n this._fillStyle = 'rgba( 0, 0, 0, 1 )';\r\n // This determines the alignment of text, e.g. left, center, right\r\n this._context.textAlign = 'center';\r\n this._textX = undefined;\r\n // This determines the baseline of the text, e.g. top, middle, bottom\r\n this._context.baseLine = 'middle';\r\n this._textY = undefined;\r\n // Size of the textured quad in meters.\r\n this._characterSize = 1;\r\n this._characterSizeMode = Text.OBJECT_COORDS;\r\n // Font resolution\r\n this._fontSize = 32;\r\n this._geometry = undefined;\r\n this._autoRotateToScreen = false;\r\n this._position = vec3.create();\r\n this._layout = Text.LEFT_TO_RIGHT;\r\n this._alignment = Text.CENTER_CENTER;\r\n // NPOT textures\r\n this._forcePowerOfTwo = false;\r\n // Lazy initialization\r\n this._texture = new Texture();\r\n this.drawText();\r\n this._dirty = false;\r\n\r\n // We need to keep track of modelView Matrix\r\n this._previousModelView = mat4.create();\r\n};\r\n\r\n// CharacterSizeMode\r\nText.OBJECT_COORDS = 0;\r\nText.SCREEN_COORDS = 1;\r\nText.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT = 2;\r\n\r\n// Layout enum\r\nText.LEFT_TO_RIGHT = 'ltr';\r\nText.RIGHT_TO_LEFT = 'rtl';\r\n\r\n// Alignment enum\r\nText.LEFT_TOP = 0;\r\nText.LEFT_CENTER = 1;\r\nText.LEFT_BOTTOM = 2;\r\n\r\nText.CENTER_TOP = 3;\r\nText.CENTER_CENTER = 4;\r\nText.CENTER_BOTTOM = 5;\r\n\r\nText.RIGHT_TOP = 6;\r\nText.RIGHT_CENTER = 7;\r\nText.RIGHT_BOTTOM = 8;\r\n\r\n/** @lends Text.prototype */\r\nutils.createPrototypeNode(\r\n Text,\r\n utils.objectInherit(AutoTransform.prototype, {\r\n drawText: function() {\r\n if (this._geometry !== undefined) {\r\n this._matrixTransform.removeChild(this._geometry);\r\n // The text could be dynamic, so we need to remove GL objects\r\n this._geometry.releaseGLObjects();\r\n }\r\n if (!this._text) return;\r\n this.setTextProperties();\r\n this._canvas.width = this._context.measureText(this._text).width;\r\n this._canvas.height = this._fontSize * 2;\r\n // For devices not supporting NPOT textures\r\n if (this._forcePowerOfTwo) {\r\n this._canvas.width = this._nextPowerOfTwo(this._canvas.width);\r\n this._canvas.height = this._nextPowerOfTwo(this._canvas.height);\r\n }\r\n // We need to set the text properties again, as the canvas size cold change.\r\n this.setTextProperties();\r\n this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);\r\n this._context.fillText(this._text, this._textX, this._textY);\r\n // Right now we set the pivot point to center, to assure the bounding box is correct when rendering billboards.\r\n // TODO: Possibility to set different pivot point so we can have missing alignments.\r\n var aspectRatio = this._canvas.width / this._canvas.height;\r\n var quadWidth = this._characterSize * aspectRatio;\r\n this._geometry = Shape.createTexturedQuadGeometry(-quadWidth / 2, -this._characterSize / 2,\r\n 0,\r\n quadWidth,\r\n 0,\r\n 0,\r\n 0,\r\n this._characterSize,\r\n 0\r\n );\r\n // create a texture to attach the canvas2D\r\n this._texture.setTextureSize(this._canvas.width, this._canvas.height);\r\n this._texture.setMinFilter('LINEAR');\r\n this._texture.setMagFilter('LINEAR');\r\n this._texture.setImage(this._canvas);\r\n // Transparency stuff\r\n var stateset = this._geometry.getOrCreateStateSet();\r\n stateset.setTextureAttributeAndModes(0, this._texture);\r\n stateset.setRenderingHint('TRANSPARENT_BIN');\r\n stateset.setAttributeAndModes(\r\n new BlendFunc(BlendFunc.ONE, BlendFunc.ONE_MINUS_SRC_ALPHA)\r\n );\r\n this._matrixTransform.addChild(this._geometry);\r\n this.dirtyBound();\r\n },\r\n\r\n setText: function(text) {\r\n this._text = text;\r\n // Canvas size could change so we need to make it dirty.\r\n this._dirty = true;\r\n },\r\n\r\n getText: function() {\r\n return this._text;\r\n },\r\n\r\n setFont: function(font) {\r\n this._font = font;\r\n this._dirty = true;\r\n },\r\n\r\n setColor: function(color) {\r\n this._color = color;\r\n // Convert color to html range\r\n this._fillStyle =\r\n 'rgba(' +\r\n Math.round(color[0] * 255) +\r\n ',' +\r\n Math.round(color[1] * 255) +\r\n ',' +\r\n Math.round(color[2] * 255) +\r\n ',' +\r\n color[3] +\r\n ')';\r\n this._context.fillStyle = this._fillStyle;\r\n // Canvas size does not change so we don't need to redo the quad.\r\n this._context.fillText(this._text, this._textX, this._textY);\r\n },\r\n\r\n getColor: function() {\r\n return this._color;\r\n },\r\n\r\n setCharacterSize: function(size) {\r\n this._characterSize = size;\r\n if (this._characterSizeMode !== Text.OBJECT_COORDS) {\r\n mat4.fromScaling(this._matrixTransform.getMatrix(), [\r\n this._characterSize,\r\n this._characterSize,\r\n this._characterSize\r\n ]);\r\n if (\r\n this._characterSizeMode ===\r\n Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT\r\n )\r\n this.setMaximumScale(this._characterSize);\r\n }\r\n this._dirty = true;\r\n },\r\n\r\n getCharacterSize: function() {\r\n return this._characterSize;\r\n },\r\n\r\n setCharacterSizeMode: function(mode) {\r\n this._characterSizeMode = mode;\r\n if (this._characterSizeMode !== Text.OBJECT_COORDS) {\r\n mat4.fromScaling(this._matrixTransform.getMatrix(), [\r\n this._characterSize,\r\n this._characterSize,\r\n this._characterSize\r\n ]);\r\n this.setAutoScaleToScreen(true);\r\n this.setMaximumScale(Number.MAX_VALUE);\r\n if (\r\n this._characterSizeMode ===\r\n Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT\r\n )\r\n this.setMaximumScale(this._characterSize);\r\n } else {\r\n this._matrixTransform.setMatrix(mat4.create());\r\n this.setAutoScaleToScreen(false);\r\n }\r\n this._dirty = true;\r\n },\r\n\r\n getCharacterSizeMode: function() {\r\n return this._characterSizeMode;\r\n },\r\n\r\n setFontResolution: function(resolution) {\r\n this._fontSize = resolution;\r\n this._dirty = true;\r\n },\r\n\r\n getFontResolution: function() {\r\n return this._fontSize;\r\n },\r\n\r\n setPosition: function(position) {\r\n this._position = position;\r\n mat4.fromTranslation(this.getMatrix(), position);\r\n },\r\n\r\n getPosition: function() {\r\n return this._position;\r\n },\r\n\r\n setTextProperties: function() {\r\n this._context.fillStyle = this._fillStyle;\r\n this._setAlignmentValues(this._alignment);\r\n this._context.font = this._fontSize + 'px ' + this._font;\r\n this._context.direction = this._layout;\r\n },\r\n\r\n setAutoRotateToScreen: function(value) {\r\n AutoTransform.prototype.setAutoRotateToScreen.call(this, value);\r\n this._dirty = true;\r\n },\r\n\r\n getAutoRotateToScreen: function() {\r\n return this._autoRotateToScreen;\r\n },\r\n\r\n setLayout: function(layout) {\r\n if (typeof layout === 'string') {\r\n this._layout = Text[layout];\r\n } else {\r\n this._layout = layout;\r\n }\r\n this._dirty = true;\r\n },\r\n getLayout: function() {\r\n return this._layout;\r\n },\r\n setAlignment: function(alignment) {\r\n if (typeof alignment === 'string') {\r\n this._alignment = Text[alignment];\r\n } else {\r\n this._alignment = alignment;\r\n }\r\n this._dirty = true;\r\n },\r\n getAlignment: function() {\r\n return this._alignment;\r\n },\r\n\r\n accept: (function() {\r\n return function(visitor) {\r\n if (this._dirty) {\r\n this.drawText();\r\n this._dirty = false;\r\n }\r\n if (visitor.getVisitorType() === NodeVisitor.CULL_VISITOR) {\r\n var width = visitor.getViewport().width();\r\n var height = visitor.getViewport().height();\r\n var projMat = visitor.getCurrentProjectionMatrix();\r\n var modelViewMat = visitor.getCurrentModelViewMatrix();\r\n var position = this._position;\r\n var doUpdate = this._firstTimeToInitEyePoint;\r\n\r\n if (!this._firstTimeToInitEyePoint) {\r\n if (!mat4.exactEquals(modelViewMat, this._previousModelView)) {\r\n doUpdate = true;\r\n } else if (\r\n width !== this._previousWidth ||\r\n height !== this._previousHeight\r\n ) {\r\n doUpdate = true;\r\n } else if (!mat4.exactEquals(projMat, this._previousProjection)) {\r\n doUpdate = true;\r\n } else if (!vec3.exactEquals(position, this._previousPosition)) {\r\n doUpdate = true;\r\n }\r\n }\r\n this._firstTimeToInitEyePoint = false;\r\n if (doUpdate) {\r\n if (this._autoScaleToScreen) {\r\n var viewport = visitor.getViewport();\r\n var psvector = this.computePixelSizeVector(\r\n viewport,\r\n projMat,\r\n modelViewMat\r\n );\r\n var v = vec4.fromValues(\r\n this._position[0],\r\n this._position[1],\r\n this._position[2],\r\n 1.0\r\n );\r\n var pixelSize = vec4.dot(v, psvector);\r\n pixelSize = 0.48 / pixelSize;\r\n var size = 1.0 / pixelSize;\r\n if (this._autoScaleTransitionWidthRatio > 0.0) {\r\n var c, b, a;\r\n if (this._minimumScale > 0.0) {\r\n var j = this._minimumScale;\r\n var i =\r\n this._maximumScale < Number.MAX_VALUE ?\r\n this._minimumScale +\r\n (this._maximumScale - this._minimumScale) *\r\n this._autoScaleTransitionWidthRatio :\r\n this._minimumScale *\r\n (1.0 + this._autoScaleTransitionWidthRatio);\r\n c = 1.0 / (4.0 * (i - j));\r\n b = 1.0 - 2.0 * c * i;\r\n a = j + b * b / (4.0 * c);\r\n var k = -b / (2.0 * c);\r\n if (size < k) size = this._minimumScale;\r\n else if (size < i) size = a + b * size + c * (size * size);\r\n }\r\n if (this._maximumScale < Number.MAX_VALUE) {\r\n var n = this._maximumScale;\r\n var m =\r\n this._minimumScale > 0.0 ?\r\n this._maximumScale +\r\n (this._minimumScale - this._maximumScale) *\r\n this._autoScaleTransitionWidthRatio :\r\n this._maximumScale *\r\n (1.0 - this._autoScaleTransitionWidthRatio);\r\n c = 1.0 / (4.0 * (m - n));\r\n b = 1.0 - 2.0 * c * m;\r\n a = n + b * b / (4.0 * c);\r\n var p = -b / (2.0 * c);\r\n\r\n if (size > p) size = this._maximumScale;\r\n else if (size > m) size = a + b * size + c * (size * size);\r\n }\r\n }\r\n this.setScale(size);\r\n }\r\n if (this._autoRotateToScreen) {\r\n var rotation = quat.create();\r\n var modelView = visitor.getCurrentModelViewMatrix();\r\n mat4.getRotation(rotation, modelView);\r\n this.setRotation(quat.invert(rotation, rotation));\r\n }\r\n this._previousWidth = width;\r\n this._previousHeight = height;\r\n vec3.copy(this._previousPosition, position);\r\n mat4.copy(this._previousProjection, projMat);\r\n mat4.copy(this._previousModelView, modelViewMat);\r\n }\r\n }\r\n\r\n Node.prototype.accept.call(this, visitor);\r\n };\r\n })(),\r\n _setAlignmentValues: function(alignment) {\r\n // Convert the OSG Api to js API\r\n switch (alignment) {\r\n case Text.LEFT_TOP:\r\n this._context.textAlign = 'left';\r\n this._textX = 0;\r\n this._context.textBaseline = 'top';\r\n this._textY = 0;\r\n break;\r\n case Text.LEFT_CENTER:\r\n this._context.textAlign = 'left';\r\n this._textX = 0;\r\n this._context.textBaseline = 'middle';\r\n this._textY = this._canvas.height / 2;\r\n break;\r\n case Text.LEFT_BOTTOM:\r\n this._context.textAlign = 'left';\r\n this._textX = 0;\r\n this._context.textBaseline = 'bottom';\r\n this._textY = this._canvas.height;\r\n break;\r\n case Text.CENTER_TOP:\r\n this._context.textAlign = 'center';\r\n this._textX = this._canvas.width / 2;\r\n this._context.textBaseline = 'top';\r\n this._textY = 0;\r\n break;\r\n case Text.CENTER_CENTER:\r\n this._context.textAlign = 'center';\r\n this._textX = this._canvas.width / 2;\r\n this._context.textBaseline = 'middle';\r\n this._textY = this._canvas.height / 2;\r\n break;\r\n case Text.CENTER_BOTTOM:\r\n this._context.textAlign = 'center';\r\n this._textX = this._canvas.width / 2;\r\n this._context.textBaseline = 'bottom';\r\n this._textY = this._canvas.height;\r\n break;\r\n case Text.RIGHT_TOP:\r\n this._context.textAlign = 'right';\r\n this._textX = this._canvas.width;\r\n this._context.textBaseline = 'top';\r\n this._textY = 0;\r\n break;\r\n case Text.RIGHT_CENTER:\r\n this._context.textAlign = 'right';\r\n this._textX = this._canvas.width;\r\n this._context.textBaseline = 'middle';\r\n this._textY = this._canvas.height / 2;\r\n break;\r\n case Text.RIGHT_BOTTOM:\r\n this._context.textAlign = 'right';\r\n this._textX = this._canvas.width;\r\n this._context.textBaseline = 'bottom';\r\n this._textY = this._canvas.height;\r\n break;\r\n }\r\n },\r\n setForcePowerOfTwo: function(value) {\r\n this._forcePowerOfTwo = value;\r\n },\r\n getForcePowerOfTwo: function() {\r\n return this._forcePowerOfTwo;\r\n },\r\n _nextPowerOfTwo: function(value) {\r\n var v = value;\r\n v--;\r\n v |= v >> 1;\r\n v |= v >> 2;\r\n v |= v >> 4;\r\n v |= v >> 8;\r\n v |= v >> 16;\r\n v++;\r\n return v;\r\n }\r\n }),\r\n 'osgText',\r\n 'Text'\r\n);\r\n\r\n// same code like Node\r\nCullVisitor.registerApplyFunction(\r\n Text.nodeTypeID,\r\n CullVisitor.getApplyFunction(AutoTransform.nodeTypeID)\r\n);\r\n\r\nexport default Text;","import P from 'bluebird';\r\nimport osgWrapper from './osg';\r\nimport notify from '../../osg/notify';\r\nimport Text from '../../osgText/Text';\r\n\r\nvar osgTextWrapper = {};\r\n\r\nosgTextWrapper.Text = function(input, node) {\r\n var jsonObj = input.getJSON();\r\n if (!jsonObj.Text) return P.reject();\r\n\r\n var promise = osgWrapper.Node(input, node);\r\n node.setColor(jsonObj.Color);\r\n node.setText(jsonObj.Text);\r\n node.setAutoRotateToScreen(jsonObj.AutoRotateToScreen);\r\n node.setPosition(jsonObj.Position);\r\n node.setCharacterSize(jsonObj.CharacterSize);\r\n\r\n if (jsonObj.Layout === 'VERTICAL') {\r\n notify.error('Vertical Alignment not supported');\r\n return P.reject();\r\n }\r\n var alignment = jsonObj.Alignment;\r\n if (jsonObj.Alignment.indexOf('BASE_LINE') > -1) {\r\n if (jsonObj.Alignment === 'LEFT_BASE_LINE') {\r\n alignment = Text.LEFT_CENTER;\r\n } else if (jsonObj.Alignment === 'CENTER_BASE_LINE') {\r\n alignment = Text.CENTER_CENTER;\r\n } else if (jsonObj.Alignment === 'RIGHT_BASE_LINE') {\r\n alignment = Text.RIGHT_CENTER;\r\n } else if (jsonObj.Alignment === 'LEFT_BOTTOM_BASE_LINE') {\r\n alignment = Text.LEFT_BOTTOM;\r\n } else if (jsonObj.Alignment === 'CENTER_BOTTOM_BASE_LINE') {\r\n alignment = Text.CENTER_BOTTOM;\r\n } else if (jsonObj.Alignment === 'RIGHT_BOTTOM_BASE_LINE') {\r\n alignment = Text.RIGHT_BOTTOM;\r\n }\r\n /*develblock:start*/\r\n notify.log('Base line alignments not supported, alignment converted');\r\n /*develblock:end*/\r\n }\r\n node.setAlignment(alignment);\r\n node.setLayout(jsonObj.Layout);\r\n\r\n return promise;\r\n};\r\n\r\nexport default osgTextWrapper;\r\n","import utils from '../osg/utils';\r\nimport Input from './Input';\r\nimport ReaderParser from './readerParser';\r\nimport DatabasePager from './DatabasePager';\r\nimport osgWrappers from '../osgWrappers/serializers/osg';\r\nimport osgAnimationWrappers from '../osgWrappers/serializers/osgAnimation';\r\nimport osgTextWrappers from '../osgWrappers/serializers/osgText';\r\nimport Registry from './Registry';\r\nimport fileHelper from './fileHelper';\r\nimport requestFile from './requestFile';\r\nimport zlib from './zlib';\r\n\r\nvar osgDB = {};\r\nosgDB.Input = Input;\r\nutils.objectMix(osgDB, ReaderParser);\r\nosgDB.DatabasePager = DatabasePager;\r\nosgDB.ObjectWrapper.serializers.osg = osgWrappers;\r\nosgDB.ObjectWrapper.serializers.osgAnimation = osgAnimationWrappers;\r\nosgDB.ObjectWrapper.serializers.osgText = osgTextWrappers;\r\nosgDB.Registry = Registry;\r\nosgDB.fileHelper = fileHelper;\r\nosgDB.requestFile = requestFile;\r\n\r\nutils.objectMix(osgDB, zlib);\r\n\r\nexport default osgDB;\r\n","import NodeVisitor from \"../../osg/NodeVisitor\";\r\nimport Geometry from \"../../osg/Geometry\";\r\n\r\nclass ShoeNodeVisitor extends NodeVisitor {\r\n constructor() {\r\n super();\r\n // this.cb = cb;\r\n this.left = null; //{node, geoms:[{name, geom}] }\r\n\r\n this.right = null; //[]; //右脚节点\r\n\r\n this.geoms = []; //为定义left, right的节点\r\n }\r\n\r\n getNodeName(node) {\r\n let name = node.getName();\r\n if (!name) return \"\";\r\n\r\n name = name.split(\"_\")[0];\r\n if (!name) {\r\n return \"\";\r\n }\r\n\r\n return name.toLowerCase();\r\n }\r\n\r\n apply(node) {\r\n //if (node instanceof Geometry) {\r\n // this.cb(node);\r\n let name = this.getNodeName(node);\r\n if (!name) {\r\n this.traverse(node);\r\n return;\r\n }\r\n let isGeom = node instanceof Geometry;\r\n\r\n if (name == \"left\" && !isGeom) {\r\n if (!this.left) {\r\n this.left = { node, geoms: [] }\r\n }\r\n }\r\n if (name == \"right\" && !isGeom) {\r\n if (!this.right) {\r\n this.right = { node, geoms: [] }\r\n }\r\n }\r\n\r\n if (isGeom) {\r\n let paths = this.getNodePath();\r\n let n = paths.length - 1;\r\n let parentLeft = false;\r\n let parentRight = false;\r\n for (let i = 0; i < n; i++) {\r\n let parentName = this.getNodeName(paths[i]);\r\n parentRight = parentName == \"right\";\r\n parentLeft = parentName == \"left\";\r\n if (parentRight || parentLeft) break;\r\n }\r\n if (parentRight) {\r\n this.right.geoms.push({ name, geom: node });\r\n } else if (parentLeft) {\r\n this.left.geoms.push({ name, geom: node });\r\n } else {\r\n this.geoms.push({ name, geom: node })\r\n }\r\n }\r\n\r\n this.traverse(node);\r\n }\r\n}\r\n\r\nexport { ShoeNodeVisitor }","const defaultColor = [0.509803950786591, 0.474509835243225, 0.474509835243225];\r\nconst _defaultTexture = { url: \"\", size: 0 };\r\n\r\nconst maps = {\r\n uvtransform: \"uvtransform\",\r\n NormalMap: \"normal\",\r\n Albedo: \"albedo\",\r\n MetalnessPBR: \"metalness\",\r\n Roughness: \"roughness\",\r\n Opacity: \"opacity\",\r\n SpecularMap: \"specular\",\r\n\r\n};\r\n\r\nconst defaultConfig = {\r\n type: \"meta\",\r\n diffuse: {\r\n color: defaultColor,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n specular: {\r\n color: defaultColor,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n gloss: {\r\n factor: 0,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n\r\n albedo: {\r\n color: defaultColor,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n cullFace: \"\",\r\n metalness: {\r\n factor: 0,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n normal: {\r\n factor: 1,\r\n texture: _defaultTexture,\r\n },\r\n displace: {\r\n enable: false,\r\n factor: 1,\r\n texture: _defaultTexture,\r\n },\r\n opacity: {\r\n enable: false,\r\n factor: 1,\r\n texture: _defaultTexture,\r\n },\r\n roughness: {\r\n factor: 1,\r\n texture: _defaultTexture,\r\n useTexture: false,\r\n },\r\n \r\n uv: { scale: 1, rotate: 0, offsetX: 0, offsetY: 0 },\r\n uvProjection: true,\r\n uvMap:\"box\",\r\n};\r\n\r\nexport function createMaterial(data: any) {\r\n const res: any = {};\r\n const defaultConf = JSON.parse( JSON.stringify(defaultConfig));\r\n if (!data) return defaultConf;\r\n\r\n for (const key in defaultConf) {\r\n const attrGroup = data[key];\r\n\r\n if (typeof attrGroup == \"object\") {\r\n if (attrGroup?.texture?.url && attrGroup?.useTexture == null) {\r\n attrGroup.useTexture = true;\r\n }\r\n const attrDefault: any = defaultConf[key as keyof typeof defaultConf];\r\n\r\n for (const k in attrGroup) {\r\n if (attrGroup[k] != undefined || attrGroup[k] != null) {\r\n attrDefault[k] = attrGroup[k];\r\n }\r\n }\r\n res[key] = { ...attrDefault };\r\n } else if (attrGroup) {\r\n res[key] = attrGroup;\r\n }\r\n }\r\n return { ...data, ...res };\r\n}\r\n\r\nexport function createRenderMaterial(data: any): Material {\r\n const result: any = { AO: {}, cullFace: \"\", MetalnessWorkFlow: false };\r\n\r\n for (const key in maps) {\r\n const rk = maps[key as keyof typeof maps];\r\n if (rk) {\r\n const attr: any = data[rk] || defaultConfig[rk as keyof typeof defaultConfig] || {};\r\n const { texture, useTexture, ...restAttr } = attr;\r\n result[key] = texture && useTexture ? { texture, ...restAttr } : restAttr;\r\n }\r\n }\r\n const { cullFace, MetalnessWorkFlow, uvtransform, ...channels } = result;\r\n return { cullFace, MetalnessWorkFlow, uvtransform, channels };\r\n}\r\n\r\ntype Material = {\r\n cullFace: string;\r\n MetalnessWorkFlow: boolean;\r\n channels: {\r\n Albedo: {\r\n color: number[];\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n MetalnessPBR: {\r\n factor: number;\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n NormalMap: {\r\n factor: number;\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n Opacity: {\r\n factor: number;\r\n enable: boolean;\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n Roughness: {\r\n factor: number;\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n SpecularMap: {\r\n color: number[];\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n };\r\n };\r\n uvtransform: {\r\n scale: number;\r\n rotate: number;\r\n offsetX: number;\r\n offsetY: number;\r\n };\r\n};\r\n\r\n// const result = {\r\n// channels: {\r\n// AO: {},\r\n// Albedo: {\r\n// color: [0.509803950786591, 0.474509835243225, 0.474509835243225],\r\n// texture: _defaultTexture,\r\n// },\r\n// MetalnessPBR: {\r\n// factor: 0,\r\n// texture: _defaultTexture,\r\n// },\r\n// NormalMap: {\r\n// factor: 1,\r\n// texture: _defaultTexture,\r\n// },\r\n// Opacity: {\r\n// enable: false,\r\n// factor: 1,\r\n// texture: _defaultTexture,\r\n// },\r\n// Roughness: {\r\n// factor: 1,\r\n// texture: _defaultTexture,\r\n// },\r\n// },\r\n// uvtransform: { scale: 1, rotate: 0, offsetX: 0, offsetY: 0 },\r\n// };\r\n\r\n// const keyMap = {\r\n// uvtransform: \"uvtransform\",\r\n// normal: \"NormalMap\",\r\n// albedo: \"Albedo\",\r\n// metalness: \"MetalnessPBR\",\r\n// roughness: \"Roughness\",\r\n// opacity: \"Opacity\",\r\n// specular: \"SpecularMap\",\r\n// };\r\nexport function createNativeMat2(colorCardConf: any) {\r\n \r\n const mat = createTextureMat({url:\"\", size:0});\r\n if (!colorCardConf ) {\r\n return mat;\r\n }\r\n \r\n const mat3d = colorCardConf;\r\n mat.metalnessWorkFlow = (mat3d.type != \"spec\");\r\n \r\n if (mat3d.type == \"spec\") {\r\n mat.channels.Albedo.color = mat3d.diffuse.color;\r\n if (mat3d.diffuse.useTexture) {\r\n mat.channels.Albedo.texture = mat3d.diffuse.texture;\r\n }\r\n \r\n mat.channels.Roughness.factor = mat3d.gloss.factor\r\n if (mat3d.gloss.useTexture) {\r\n mat.channels.Roughness.texture = mat3d.gloss.texture\r\n }\r\n \r\n //@ts-ignore\r\n mat.channels.MetalnessPBR.factor = mat3d.specular.color || [0,0,0]\r\n if (mat3d.specular.useTexture ) {\r\n mat.channels.MetalnessPBR.texture = mat3d.specular.texture;\r\n }\r\n \r\n } else { //这里是金属流实现\r\n mat.channels.Albedo.color = mat3d.albedo.color;\r\n if (mat3d.albedo.useTexture) {\r\n mat.channels.Albedo.texture = mat3d.albedo.texture;\r\n }\r\n \r\n mat.channels.Roughness.factor = mat3d.roughness.factor\r\n if (typeof mat3d.roughness.factor !== 'number') {\r\n mat.channels.Roughness.factor = 1;\r\n }\r\n \r\n if (mat3d.roughness.useTexture) {\r\n mat.channels.Roughness.texture = mat3d.roughness.texture\r\n }\r\n \r\n mat.channels.MetalnessPBR.factor = mat3d.metalness.factor || 0\r\n \r\n if (mat3d.metalness.useTexture ) {\r\n mat.channels.MetalnessPBR.texture = mat3d.metalness.texture;\r\n }\r\n }\r\n \r\n if (mat3d.uv) {\r\n //@ts-ignore\r\n mat.uvtransform = mat3d.uv;\r\n }\r\n if (mat3d.cusUv) {\r\n if (mat3d.cusUv.offsetX) mat.uvtransform.offsetX += mat3d.cusUv.offsetX;\r\n if (mat3d.cusUv.offsetY) mat.uvtransform.offsetY += mat3d.cusUv.offsetY;\r\n if (mat3d.cusUv.rotate ) mat.uvtransform.rotate += mat3d.cusUv.rotate;\r\n \r\n if (mat3d.cusUv.scale) {\r\n const orginScale = mat.uvtransform.scale;\r\n let scale = mat3d.cusUv.scale;\r\n if (scale < 0) {\r\n //放大\r\n scale = (1 - 0.9 * scale) * orginScale;\r\n } else {\r\n //缩小\r\n scale = orginScale * (1 - 0.09 * scale);\r\n }\r\n mat.uvtransform.scale = scale;\r\n }\r\n }\r\n \r\n if (mat3d.normal) {\r\n mat.channels.NormalMap.enable = true;\r\n mat.channels.NormalMap.texture = mat3d.normal.texture;\r\n }\r\n \r\n if (mat3d.displace && mat3d.displace.enable) {\r\n mat.channels.Displacement.enable = true;\r\n mat.channels.Displacement.texture = mat3d.displace.texture;\r\n mat.channels.Displacement.factor = mat3d.displace.factor;\r\n }\r\n \r\n if(mat3d.opacity && mat3d.opacity.enable) {\r\n mat.channels.Opacity.enable = true\r\n mat.channels.Opacity.factor = mat3d.opacity.factor;\r\n mat.channels.Opacity.texture = mat3d.opacity.texture;\r\n }\r\n \r\n mat.uvProjection = mat3d.uvProjection;\r\n if (mat.uvProjection == undefined) {\r\n if (!mat3d.uvMap) {\r\n mat.uvProjection = true; //默认box映射\r\n } else {\r\n mat.uvProjection = mat3d.uvMap == \"box\"\r\n }\r\n }\r\n return mat\r\n}\r\n\r\nexport function createNativeMat(colorCardConf: any): any {\r\n\r\n const mat3d = colorCardConf;\r\n\r\n const mat = createTextureMat(mat3d?.baseMap);\r\n if (!colorCardConf ) {\r\n return mat;\r\n }\r\n\r\n mat.metalnessWorkFlow = (mat3d.type != \"spec\");\r\n\r\n if (mat3d.uv) {\r\n //@ts-ignore\r\n mat.uvtransform = mat3d.uv;\r\n }\r\n\r\n if (mat3d.cusUv) {\r\n if (mat3d.cusUv.offsetX) mat.uvtransform.offsetX += mat3d.cusUv.offsetX;\r\n if (mat3d.cusUv.offsetY) mat.uvtransform.offsetY += mat3d.cusUv.offsetY;\r\n if (mat3d.cusUv.rotate ) mat.uvtransform.rotate += mat3d.cusUv.rotate;\r\n\r\n if (mat3d.cusUv.scale) {\r\n const orginScale = mat.uvtransform.scale;\r\n let scale = mat3d.cusUv.scale;\r\n if (scale < 0) {\r\n //放大\r\n scale = (1 - 0.9 * scale) * orginScale;\r\n } else {\r\n //缩小\r\n scale = orginScale * (1 - 0.09 * scale);\r\n }\r\n mat.uvtransform.scale = scale;\r\n }\r\n }\r\n \r\n console.log(\"uvtransform=>\", mat.uvtransform);\r\n\r\n mat.channels.Albedo.color = mat3d.baseColor;\r\n\r\n if (mat3d.normalMap && mat3d.normalMap.url) {\r\n mat.channels.NormalMap.enable = true;\r\n mat.channels.NormalMap.texture = mat3d.normalMap;\r\n }\r\n\r\n if (mat3d.roughMap) {\r\n mat.channels.Roughness.texture = mat3d.roughMap;\r\n }\r\n\r\n mat.channels.Roughness.factor = typeof mat3d.roughFactor === 'number'? mat3d.roughFactor : 1;\r\n \r\n\r\n if (mat3d.metalMap) {\r\n mat.channels.MetalnessPBR.texture = mat3d.metalMap;\r\n }\r\n\r\n mat.channels.MetalnessPBR.factor = typeof mat3d.metalFactor === 'number' ? mat3d.metalFactor : 0\r\n \r\n\r\n\r\n if (mat3d.normal && mat3d.normal.url) {\r\n mat.channels.NormalMap.enable = true;\r\n mat.channels.NormalMap.texture = mat3d.normal;\r\n }\r\n\r\n if (mat3d.displaceMap && mat3d.displaceMap.url) {\r\n mat.channels.Displacement.enable = true;\r\n mat.channels.Displacement.texture = mat3d.displaceMap;\r\n mat.channels.Displacement.factor = mat3d.displaceFactor;\r\n }\r\n\r\n if (mat3d.type == \"spec\") {\r\n mat.channels.Albedo.color = mat3d.diffuseColor;\r\n mat.channels.Albedo.texture = mat3d.diffuseMap;\r\n\r\n mat.channels.Roughness.factor = (typeof mat3d.glossFactor === 'number') ? mat3d.glossFactor : 0;\r\n mat.channels.Roughness.texture = mat3d.glossMap;\r\n\r\n mat.channels.MetalnessPBR.factor = (mat3d.specColor instanceof Array) ? mat3d.specColor : [0, 0, 0];\r\n mat.channels.MetalnessPBR.texture = mat3d.specMap;\r\n }\r\n\r\n\r\n mat.channels.Opacity.factor = 1.0\r\n mat.channels.Opacity.enable = false\r\n if(mat3d.opacFactor != undefined && mat3d.opacFactor != null && mat3d.opacFactor < 1.0 ) {\r\n mat.channels.Opacity.enable = true\r\n mat.channels.Opacity.factor = mat3d.opacFactor;\r\n } \r\n \r\n if (mat3d.opacMap && mat3d.opacMap.url ) {\r\n mat.channels.Opacity.enable = true\r\n mat.channels.Opacity.texture = mat3d.opacMap;\r\n }\r\n\r\n mat.uvProjection = mat3d.uvProjection;\r\n if (mat.uvProjection == undefined) {\r\n if (!mat3d.uvMap) {\r\n mat.uvProjection = true; //默认映射\r\n } else {\r\n mat.uvProjection = mat3d.uvMap == \"box\"\r\n }\r\n }\r\n return mat\r\n}\r\n\r\nconst _defaultText = {\r\n url: \"\",\r\n size: 0,\r\n}\r\n\r\nexport default function createTextureMat(image:{url:string, size:number}) {\r\n \r\n return {\r\n cullFace: \"\",\r\n metalnessWorkFlow: true,\r\n uvProjection:true,\r\n uvtransform: {offsetX: 0, offsetY: 0, rotate: 0, scale: 1},\r\n channels: {\r\n Albedo: {\r\n color: [0.509803950786591, 0.474509835243225, 0.474509835243225],\r\n texture: image\r\n },\r\n Roughness: {\r\n factor: 1,\r\n invert: false,\r\n texture: {..._defaultText}\r\n },\r\n \r\n Emissive: {\r\n color: [0, 0, 0],\r\n factor: 1,\r\n enable: false\r\n },\r\n \r\n NormalMap: {\r\n enable: true,\r\n factor: 1,\r\n flipY: false,\r\n texture: {..._defaultText},\r\n },\r\n \r\n \r\n BumpMap: {\r\n enable: false,\r\n factor: 1,\r\n texture: {..._defaultText}\r\n },\r\n \r\n Opacity: {\r\n enable: false,\r\n type: \"ALPHA_BLEND\",\r\n factor: 1,\r\n invert: false,\r\n sampleChannel: \"a\",\r\n refractionTint: [1, 1, 1],\r\n refractUseDiffuse: false,\r\n refractUseShininessMap: false,\r\n IOR: 1,\r\n roughnessFactor: 0,\r\n texture: {..._defaultText}\r\n },\r\n \r\n AO: {\r\n enable: false,\r\n occludeSpecular: false,\r\n factor: 0,\r\n texture: {..._defaultText}\r\n },\r\n \r\n MetalnessPBR: {\r\n factor: 0,\r\n texture: {..._defaultText}\r\n },\r\n SpecularF0: 0.5,\r\n ClearCoat: {\r\n enable: false,\r\n thickness: 5,\r\n intensity: 1,\r\n color: [1, 1, 1],\r\n reflectivity: 0,\r\n roughness: {\r\n factor: 0.04,\r\n },\r\n normalmap: {\r\n factor: 1,\r\n flipY: false,\r\n }\r\n },\r\n Displacement: {\r\n enable: false,\r\n factor: 0,\r\n texture: {..._defaultText}\r\n },\r\n CavityMap: {\r\n enable: false,\r\n factor: 0,\r\n }\r\n }\r\n }\r\n}","export function createDefaultEvn3d() {\r\n return {\r\n id: \"1\",\r\n name:\"工作室\",\r\n cusNum:\"\",\r\n thumbnail:{\r\n url: \"\",\r\n size: 0,\r\n },\r\n createTime:null,\r\n hdr:{\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/photo_studio_01_8k.hdr\",\r\n \"size\": 100350789\r\n },\r\n config: {\r\n \"textures\": [{\r\n \"images\": [{\r\n \"width\": 256,\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg\",\r\n \"height\": 128,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg\",\r\n \"size\": \"15905\"\r\n }\r\n }],\r\n \"encoding\": \"srgb\",\r\n \"type\": \"thumbnail\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1779853,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz\",\r\n \"size\": \"1779853\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1200968,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz\",\r\n \"size\": \"1200968\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 317622,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz\",\r\n \"size\": \"317622\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 97956,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz\",\r\n \"size\": \"97956\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 29064,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz\",\r\n \"size\": \"29064\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"luv\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 2977192,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz\",\r\n \"size\": \"2977192\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1858076,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz\",\r\n \"size\": \"1858076\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 487212,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz\",\r\n \"size\": \"487212\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 149136,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz\",\r\n \"size\": \"149136\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 46566,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz\",\r\n \"size\": \"46566\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 3043958,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz\",\r\n \"size\": \"3043958\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 6291456,\r\n \"sizeCompressed\": 1766005,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz\",\r\n \"size\": \"1766005\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 1572864,\r\n \"sizeCompressed\": 473185,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz\",\r\n \"size\": \"473185\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 393216,\r\n \"sizeCompressed\": 149500,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz\",\r\n \"size\": \"149500\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 98304,\r\n \"sizeCompressed\": 49221,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz\",\r\n \"size\": \"49221\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz\",\r\n \"sizeUncompressed\": 18874368,\r\n \"sizeCompressed\": 16116615,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz\",\r\n \"size\": \"16116615\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz\",\r\n \"sizeUncompressed\": 18874368,\r\n \"sizeCompressed\": 16067477,\r\n \"height\": 512,\r\n \"width\": 512,\r\n \"samples\": 2048,\r\n \"blur\": 0.02,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz\",\r\n \"size\": \"16067477\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz\",\r\n \"sizeUncompressed\": 4718592,\r\n \"sizeCompressed\": 4041881,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"samples\": 2048,\r\n \"blur\": 0.055,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz\",\r\n \"size\": \"4041881\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz\",\r\n \"sizeUncompressed\": 1179648,\r\n \"sizeCompressed\": 1020352,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"samples\": 2048,\r\n \"blur\": 0.1,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz\",\r\n \"size\": \"1020352\"\r\n }\r\n },\r\n {\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz\",\r\n \"sizeUncompressed\": 294912,\r\n \"sizeCompressed\": 258568,\r\n \"height\": 64,\r\n \"width\": 64,\r\n \"samples\": 2048,\r\n \"blur\": 0.15,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz\",\r\n \"size\": \"258568\"\r\n }\r\n }\r\n ],\r\n \"encoding\": \"float\",\r\n \"type\": \"background\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 673838,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz\",\r\n \"size\": \"673838\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"luv\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 1095123,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz\",\r\n \"size\": \"1095123\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 4194304,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 1130918,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz\",\r\n \"size\": \"1130918\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz\",\r\n \"sizeUncompressed\": 12582912,\r\n \"samples\": 2048,\r\n \"height\": 1024,\r\n \"width\": 1024,\r\n \"sizeCompressed\": 7099449,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz\",\r\n \"size\": \"7099449\"\r\n }\r\n }],\r\n \"limitSize\": 32,\r\n \"encoding\": \"float\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"panorama\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 635016,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz\",\r\n \"size\": \"635016\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"luv\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 1055995,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz\",\r\n \"size\": \"1055995\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"rgbm\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz\",\r\n \"sizeUncompressed\": 2097144,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 1109686,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz\",\r\n \"size\": \"1109686\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"rgbe\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz\",\r\n \"sizeUncompressed\": 6291432,\r\n \"samples\": 2048,\r\n \"height\": 256,\r\n \"width\": 256,\r\n \"sizeCompressed\": 5417781,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz\",\r\n \"size\": \"5417781\"\r\n }\r\n }],\r\n \"limitSize\": 8,\r\n \"encoding\": \"float\",\r\n \"type\": \"specular_ue4\",\r\n \"format\": \"cubemap\"\r\n },\r\n {\r\n \"images\": [{\r\n \"file\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz\",\r\n \"sizeUncompressed\": 65536,\r\n \"samples\": 2048,\r\n \"height\": 128,\r\n \"width\": 128,\r\n \"sizeCompressed\": 59665,\r\n \"oss\": {\r\n \"url\": \"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz\",\r\n \"size\": \"59665\"\r\n }\r\n }],\r\n \"encoding\": \"rg16\",\r\n \"type\": \"brdf_ue4\",\r\n \"format\": \"lut\"\r\n }\r\n ],\r\n \"writeByChannel\": true,\r\n \"lights\": [{\r\n \"direction\": [\r\n 0.0331058, -0.82285,\r\n 0.567294\r\n ],\r\n \"lum_ratio\": 0.0797674,\r\n \"color\": [\r\n 43.9513,\r\n 47.0473,\r\n 49.9592\r\n ],\r\n \"luminosity\": 508.628,\r\n \"sum\": 0.74215,\r\n \"area\": {\r\n \"y\": 0.192383,\r\n \"x\": 0.490723,\r\n \"w\": 0.0166016,\r\n \"h\": 0.0878906\r\n },\r\n \"error\": 0,\r\n \"variance\": 0.00071996\r\n }],\r\n \"diffuseSPH\": [\r\n 2.52177,\r\n 2.6475,\r\n 2.71793, -0.970495, -1.03103, -1.07638, -0.517793, -0.556958, -0.594671, -0.335999, -0.36003, -0.390184,\r\n 0.14915,\r\n 0.157474,\r\n 0.170339,\r\n 0.305085,\r\n 0.325537,\r\n 0.345122, -0.000786492, -0.00349557, -0.00655254, -0.000955614, -0.000445611,\r\n 0.00699492, -0.00675775, -0.0107802, -0.0170637,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0,\r\n 0, -0.0128212, -0.0135017, -0.0145362,\r\n 0.0321759,\r\n 0.0344156,\r\n 0.0357341,\r\n 0.010143,\r\n 0.0108799,\r\n 0.0117446,\r\n 0.0164007,\r\n 0.0178076,\r\n 0.0192644,\r\n 0.0183598,\r\n 0.0198073,\r\n 0.0203541,\r\n 0.00825731,\r\n 0.00872035,\r\n 0.0094819,\r\n 0.0411866,\r\n 0.044173,\r\n 0.0463374,\r\n 0.0160459,\r\n 0.0171311,\r\n 0.0176568, -0.0096879, -0.0103498, -0.00986728\r\n ]\r\n },\r\n options:{\r\n rotation:202,\r\n exposure:1.2,\r\n },\r\n toneMap: {\r\n method: 1,\r\n exposure: 1.0,\r\n brightness: 0.1,\r\n contrast: 0.06,\r\n saturation: 1.0,\r\n },\r\n background:null,\r\n userData:{},\r\n }\r\n}","import {createDefaultEvn3d} from \"./scenePackageEn3d\";\r\n\r\nexport function createDefaultScenePackage() {\r\n return {\r\n version: \"1.0\",\r\n mats: [{\r\n id: \"1\",\r\n thumbnail:null,\r\n name: \"基础色\",\r\n cusNum: \"xx\",//编号\r\n normalMap: null,\r\n displaceMap: null,\r\n displaceFactor: 0,\r\n baseMap: null,\r\n baseColor: [0,1,0],\r\n roughMap:null,\r\n roughFactor: 0.5,\r\n metalMap:null,\r\n metalFactor: 0,\r\n diffuseMap: null,\r\n diffuseColor: [0,0,0],\r\n glossMap: null,\r\n glossFactor: 0,\r\n specMap: null,\r\n specColor: null,\r\n techMaterial:null,\r\n images: [],\r\n opacMap: null,\r\n opacFactor: 1,\r\n type: \"meta\",\r\n uv: null,\r\n cusUv: null,\r\n userData:{},\r\n }], //材质球\r\n geoms: [\r\n {\r\n id: \"1\",\r\n name:\"cube\",\r\n thumbnail:{\r\n url:\"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/image/jpeg/1654055769653AUoutq_mf6O4k.image/jpeg\",\r\n size: 1,\r\n },\r\n osgjs:{\r\n url:\"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/upload/osgjs/1654056232504W6qHX6_1654056227380.glb.osgjs\",\r\n size: 2,\r\n },\r\n file:{\r\n url: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/fbx/1654075876597asa7I2_box.fbx\",\r\n size: 26284\r\n },\r\n\r\n glb: {\r\n url: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/glb/1654075876532OlNLjF_1654075872416.glb\",\r\n size: 4240\r\n },\r\n shadow:{\r\n url:\"\",\r\n size: 0,\r\n },\r\n boundingBox:{\r\n max: {x: 100, y: 100.00001629206662, z: 100.00001629206662},\r\n min: {x: -100, y: -100.00001629206662, z: -100.00001629206662},\r\n },\r\n }\r\n ], //几何体\r\n env3ds: [\r\n createDefaultEvn3d()\r\n ],//3d 环境\r\n\r\n products: [\r\n {\r\n id: \"1\",\r\n geomId:\"1\",\r\n name:\"cube\",\r\n cusNum:\"bh001\",\r\n type: \"shoe\", //类型\r\n thumbnail:{\r\n url:\"\",\r\n size: 0,\r\n },\r\n components:[],\r\n userData:{},\r\n }\r\n ],\r\n scenes: [\r\n {\r\n id:\"001\",\r\n name:\"scene01\",\r\n thumbnail:{\r\n url:\"\",\r\n size:0,\r\n },\r\n envId: \"1\",\r\n lights:[],\r\n products:[\r\n {\r\n id:\"1\",\r\n prodId:\"1\",\r\n transform:{\r\n pos:[0,0,0],\r\n scale:[1,1,1],\r\n rotation:[0,0,0,1],\r\n },\r\n visible:true,\r\n userData:{},\r\n }\r\n ],\r\n userData:null,\r\n }\r\n ],\r\n userData:{}\r\n }\r\n}","import defaultEnv3d from './defaultEnv3d';\r\n\r\nexport class Env3dObj {\r\n private _app: any;\r\n private get app() {\r\n return this._app.getAppInstance();\r\n }\r\n\r\n constructor(app: any) {\r\n this._app = app;\r\n }\r\n\r\n setDefaultEnv3d() {\r\n this.setEnv3d(defaultEnv3d.config);\r\n }\r\n\r\n setEnv3d(data: any) {\r\n if (!this.app) return;\r\n\r\n this.app.setEnvironmentModel(data);\r\n this.app.redraw();\r\n }\r\n\r\n setRotation(v: number) {\r\n if (!this.app) return;\r\n\r\n this.app.setEnvironmentRotation((v * Math.PI) / 180);\r\n this.app.redraw();\r\n }\r\n\r\n setExposure(v: number) {\r\n if (!this.app) return;\r\n\r\n this.app.setEnvironmentExposure(v);\r\n this.app.redraw();\r\n }\r\n\r\n setEnv3dOption(rotation: number, exposure: number) {\r\n if (!this.app) return;\r\n\r\n this.app.setEnvironmentRotation((rotation * Math.PI) / 180);\r\n this.app.setEnvironmentExposure(exposure);\r\n this.app.redraw();\r\n }\r\n\r\n setEnvToneMap(toneMap: any) {\r\n if (!this.app) return;\r\n\r\n this.app.setToneMappingExposure(toneMap.exposure == undefined ? 1 : toneMap.exposure);\r\n this.app.setToneMappingBrightness(toneMap.brightness == undefined ? 0 : toneMap.brightness);\r\n this.app.setToneMappingContrast(toneMap.contrast == undefined ? 0: toneMap.contrast);\r\n this.app.setToneMappingSaturation(toneMap.saturation == undefined ? 1: toneMap.saturation);\r\n this.app.setToneMappingMethod(toneMap.method == undefined ? 1: toneMap.method);\r\n this.app.redraw();\r\n }\r\n}\r\n","import { isPc } from '@queenjs/utils';\r\nimport { Application } from '../../queen';\r\n\r\nexport class Picker {\r\n private _app: Application;\r\n private _touchTime = 0;\r\n private _touchPos: any = {};\r\n private _target: any = null;\r\n private _rect: any = null;\r\n private _picking = false;\r\n\r\n options: any\r\n enable = true;\r\n\r\n constructor(app: Application, options:{clickedOutline:boolean}) {\r\n this._app = app;\r\n this.initEvent();\r\n this.options = options;\r\n }\r\n\r\n private initEvent() {\r\n const isMobile = !isPc();\r\n const touchEvent = {\r\n start: isMobile ? 'touchstart' : 'mousedown',\r\n end: isMobile ? 'touchend' : 'mouseup',\r\n };\r\n\r\n this._app.setOutLine(null, { durationHighlight: 300 });\r\n\r\n // 阻止默认右键菜单选项\r\n window.addEventListener('contextmenu', function (e) {\r\n e.preventDefault();\r\n });\r\n\r\n // 添加触摸画布监听事件\r\n this._app._canvas.addEventListener(touchEvent.start, (e:any) => {\r\n e.preventDefault();\r\n if (!this.enable) return;\r\n\r\n this._touchTime = Date.now();\r\n window.addEventListener(touchEvent.end, evtTouchClick, false);\r\n this._touchPos = getPos(e);\r\n this.setCanvasRect();\r\n if (\r\n document.activeElement &&\r\n document.activeElement.tagName.toLowerCase() === 'input'\r\n ) {\r\n //@ts-ignore\r\n document.activeElement.blur();\r\n }\r\n });\r\n\r\n const evtTouchClick = (e:any) => {\r\n window.removeEventListener(touchEvent.end, evtTouchClick, false);\r\n if (!this.enable) return;\r\n \r\n const endPos = getPos(e);\r\n if (\r\n Date.now() - this._touchTime <= 300 &&\r\n Math.abs(endPos.clientX - this._touchPos.clientX) < 2 &&\r\n Math.abs(endPos.clientY - this._touchPos.clientY) < 2\r\n )\r\n \r\n this.pick(true);\r\n if (this._target ) {\r\n setTimeout(() => {\r\n this._target = null;\r\n }, 1000); //分钟后清除target\r\n }\r\n };\r\n\r\n function getPos(e:any) {\r\n if (isMobile) {\r\n return e.changedTouches[0];\r\n } else {\r\n return e;\r\n }\r\n }\r\n }\r\n\r\n setTouchPos(pos:any) {\r\n this._touchPos = pos;\r\n }\r\n\r\n getCanvsPos() {\r\n const { _rect, _touchPos } = this;\r\n return [_touchPos.clientX - _rect.left, _touchPos.clientY - _rect.top];\r\n }\r\n\r\n setCanvasRect() {\r\n this._rect = this._app._canvas.getBoundingClientRect();\r\n }\r\n\r\n getPickTarget() {\r\n return this._target;\r\n }\r\n\r\n clearPickTarget() {\r\n this._target = null;\r\n }\r\n\r\n pick(clicked=false) {\r\n const outline = this.options?.clickedOutline;\r\n if (this._picking ) return;\r\n \r\n this._picking = true;\r\n const scope = this;\r\n this._app.pick(...this.getCanvsPos(), (geom:any) => {\r\n scope._picking = false;\r\n if (scope._target === geom) return;\r\n if (geom && outline) {\r\n scope._app.setOutLine(geom.getOrCreateStateSet());\r\n }\r\n scope._target = geom;\r\n scope._app.emit('tap:click', geom, clicked);\r\n });\r\n }\r\n}\r\n","\r\nimport { Bus, Application as QueenApplication, } from '../../queen';\r\nimport { Env3dObj } from './Env3d';\r\nimport { Picker } from './picker';\r\n\r\nexport function createApp(){\r\n return new Application();\r\n}\r\n\r\nexport class Application extends Bus {\r\n private _app: QueenApplication | null = null;\r\n canvas: HTMLElement | null = null;\r\n env3d = new Env3dObj(this);\r\n picker?:Picker\r\n getDefaultEnvHandle?:()=>any;\r\n\r\n getAppInstance() {\r\n return this._app as QueenApplication;\r\n }\r\n\r\n init(dom: HTMLElement, pickOption:{clickedOutline:boolean, enablePicker: boolean}={clickedOutline:true, enablePicker: true}) {\r\n if (this._app) {\r\n this._app.destory();\r\n }\r\n this.canvas = dom;\r\n this._app = new QueenApplication(dom);\r\n\r\n // debugger\r\n this.picker = new Picker(this._app, pickOption);\r\n \r\n this._app.start();\r\n\r\n if (this.getDefaultEnvHandle ) {\r\n const env = this.getDefaultEnvHandle();\r\n this.env3d.setEnv3d(env);\r\n } else {\r\n this.env3d.setDefaultEnv3d();\r\n }\r\n\r\n this.emit('app:initialized');\r\n }\r\n\r\n setTransparntBg() {\r\n const app = this.getAppInstance()\r\n app?.setBackgroundMode('none');\r\n }\r\n\r\n destory() {\r\n if (this._app) {\r\n this._app.destory(true);\r\n }\r\n this._app = null;\r\n this.canvas = null;\r\n this.emit('app:destoryed');\r\n \r\n }\r\n afterInit(cb: () => void) {\r\n if (this._app) {\r\n cb();\r\n } else {\r\n this.once('app:initialized', cb);\r\n }\r\n }\r\n\r\n redraw() {\r\n this._app?.redraw();\r\n }\r\n\r\n setOutLine(geom: any) {\r\n this._app?.setOutLine(geom.getOrCreateStateSet());\r\n }\r\n\r\n showGrid(show: boolean) {\r\n this._app?.getFeaturesManager()?.enableGrid(show);\r\n this.redraw();\r\n }\r\n\r\n showGizmo(show: boolean) {\r\n this._app?.getFeaturesManager()?.enableGizmo(show);\r\n }\r\n\r\n gizmoAttach(node: any) {\r\n return this._app?.getFeaturesManager()?.getNodeGizmo()?.attachToNode(node);\r\n }\r\n\r\n updateController() {\r\n const _viewer = this._app?._viewer;\r\n if (!_viewer) return;\r\n\r\n //@ts-ignore\r\n _viewer.setupManipulator(this._app?._switchManipulator);\r\n\r\n //@ts-ignore\r\n _viewer.getManipulator().computeHomePosition();\r\n }\r\n\r\n setControllerZoom(inRadiuScale:number, outRadiuScale: number) {\r\n const _viewer = this._app?._viewer;\r\n if (!_viewer) return;\r\n\r\n //@ts-ignore\r\n _viewer.getManipulator().computeHomePosition();\r\n \r\n //@ts-ignore\r\n const v = _viewer.getManipulator().getCurrentManipulator()\r\n\r\n const bound = v.getHomeBoundingSphere();\r\n\r\n const inScale = (inRadiuScale? inRadiuScale: 1.5);\r\n const outScale = outRadiuScale?outRadiuScale: 6;\r\n\r\n v.setLimitZoomIn(bound.radius() / inScale ); \r\n v.setLimitZoomOut(bound.radius() * outScale);\r\n }\r\n\r\n setControllerTarget(target:any) {\r\n const _viewer = this._app?._viewer;\r\n if (!_viewer) return;\r\n\r\n //@ts-ignore\r\n const v = _viewer.getManipulator().getCurrentManipulator()\r\n \r\n v.setTarget( target );\r\n }\r\n\r\n getControllerTarget( target:any ) {\r\n const _viewer = this._app?._viewer;\r\n if (!_viewer) return;\r\n //@ts-ignore\r\n const v = _viewer.getManipulator().getCurrentManipulator()\r\n \r\n v.getTarget( target );\r\n }\r\n\r\n addChild(node: any) {\r\n this._app?.scene?.addChild(node);\r\n // this._app?.scene?.updateKdTree();\r\n // this.updateController();\r\n this.redraw();\r\n }\r\n\r\n removeChild(node: any) {\r\n this._app?.scene?.removeChild(node);\r\n this.redraw();\r\n }\r\n}\r\n","import { createMat, Mat } from './createMat';\r\n\r\nexport class MatObj {\r\n material: Mat;\r\n constructor(mat?: Parameters<typeof createMat>[0]) {\r\n this.material = createMat(mat);\r\n }\r\n}\r\n","import { mat4 } from '../../../queen/osg/glMatrix';\r\nimport osgUtil from '../../../queen/osgUtil/osgUtil';\r\nimport osg from '../../../queen/osg/osg';\r\n\r\nimport MatrixTransform from '../../../queen/osg/MatrixTransform';\r\nimport MaterialUtils from '../../../queen/application/material/MaterialUtils';\r\nimport { GeomNodeVisitor } from '../../../queen/application/objects/GeomNodeVisitor';\r\nimport { GeomNodeVisitorV3 } from '../../../queen/application/objects/GeomNodeVisitorV3';\r\nimport { Mat } from '../Mat/createMat';\r\n\r\nexport class MeshObj {\r\n id: string = '';\r\n geom: any = new MatrixTransform();\r\n geomVisitor: GeomNodeVisitorV3 | GeomNodeVisitor;\r\n _InverseModelMatrix = osg.Uniform.createMatrix4('uInverseScopeModelMatrix');\r\n _tempMatrix = mat4.create();\r\n _version;\r\n\r\n constructor(id: string, mesh: any, version: string) {\r\n this._version = version;\r\n this.id = id;\r\n this.geomVisitor = version == \"3.0\" ? new GeomNodeVisitorV3(null, true) : new GeomNodeVisitor(null, true);\r\n this.geomVisitor.apply(mesh);\r\n this.geom.addChild(mesh);\r\n\r\n //设置部件名字\r\n this.geomVisitor.geoms.forEach((item)=>{\r\n const node = item.geom;\r\n const udata = node.getUserData() || {};\r\n udata.name = item.node;\r\n udata.index = item.index;\r\n node.setUserData(udata);\r\n })\r\n\r\n this.geom.setName('meshobjRoot');\r\n this.geom.editMask = osgUtil.NodeGizmo.PICK_GIZMO;\r\n\r\n //初始化mesh node 设置\r\n const cbs = mesh.getUpdateCallbackList();\r\n for (let i = 0; i < cbs.length; i++) {\r\n mesh.removeUpdateCallback(cbs[i]);\r\n }\r\n mesh.getOrCreateStateSet().addUniform(this._InverseModelMatrix);\r\n\r\n mesh.addUpdateCallback(this);\r\n }\r\n\r\n\r\n update() {\r\n mat4.invert(this._tempMatrix, this.geom.getMatrix());\r\n this._InverseModelMatrix.setMatrix4(this._tempMatrix);\r\n }\r\n\r\n getGeoms() {\r\n return this.geomVisitor.geoms.map((item) => {\r\n return item;\r\n });\r\n }\r\n\r\n getGeomByName(name: string) {\r\n return this.geomVisitor.geoms.find((item) => item.node === name)?.geom;\r\n }\r\n\r\n setGeomMat(geomName: string, mat: Mat) {\r\n const geom = this.getGeomByName(geomName);\r\n if (!geom) return;\r\n return MaterialUtils.updateGeomMaterial(geom, mat);\r\n }\r\n\r\n setGeomVisible(CompName: string, visible: boolean) {\r\n const geom = this.getGeomByName(CompName);\r\n if (!geom) return;\r\n geom.setNodeMask(visible ? -1 : 0);\r\n }\r\n\r\n\r\n transform() {\r\n const m = mat4.create();\r\n mat4.translate(m, m, [10, 0, 0]);\r\n // mat4.r\r\n this.geom.setMatrix(m);\r\n }\r\n}\r\n","import { ModelLoader } from '../../../queen/application/objects/ModelLoader';\r\nimport { MeshObj } from '.';\r\n\r\nexport class MeshLoader {\r\n async load(options: { id: string; url: string }, uvproject = true, version:string = \"\") {\r\n const model = await ModelLoader.loadModel(options.url, {uvproject, version});\r\n return new MeshObj(options.id, model, version);\r\n }\r\n}\r\n","type ReturnPromiseType<T> = T extends (...args: any) => Promise<infer R>\r\n ? R\r\n : any;\r\n\r\nexport class ResLoader {\r\n async load(args: any): Promise<object | undefined> {\r\n return undefined;\r\n }\r\n}\r\n\r\nexport class ResController<T extends ResLoader> {\r\n private resMap = new Map<string, ReturnPromiseType<T['load']>>();\r\n private loader: T;\r\n constructor(loader: T) {\r\n this.loader = loader;\r\n }\r\n\r\n async load(\r\n id: string,\r\n params: Parameters<T['load']>[0]\r\n ): Promise<ReturnPromiseType<T['load']>> {\r\n if (this.resMap.has(id)) {\r\n return this.resMap.get(id) as any;\r\n } else {\r\n const item = await this.loader.load(params);\r\n if (item) {\r\n this.resMap.set(id, item as any);\r\n }\r\n return item as any;\r\n }\r\n }\r\n\r\n set(id: string, item: ReturnPromiseType<T['load']>) {\r\n return this.resMap.set(id, item);\r\n }\r\n\r\n get(id: string) {\r\n return this.resMap.get(id);\r\n }\r\n\r\n delete(id: string) {\r\n this.resMap.delete(id);\r\n }\r\n\r\n clear() {\r\n this.resMap.clear();\r\n }\r\n}\r\n","import osg from '../osg/osg'\r\nimport MaterialUtils from './material/MaterialUtils'\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport ResourceManager from './ResourceManager'\r\nimport PickMask from './PickMask';\r\nimport RenderDetail from './RenderDetail';\r\nimport PBRMaterial from './material/PBRMaterial'\r\nexport default class GroundShadow extends MatrixTransform {\r\n constructor(options) {\r\n super()\r\n\r\n var width = options.width || 300\r\n var height = options.height || 400\r\n var position = options.position || [0, 0, 0]\r\n\r\n let ret = ResourceManager.getInstance().getOrCreateTexture(options.file, {\r\n minFilter: osg.Texture.LINEAR_MIPMAP_LINEAR,\r\n magFilter: osg.Texture.LINEAR,\r\n internalFormat: osg.Texture.RGB,\r\n wrapS: osg.Texture.CLAMP_TO_EDGE,\r\n wrapT: osg.Texture.CLAMP_TO_EDGE,\r\n anisotropy: 16\r\n });\r\n\r\n this._texture = ret.texture\r\n if (options.onLoad && ret.promise) {\r\n ret.promise.then(()=>{\r\n options.onLoad();\r\n })\r\n }\r\n \r\n this.setNodeMask(PickMask.NO_PICK_NO_SHADOW)\r\n this._geometry = osg.createTexturedQuadGeometry(\r\n -width / 2 + position[0],\r\n -height / 2 + position[1],\r\n position[2],\r\n width,\r\n 0,\r\n 0,\r\n 0,\r\n height,\r\n 0\r\n )\r\n this._geometry.setBound(new osg.BoundingBox())\r\n this._geometry.setName('Ground - Geometry')\r\n this._geometry.setNodeMask(0)\r\n this.addChild(this._geometry)\r\n\r\n let material = new PBRMaterial();\r\n material._cullFace = osg.CullFace.BACK\r\n material.setUnLit(true)\r\n material.setHasOpacityMap(true)\r\n material.enableInvertAlpha(true)\r\n var stateset = this._geometry.getOrCreateStateSet()\r\n stateset.setAttributeAndModes(material);\r\n let orgMaterial = new osg.Material();\r\n orgMaterial.setName('ground_shadow')\r\n stateset.setAttributeAndModes(orgMaterial);\r\n stateset.setName('Ground')\r\n stateset.setShaderGeneratorName('PBR');\r\n stateset.setRenderBinDetails(RenderDetail.TRANSPARENT, 'DepthSortedBin');\r\n stateset.setAttribute(new osg.CullFace(osg.CullFace.BACK))\r\n stateset.addUniform(osg.Uniform.createInt(MaterialUtils.OPACITY_TEXTURE_UNIT, \"opacityMap\"))\r\n stateset.setTextureAttributeAndModes(MaterialUtils.OPACITY_TEXTURE_UNIT, this._texture);\r\n\r\n this._visiable = false\r\n this.setVisiable(true)\r\n }\r\n\r\n setVisiable(value) {\r\n this._visiable = !!value\r\n this._geometry.setNodeMask(!!value ? -1 : 0);\r\n }\r\n\r\n isVisiable() {\r\n return this._visiable\r\n }\r\n}","import './queen';\r\nimport MatrixTransform from './queen/osg/MatrixTransform';\r\nimport Node from \"./queen/osg/Node\";\r\nimport osg from './queen/osg/osg';\r\nimport osgUtil from './queen/osgUtil/osgUtil';\r\nimport * as Util from \"./util/useMaterial\";\r\nimport { createMaterial, createRenderMaterial } from \"./util/useMaterial\";\r\nimport { createDefaultScenePackage } from \"./util/scenepack\";\r\n\r\nexport * from './module/objects/Application';\r\nexport * from './module/objects/Mat/index';\r\nexport * from './module/objects/Mesh/index';\r\nexport * from './module/objects/Mesh/loader';\r\nexport * from './module/objects/ResController';\r\nimport GroundShadow from \"./queen/application/GroundShadow\";\r\nimport { UrlConfig, DefaultUrlResolver } from './queen/application/material/UrlResolver';\r\nexport const Utils = {\r\n MatrixTransform,\r\n Node,\r\n osg,\r\n osgUtil,\r\n GroundShadow,\r\n Util,\r\n createMaterial,\r\n createRenderMaterial,\r\n createDefaultScenePackage,\r\n UrlConfig,\r\n DefaultUrlResolver\r\n}\r\n","import { MeshObj, Utils } from \"@/queen3d\";\r\nimport { Events } from \"@/queen3d/queen\";\r\n\r\nconst { MatrixTransform, osgUtil, osg, GroundShadow } = Utils;\r\n\r\nexport class ProdcutObj extends Events {\r\n node: any;\r\n mesh: MeshObj;\r\n nodeShadow: any;\r\n\r\n constructor(\r\n meshObj: MeshObj,\r\n sceneProdId: string,\r\n clearMeshParent = false,\r\n shadow = \"\"\r\n ) {\r\n super();\r\n\r\n this.mesh = meshObj;\r\n //@ts-ignore\r\n this.node = new MatrixTransform();\r\n //@ts-ignore\r\n this.node.editMask = osgUtil.NodeGizmo.PICK_GIZMO;\r\n\r\n const udata = { sceneProdId: sceneProdId };\r\n //@ts-ignore\r\n this.node.setUserData(udata);\r\n\r\n if (clearMeshParent) {\r\n meshObj.geom.removeParents();\r\n }\r\n //@ts-ignore\r\n this.node.addChild(meshObj.geom);\r\n\r\n // eslint-disable-next-line\r\n const scope = this;\r\n if (shadow) {\r\n if (shadow.indexOf(\"tree-shadow-\") != -1) {\r\n //tree-shadow-1.5-512-xx.png\r\n\r\n let scale = 1.5;\r\n let fileName: any = shadow.split(\"/\");\r\n fileName = fileName[fileName.length - 1];\r\n const frags = fileName.split(\"-\");\r\n if (frags.length > 4) {\r\n const s = parseFloat(frags[2]);\r\n // eslint-disable-next-line\r\n if ( s > 1.5) {\r\n scale = s;\r\n }\r\n }\r\n //@ts-ignore\r\n const box = this.node.getBoundingBox();\r\n const yw = box.yMax() - box.yMin();\r\n const xw = box.xMax() - box.xMin();\r\n // const zw = box.zMax() - box.zMin()\r\n const maxX = Math.max(xw, yw) * scale;\r\n\r\n const objShadow = new GroundShadow({\r\n width: maxX,\r\n height: maxX,\r\n position: [box.xMin() + 0.5 * xw, box.yMin() + 0.5 * yw, box.zMin()],\r\n file: shadow,\r\n onLoad: () => {\r\n scope.emit(\"onload\");\r\n },\r\n });\r\n\r\n objShadow._geometry.setBound(new osg.BoundingBox());\r\n this.nodeShadow = objShadow;\r\n //@ts-ignore\r\n this.node.addChild(objShadow);\r\n } else {\r\n const objShadow = new GroundShadow({\r\n width: 300,\r\n height: 400,\r\n position: [0, 50, 0],\r\n file: shadow,\r\n onLoad: () => {\r\n scope.emit(\"onload\");\r\n },\r\n });\r\n objShadow._geometry.setBound(new osg.BoundingBox());\r\n this.nodeShadow = objShadow;\r\n //@ts-ignore\r\n this.node.addChild(objShadow);\r\n }\r\n }\r\n }\r\n\r\n updateTransform(transform: { pos: any; scale: any; rotation: any }) {\r\n const trans = osg.vec3.fromValues(...transform.pos);\r\n\r\n const scale = osg.vec3.fromValues(...transform.scale);\r\n\r\n const quatR = osg.quat.fromValues(...transform.rotation);\r\n const trsMat = osg.mat4.fromRotationTranslationScale(\r\n osg.mat4.create(),\r\n quatR,\r\n trans,\r\n scale\r\n );\r\n //@ts-ignore\r\n this.node.setMatrix(trsMat);\r\n }\r\n}\r\n","export const env3dConf = {\r\n diffuseSPH: [\r\n 2.52177000045776, 2.64750003814697, 2.71793007850647, -0.970494985580444,\r\n -1.03103005886078, -1.07638001441956, -0.517792999744415,\r\n -0.556958019733429, -0.594671010971069, -0.335999011993408,\r\n -0.360029995441437, -0.390183985233307, 0.149149999022484,\r\n 0.157473996281624, 0.170339003205299, 0.305085003376007, 0.325536996126175,\r\n 0.345122009515762, -0.000786492018960416, -0.00349557003937662,\r\n -0.0065525402314961, -0.00095561402849853, -0.000445610989117995,\r\n 0.00699491985142231, -0.00675775017589331, -0.0107802003622055,\r\n -0.0170636996626854, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r\n 0, 0, 0, -0.0128212003037333, -0.013501700013876, -0.0145362000912428,\r\n 0.0321758985519409, 0.0344155989587307, 0.0357340984046459,\r\n 0.0101429997012019, 0.0108799003064632, 0.011744599789381,\r\n 0.0164007004350424, 0.017807599157095, 0.0192644000053406,\r\n 0.0183598008006811, 0.0198072995990515, 0.0203540995717049,\r\n 0.00825730990618467, 0.00872035045176744, 0.00948190037161112,\r\n 0.0411866009235382, 0.0441729985177517, 0.0463373996317387,\r\n 0.0160459000617266, 0.0171310994774103, 0.0176567994058132,\r\n -0.00968789961189032, -0.0103497998788953, -0.00986727979034185,\r\n ],\r\n lights: [\r\n {\r\n area: {\r\n h: 0.0878906026482582,\r\n w: 0.016601599752903,\r\n x: 0.490723013877869,\r\n y: 0.192383006215096,\r\n },\r\n color: [43.951301574707, 47.0472984313965, 49.9592018127441],\r\n direction: [0.0331058017909527, -0.822849988937378, 0.567294001579285],\r\n lum_ratio: 0.0797673985362053,\r\n luminosity: 508.627990722656,\r\n sum: 0.742150008678436,\r\n variance: 0.000719960022252053,\r\n },\r\n ],\r\n textures: [\r\n {\r\n encoding: \"srgb\",\r\n format: \"panorama\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/thumbnail_256.jpg\",\r\n height: 128,\r\n width: 256,\r\n },\r\n ],\r\n type: \"thumbnail\",\r\n },\r\n {\r\n encoding: \"luv\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_luv.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 1779853,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.019999999552965164,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_luv.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 1200968,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.054999999701976776,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_luv.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 317622,\r\n sizeUncompressed: 1572864,\r\n width: 256,\r\n },\r\n {\r\n blur: 0.10000000149011612,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_luv.bin.gz\",\r\n height: 128,\r\n samples: 2048,\r\n sizeCompressed: 97956,\r\n sizeUncompressed: 393216,\r\n width: 128,\r\n },\r\n {\r\n blur: 0.15000000596046448,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_luv.bin.gz\",\r\n height: 64,\r\n samples: 2048,\r\n sizeCompressed: 29064,\r\n sizeUncompressed: 98304,\r\n width: 64,\r\n },\r\n ],\r\n type: \"background\",\r\n },\r\n {\r\n encoding: \"rgbm\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_rgbm.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 2977192,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.019999999552965164,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_rgbm.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 1858076,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.054999999701976776,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_rgbm.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 487212,\r\n sizeUncompressed: 1572864,\r\n width: 256,\r\n },\r\n {\r\n blur: 0.10000000149011612,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_rgbm.bin.gz\",\r\n height: 128,\r\n samples: 2048,\r\n sizeCompressed: 149136,\r\n sizeUncompressed: 393216,\r\n width: 128,\r\n },\r\n {\r\n blur: 0.15000000596046448,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_rgbm.bin.gz\",\r\n height: 64,\r\n samples: 2048,\r\n sizeCompressed: 46566,\r\n sizeUncompressed: 98304,\r\n width: 64,\r\n },\r\n ],\r\n type: \"background\",\r\n },\r\n {\r\n encoding: \"rgbe\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_rgbe.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 3043958,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.019999999552965164,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_rgbe.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 1766005,\r\n sizeUncompressed: 6291456,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.054999999701976776,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_rgbe.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 473185,\r\n sizeUncompressed: 1572864,\r\n width: 256,\r\n },\r\n {\r\n blur: 0.10000000149011612,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_rgbe.bin.gz\",\r\n height: 128,\r\n samples: 2048,\r\n sizeCompressed: 149500,\r\n sizeUncompressed: 393216,\r\n width: 128,\r\n },\r\n {\r\n blur: 0.15000000596046448,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_rgbe.bin.gz\",\r\n height: 64,\r\n samples: 2048,\r\n sizeCompressed: 49221,\r\n sizeUncompressed: 98304,\r\n width: 64,\r\n },\r\n ],\r\n type: \"background\",\r\n },\r\n {\r\n encoding: \"float\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_float.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 16116615,\r\n sizeUncompressed: 18874368,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.019999999552965164,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_float.bin.gz\",\r\n height: 512,\r\n samples: 2048,\r\n sizeCompressed: 16067477,\r\n sizeUncompressed: 18874368,\r\n width: 512,\r\n },\r\n {\r\n blur: 0.054999999701976776,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_float.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 4041881,\r\n sizeUncompressed: 4718592,\r\n width: 256,\r\n },\r\n {\r\n blur: 0.10000000149011612,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_float.bin.gz\",\r\n height: 128,\r\n samples: 2048,\r\n sizeCompressed: 1020352,\r\n sizeUncompressed: 1179648,\r\n width: 128,\r\n },\r\n {\r\n blur: 0.15000000596046448,\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_float.bin.gz\",\r\n height: 64,\r\n samples: 2048,\r\n sizeCompressed: 258568,\r\n sizeUncompressed: 294912,\r\n width: 64,\r\n },\r\n ],\r\n type: \"background\",\r\n },\r\n {\r\n encoding: \"luv\",\r\n format: \"panorama\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_luv.bin.gz\",\r\n height: 1024,\r\n samples: 2048,\r\n sizeCompressed: 673838,\r\n sizeUncompressed: 4194304,\r\n width: 1024,\r\n },\r\n ],\r\n limitSize: 32,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"rgbm\",\r\n format: \"panorama\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_rgbm.bin.gz\",\r\n height: 1024,\r\n samples: 2048,\r\n sizeCompressed: 1095123,\r\n sizeUncompressed: 4194304,\r\n width: 1024,\r\n },\r\n ],\r\n limitSize: 32,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"rgbe\",\r\n format: \"panorama\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_rgbe.bin.gz\",\r\n height: 1024,\r\n samples: 2048,\r\n sizeCompressed: 1130918,\r\n sizeUncompressed: 4194304,\r\n width: 1024,\r\n },\r\n ],\r\n limitSize: 32,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"float\",\r\n format: \"panorama\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_float.bin.gz\",\r\n height: 1024,\r\n samples: 2048,\r\n sizeCompressed: 7099449,\r\n sizeUncompressed: 12582912,\r\n width: 1024,\r\n },\r\n ],\r\n limitSize: 32,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"luv\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_luv.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 635016,\r\n sizeUncompressed: 2097144,\r\n width: 256,\r\n },\r\n ],\r\n limitSize: 8,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"rgbm\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_rgbm.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 1055995,\r\n sizeUncompressed: 2097144,\r\n width: 256,\r\n },\r\n ],\r\n limitSize: 8,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"rgbe\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_rgbe.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 1109686,\r\n sizeUncompressed: 2097144,\r\n width: 256,\r\n },\r\n ],\r\n limitSize: 8,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"float\",\r\n format: \"cubemap\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_float.bin.gz\",\r\n height: 256,\r\n samples: 2048,\r\n sizeCompressed: 5417781,\r\n sizeUncompressed: 6291432,\r\n width: 256,\r\n },\r\n ],\r\n limitSize: 8,\r\n type: \"specular_ue4\",\r\n },\r\n {\r\n encoding: \"rg16\",\r\n format: \"lut\",\r\n images: [\r\n {\r\n file: \"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/brdf_ue4.bin.gz\",\r\n height: 128,\r\n samples: 2048,\r\n sizeCompressed: 59665,\r\n sizeUncompressed: 65536,\r\n width: 128,\r\n },\r\n ],\r\n type: \"brdf_ue4\",\r\n },\r\n ],\r\n writeByChannel: true,\r\n };\r\n ","import { cloneDeep } from \"lodash\";\r\nimport { env3dConf } from \"./defaultEnv3d\";\r\nimport { Application } from \"@/queen3d\";\r\n\r\nexport function initSceneEnv(\r\n queen3d: Application,\r\n source: any,\r\n scene: any,\r\n backgroundTransparent = false\r\n) {\r\n setSceneEnv(queen3d, source, scene.envId);\r\n if (!backgroundTransparent) {\r\n setSceneBg(queen3d, scene.background);\r\n } else {\r\n const app = queen3d.getAppInstance();\r\n app?.setBackgroundMode(\"none\");\r\n }\r\n\r\n setSceneLight(queen3d, scene.lights?.list);\r\n}\r\n\r\nexport function setSceneEnv(queen3d: Application, source: any, envId: string) {\r\n if (!envId) {\r\n queen3d.env3d.setEnv3d(env3dConf);\r\n return;\r\n }\r\n const env = source.env3ds.find((item: any) => item.id == envId);\r\n if (!env) return;\r\n\r\n queen3d.env3d.setEnv3d(env.config || env3dConf);\r\n queen3d.env3d.setEnv3dOption(env.options.rotation, env.options.exposure);\r\n queen3d.env3d.setEnvToneMap(env.toneMap);\r\n}\r\n\r\nexport function setSceneBg(\r\n queen3d: Application,\r\n background: {\r\n type: number;\r\n color?: any;\r\n image?: { url: string; size: number };\r\n }\r\n) {\r\n const data = background;\r\n const type = data.type,\r\n color = data.color,\r\n url = data.image ? data.image.url : undefined;\r\n const app = queen3d.getAppInstance();\r\n if (type == 1) {\r\n app.setBackgroundMode(\"color\");\r\n app.setBackgroundColor(color);\r\n app.redraw();\r\n } else if (type == 2) {\r\n app.setBackgroundFixed(url);\r\n app.setBackgroundMode(\"fixed\");\r\n app.redraw();\r\n } else if (type == 3) {\r\n app.setBackgroundMode(\"environment\"); //ambient\r\n app.redraw();\r\n }\r\n}\r\n\r\n//@param isPreset 修改是否来自选择模板\r\nexport function setSceneLight(\r\n queen3d: Application,\r\n list: any[] = [],\r\n isPreset = false\r\n) {\r\n const app = queen3d.getAppInstance();\r\n if (list && list.length) {\r\n app.setLightingEnable(true);\r\n app.setThreeLightsJson(cloneDeep(list), isPreset);\r\n if (isPreset) {\r\n //@ts-ignore\r\n Object.assign(list, app._features.lighting.getModel().getJSON().lights);\r\n }\r\n } else {\r\n app.setLightingEnable(false);\r\n }\r\n}\r\n","//预先加载所有几何体,并进行初始化 obj.removeParents() 清除\r\nexport async function initSceneGeoms(\r\n source: any,\r\n scene: any,\r\n geomsCacher: any\r\n) {\r\n //@ts-ignore\r\n const force = window.noForceHttps;\r\n //@ts-ignore\r\n window.noForceHttps = true;\r\n\r\n const pack = source;\r\n const products = pack.products || [];\r\n //查找场景中所有模型\r\n const downloading: any[] = [];\r\n scene.products.forEach((p: any) => {\r\n if (p.visible == false) return;\r\n const prod = products.find((prod: any) => prod.id == p.prodId);\r\n const geom = pack.geoms.find((g: any) => g.id == prod?.geomId);\r\n\r\n const finded = downloading.find((g) => g.id == geom?.id);\r\n if (!finded) {\r\n downloading.push(geom);\r\n }\r\n });\r\n\r\n let n = downloading.length;\r\n while (n--) {\r\n const meshObj = await geomsCacher.load(\r\n downloading[n].osgjs.url,\r\n downloading[n]\r\n );\r\n\r\n if (meshObj) {\r\n meshObj.geom.removeParents();\r\n }\r\n }\r\n //@ts-ignore\r\n window.noForceHttps = force;\r\n}\r\nexport async function initMatGeom(source: any, geomsCacher: any) {\r\n //@ts-ignore\r\n const force = window.noForceHttps;\r\n //@ts-ignore\r\n window.noForceHttps = true;\r\n const meshObj = await geomsCacher.load(source.geom.osgjs.url, source.geom);\r\n\r\n if (meshObj) {\r\n meshObj.geom.removeParents();\r\n return meshObj;\r\n }\r\n\r\n //@ts-ignore\r\n window.noForceHttps = force;\r\n}\r\n\r\nexport function cleanGeomCacher(this: any) {\r\n this.geomsCacher.clear();\r\n}\r\n\r\nexport function switchSceneProdComp(\r\n this: any,\r\n sceneProdId: string,\r\n compName: string\r\n) {\r\n const sceneProd = this.store.currSceneProds.find(\r\n (d: any) => d.id === sceneProdId\r\n );\r\n if (!sceneProd) return;\r\n const product = this.store.pack.products.find(\r\n (d: any) => d.id === sceneProd.prodId\r\n );\r\n if (!product) return;\r\n const prodComp = product.components.find((d: any) => d.name === compName);\r\n if (!prodComp) return;\r\n\r\n this.store.setCurrSceneActiveKeys({\r\n type: \"productComp\",\r\n id: prodComp.id,\r\n pid: sceneProdId,\r\n });\r\n}\r\n","//@ts-nocheck\r\nimport RenderTarget from \"proto.gl/RenderTarget\";\r\nimport BigTri from \"proto.gl/BigTriangle\";\r\nimport WebGLCanvas from \"proto.gl/WebGLCanvas\";\r\nimport loadtex from \"proto.gl/loader/texture\";\r\nimport GL from \"proto.gl/WebGLConstants\";\r\nimport DataTexture from \"proto.gl/DataTexture\";\r\nimport Texture from \"proto.gl/Texture\";\r\n\r\nclass MeanPass {\r\n _inputFilter: any;\r\n _inputWrap: any;\r\n _outputSize: any;\r\n _downSampler: BigTri;\r\n _mipmapSampler: BigTri;\r\n _downSamplerTarget: BigTri;\r\n _output: RenderTarget;\r\n constructor() {\r\n this._inputFilter = GL.LINEAR;\r\n this._inputWrap = GL.REPEAT;\r\n this._outputSize = [16, 16];\r\n this._downSampler = BigTri({\r\n fs: `\r\n precision highp float;\r\n #define SHADER_NAME MEAN_DOWN_SAMPLE\r\n uniform vec2 size;\r\n uniform sampler2D tex;\r\n void main () {\r\n gl_FragColor = texture2D(tex, gl_FragCoord.xy / size);\r\n }\r\n `,\r\n });\r\n\r\n this._mipmapSampler = BigTri({\r\n fs: `\r\n #extension GL_EXT_shader_texture_lod : enable\r\n #define SHADER_NAME MEAN_MIPMAP\r\n precision highp float;\r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n void main () {\r\n gl_FragColor = texture2DLodEXT(tex, gl_FragCoord.xy / size, 4.);\r\n }\r\n `,\r\n });\r\n this._downSamplerTarget = new RenderTarget(\r\n new DataTexture(this._outputSize[0], this._outputSize[1], {\r\n mipMaping: true,\r\n magFilter: GL.LINEAR,\r\n minFilter: GL.LINEAR,\r\n wrapS: GL.REPEAT,\r\n wrapT: GL.REPEAT,\r\n })\r\n );\r\n this._output = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n }\r\n\r\n render(canvas, tex) {\r\n tex.magFilter = this._inputFilter;\r\n tex.minFilter = this._inputFilter;\r\n tex.wrapS = this._inputWrap;\r\n tex.wrapT = this._inputWrap;\r\n\r\n canvas.context.bindRenderTarget(this._downSamplerTarget);\r\n canvas.draw(this._downSampler, {\r\n uniforms: { size: this._outputSize, tex },\r\n });\r\n canvas.context.renderTargetMipmap(this._downSamplerTarget);\r\n canvas.context.bindRenderTarget(this._output);\r\n canvas.draw(this._mipmapSampler, {\r\n uniforms: {\r\n size: this._outputSize,\r\n tex: this._downSamplerTarget.colorTexture,\r\n },\r\n });\r\n return this._output.colorTexture;\r\n }\r\n\r\n release() {\r\n this._downSamplerTarget.release();\r\n this._output.release();\r\n }\r\n}\r\n\r\nclass DirectionalBlurPass {\r\n _inputFilter: any;\r\n _inputWrap: any;\r\n _outputSize: any;\r\n _draw: BigTri;\r\n _output: RenderTarget;\r\n constructor(param?: any) {\r\n param = param || {};\r\n this._inputFilter = param.filter || GL.NEAREST;\r\n this._inputWrap = param.wrap || GL.REPEAT;\r\n this._outputSize = param.size || [2048, 2048];\r\n this._draw = BigTri({\r\n fs: `\r\n precision highp float;\r\n #define SHADER_NAME DIRECTIONAL_BLUR\r\n uniform sampler2D tex;\r\n uniform float intensity;\r\n uniform float angle;\r\n uniform vec2 size;\r\n const int sample = 128;\r\n vec4 directional_blur(sampler2D tex, vec2 uv, float intensity, float angle) {\r\n vec2 offset = vec2(cos(-angle) * intensity / float(sample), sin(-angle) * intensity / float(sample));\r\n vec4 color = vec4(0.);\r\n for (int k = -sample; k < sample + 1; k ++){\r\n color += texture2D(tex, uv + offset * float(k));\r\n }\r\n\r\n return color / float(2 * sample + 1);\r\n }\r\n void main() {\r\n vec2 uv = gl_FragCoord.xy / size; \r\n gl_FragColor = directional_blur(tex, uv, intensity, angle); \r\n }\r\n `,\r\n });\r\n\r\n this._output = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n }\r\n\r\n render(canvas, tex, { angle, intensity }) {\r\n angle = angle === undefined ? 0 : (angle * Math.PI) / 180;\r\n intensity = intensity === undefined ? 10 / 256 : intensity / 256;\r\n\r\n tex.wrapS = this._inputWrap;\r\n tex.wrapT = this._inputWrap;\r\n tex.minFilter = this._inputFilter;\r\n tex.magFilter = this._inputFilter;\r\n\r\n canvas.context.bindRenderTarget(this._output);\r\n canvas.draw(this._draw, {\r\n uniforms: { size: this._outputSize, tex, intensity, angle },\r\n });\r\n return this._output.colorTexture;\r\n }\r\n\r\n release() {\r\n this._output.release();\r\n }\r\n}\r\n\r\nclass BlurHQPass {\r\n _inputFilter: any;\r\n _inputWrap: any;\r\n _outputSize: any;\r\n _draw: BigTri;\r\n _output: RenderTarget;\r\n _blurIn: DirectionalBlurPass;\r\n _blurOut1: DirectionalBlurPass;\r\n _blurOut2: DirectionalBlurPass;\r\n constructor(param?: any) {\r\n param = param || {};\r\n this._inputFilter = param.filter || GL.NEAREST;\r\n this._inputWrap = param.wrap || GL.REPEAT;\r\n this._outputSize = param.size || [2048, 2048];\r\n this._draw = BigTri({\r\n fs: `\r\n precision highp float;\r\n #define SHADER_NAME BLUR_HQ\r\n uniform vec2 size;\r\n uniform sampler2D tex1;\r\n uniform sampler2D tex2;\r\n uniform float quality;\r\n \r\n void main () {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n vec4 color1 = texture2D(tex1, uv);\r\n vec4 color2 = texture2D(tex2, uv);\r\n gl_FragColor = mix(color1, (color1 + color2) / 2., quality);\r\n }\r\n `,\r\n });\r\n\r\n this._blurIn = new DirectionalBlurPass({ size: this._outputSize });\r\n this._blurOut1 = new DirectionalBlurPass({ size: this._outputSize });\r\n this._blurOut2 = new DirectionalBlurPass({ size: this._outputSize });\r\n this._output = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n }\r\n\r\n render(canvas, tex, { intensity, quality }) {\r\n //quality range [0-1]\r\n\r\n intensity = intensity === undefined ? 10 : intensity;\r\n quality = quality === undefined ? 0 : quality;\r\n\r\n tex.wrapS = this._inputWrap;\r\n tex.wrapT = this._inputWrap;\r\n tex.minFilter = this._inputFilter;\r\n tex.magFilter = this._inputFilter;\r\n\r\n if (intensity === 0) {\r\n return tex;\r\n }\r\n\r\n intensity = (intensity * 2) / 3;\r\n\r\n let tex1 = this._blurIn.render(canvas, tex, { intensity, angle: 0 });\r\n tex1 = this._blurOut1.render(canvas, tex1, { intensity, angle: 45 });\r\n tex1 = this._blurIn.render(canvas, tex1, { intensity, angle: 90 });\r\n tex1 = this._blurOut1.render(canvas, tex1, { intensity, angle: 135 });\r\n\r\n let tex2 = tex1;\r\n if (quality !== 0) {\r\n tex2 = this._blurIn.render(canvas, tex, { intensity, angle: 22.5 });\r\n tex2 = this._blurOut2.render(canvas, tex2, { intensity, angle: 157.5 });\r\n tex2 = this._blurIn.render(canvas, tex2, { intensity, angle: 67.5 });\r\n tex2 = this._blurOut2.render(canvas, tex2, { intensity, angle: 112.5 });\r\n }\r\n\r\n canvas.context.bindRenderTarget(this._output);\r\n canvas.draw(this._draw, {\r\n uniforms: { size: this._outputSize, tex1, tex2 },\r\n });\r\n return this._output.colorTexture;\r\n }\r\n\r\n release() {\r\n this._blurIn.release();\r\n this._blurOut1.release();\r\n this._blurOut2.release();\r\n this._output.release();\r\n }\r\n}\r\n\r\nclass ColorMatchPass {\r\n static AVERAGE = 0;\r\n static COLOR = 1;\r\n static TEXTURE = 2;\r\n _inputFilter: any;\r\n _inputWrap: any;\r\n _outputSize: any;\r\n _computeTarget: BigTri;\r\n _splitAlpha: BigTri;\r\n _histogram_scan_shader: BigTri;\r\n _withoutMaskBlit: BigTri;\r\n _maskBlit: BigTri;\r\n _mean: MeanPass;\r\n _target: RenderTarget;\r\n _targetAlpha: RenderTarget;\r\n _blurHQ: BlurHQPass;\r\n _scan: RenderTarget;\r\n _output: RenderTarget;\r\n constructor(param?: any) {\r\n param = param || {};\r\n this._inputFilter = param.filter || GL.NEAREST;\r\n this._inputWrap = param.wrap || GL.REPEAT;\r\n this._outputSize = param.size || [2048, 2048];\r\n this._computeTarget = BigTri({\r\n fs: `\r\n #define SHADER_NAME COLOR_MATCH_COUMPUTE_TARGET\r\n precision highp float; \r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n #ifdef HAS_SOURCE_TEX\r\n uniform sampler2D sourceTexture;\r\n #else\r\n uniform vec3 sourceColor;\r\n #endif\r\n uniform vec3 targetColor;\r\n uniform float mask_hue;\r\n uniform float mask_chroma;\r\n uniform float mask_luma;\r\n uniform float color_variation_hue;\r\n uniform float color_variation_chroma;\r\n uniform float color_variation_luma;\r\n vec3 hcl2rgb(vec3 X) { \r\n\r\n float H6 = X.x * 6.0;\r\n float temp = (1.0 - abs(mod(H6, 2.0) - 1.0)) * X.y;\r\n vec3 tempRGB;\r\n \r\n if(0.0 <= H6 && H6 <= 1.0) {\r\n tempRGB = vec3(X.y, temp, 0.0);\r\n } \r\n else if(1.0 < H6 && H6 <= 2.0){\r\n tempRGB = vec3(temp, X.y, 0.0);\r\n }\r\n else if(2.0 < H6 && H6 <= 3.0){\r\n tempRGB = vec3(0.0, X.y, temp);\r\n }\r\n else if(3.0 < H6 && H6 <= 4.0){\r\n tempRGB = vec3(0.0, temp, X.y);\r\n }\r\n else if(4.0 < H6 && H6 <= 5.0){\r\n tempRGB = vec3(temp, 0.0, X.y);\r\n }\r\n else if(5.0 < H6 && H6 <= 6.0){\r\n tempRGB = vec3(X.y, 0.0, temp);\r\n } else {\r\n tempRGB= vec3(0.0);\r\n }\r\n float tempLuma = dot(tempRGB, vec3(0.299, 0.587, 0.114));\r\n vec3 RGB = tempRGB + vec3(X.z - tempLuma);\r\n return RGB;\r\n }\r\n\r\n vec3 rgb2hcl(vec3 X){\r\n float L = dot(X, vec3(0.299, 0.587, 0.114));\r\n float M = max(X.r, max(X.g, X.b));\r\n float m = min(X.r, min(X.g, X.b));\r\n float C = M - m;\r\n float H;\r\n if(abs(C) <= 0.0001) {\r\n H = 0.0;\r\n } \r\n else if(abs(M - X.r) <= 0.0001) {\r\n H = mod((X.g - X.b) / C, 6.0);\r\n } \r\n else if(abs(M - X.g) <= 0.0001) {\r\n H = (X.b - X.r) / C + 2.0;\r\n } \r\n else if(abs(M - X.b) <= 0.0001) {\r\n H = (X.r - X.g) / C + 4.0;\r\n } else {\r\n H = 1.0;\r\n }\r\n \r\n H = H / 6.0;\r\n return vec3(H, C, L);\r\n }\r\n void main() {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n vec3 ohcl = rgb2hcl(texture2D(tex, uv).rgb);\r\n #ifdef HAS_SOURCE_TEX\r\n vec3 shcl = rgb2hcl(texture2D(sourceTexture, uv).rgb);\r\n #else\r\n vec3 shcl = rgb2hcl(sourceColor);\r\n #endif\r\n \r\n vec3 deltaHcl = ohcl - shcl;\r\n float absDeltaH = abs(deltaHcl.x);\r\n \r\n float deltaH = min(1. - absDeltaH, absDeltaH);\r\n float deltaC = abs(deltaHcl.y);\r\n float deltaL = abs(deltaHcl.z);\r\n \r\n float hRange = mask_hue / 360. * 0.5 ;\r\n float cRange = mask_chroma * 0.5;\r\n float lRange = mask_luma * 0.5;\r\n \r\n float alpha = 0.5;\r\n if(deltaH <= hRange && deltaC <= cRange && deltaL <= lRange) {\r\n alpha = 1.;\r\n } else {\r\n alpha = 0.;\r\n } \r\n vec3 variation_hcl = vec3(color_variation_hue / 360., color_variation_chroma, color_variation_luma) * deltaHcl;\r\n vec3 thcl = rgb2hcl(targetColor);\r\n thcl += variation_hcl;\r\n float H = mod(thcl.x, 1.);\r\n float C = max(thcl.y, 0.);\r\n float L = max(thcl.z, 0.);\r\n gl_FragColor = vec4(hcl2rgb(vec3(H, C, L)), alpha);\r\n }`,\r\n });\r\n\r\n this._splitAlpha = BigTri({\r\n fs: `\r\n precision highp float;\r\n #define SHADER_NAME COLOR_MATCH_SPLIT_ALPHA\r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n void main () {\r\n float alpha = texture2D(tex, gl_FragCoord.xy / size).a;\r\n gl_FragColor = vec4(alpha, alpha, alpha, 1.);\r\n }\r\n `,\r\n });\r\n\r\n this._histogram_scan_shader = BigTri({\r\n fs: `\r\n #define SHADER_NAME COLOR_MATCH_HISTOGRAM_SCAN\r\n precision highp float;\r\n float histogram_scan(float gray, float position, float contrast) {\r\n\r\n float t = 1.0 - position;\r\n float A = (max(t, 0.5) - 0.5) * 2.0;\r\n float B = min(t * 2.0, 1.0);\r\n \r\n float X = clamp(contrast * 0.5, 0., 1.);\r\n float minInput = mix(A, B, X); //0.95 /2\r\n float maxInput = mix(B, A, X); // 1- 0.95 /2\r\n \r\n return clamp((gray - minInput) / (maxInput - minInput), 0., 1.);\r\n }\r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n void main() {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n float gray = texture2D(tex, uv).r;\r\n gray = histogram_scan(gray, 0.5, 0.95);\r\n gl_FragColor = vec4(gray, gray, gray, 1.);\r\n }\r\n `,\r\n });\r\n\r\n this._withoutMaskBlit = BigTri({\r\n fs: `\r\n #define SHADER_NAME COLOR_MATCH_WITHOUT_MASK_BLIT\r\n precision highp float;\r\n uniform sampler2D targetTex;\r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n \r\n void main() {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n gl_FragColor = vec4(texture2D(targetTex, uv).rgb, texture2D(tex, uv).a);\r\n }\r\n `,\r\n });\r\n\r\n this._maskBlit = BigTri({\r\n fs: `\r\n #define SHADER_NAME COLOR_MATCH_MASK_BLIT\r\n precision highp float;\r\n uniform sampler2D targetTex;\r\n uniform sampler2D tex;\r\n uniform sampler2D opacityTex;\r\n uniform vec2 size;\r\n \r\n void main() {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n vec4 background = texture2D(tex, uv);\r\n vec4 foreground = vec4(texture2D(targetTex, uv).rgb, background.a);\r\n float opacity = texture2D(opacityTex, uv).r;\r\n gl_FragColor = mix(background, foreground, opacity);\r\n }\r\n `,\r\n });\r\n\r\n this._mean = new MeanPass();\r\n this._target = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n this._targetAlpha = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n this._blurHQ = new BlurHQPass({ size: this._outputSize });\r\n this._scan = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n this._output = RenderTarget.createU84(\r\n this._outputSize[0],\r\n this._outputSize[1]\r\n );\r\n }\r\n\r\n render(\r\n canvas,\r\n tex,\r\n {\r\n sourceMode = ColorMatchPass.AVERAGE,\r\n sourceColor = [0.5, 0.5, 0.5],\r\n sourceTexture,\r\n targetColor = [0.5, 0.5, 0.5],\r\n color_variation_hue = 0,\r\n color_variation_chroma = 1,\r\n color_variation_luma = 1,\r\n useMask = true,\r\n mask_hue = 30,\r\n mask_chroma = 0.5,\r\n mask_luma = 0.5,\r\n mask_blur = 0,\r\n mask_smoothness = 0,\r\n }\r\n ) {\r\n if (sourceMode == ColorMatchPass.AVERAGE) {\r\n sourceTexture = this._mean.render(canvas, tex);\r\n }\r\n if (sourceMode == ColorMatchPass.TEXTURE && !sourceTexture) {\r\n console.error(\"no source texture with source-texture-mode\");\r\n }\r\n\r\n if (sourceTexture) {\r\n this._computeTarget.defines = \"#define HAS_SOURCE_TEX\\n\";\r\n sourceTexture.wrapS = this._inputWrap;\r\n sourceTexture.wrapT = this._inputWrap;\r\n sourceTexture.minFilter = this._inputFilter;\r\n sourceTexture.magFilter = this._inputFilter;\r\n } else {\r\n this._computeTarget.defines = \"\";\r\n }\r\n\r\n tex.wrapS = this._inputWrap;\r\n tex.wrapT = this._inputWrap;\r\n tex.minFilter = this._inputFilter;\r\n tex.magFilter = this._inputFilter;\r\n\r\n canvas.context.bindRenderTarget(this._target);\r\n canvas.draw(this._computeTarget, {\r\n uniforms: {\r\n size: this._outputSize,\r\n tex,\r\n sourceColor,\r\n sourceTexture,\r\n targetColor,\r\n mask_hue,\r\n mask_chroma,\r\n mask_luma,\r\n color_variation_hue,\r\n color_variation_chroma,\r\n color_variation_luma,\r\n },\r\n });\r\n\r\n this._target.colorTexture.wrapS = this._inputWrap;\r\n this._target.colorTexture.wrapT = this._inputWrap;\r\n this._target.colorTexture.minFilter = this._inputFilter;\r\n this._target.colorTexture.magFilter = this._inputFilter;\r\n if (useMask) {\r\n //split alpha\r\n canvas.context.bindRenderTarget(this._targetAlpha);\r\n canvas.draw(this._splitAlpha, {\r\n uniforms: { size: this._outputSize, tex: this._target.colorTexture },\r\n });\r\n //smooth\r\n const smoothTex = this._blurHQ.render(\r\n canvas,\r\n this._targetAlpha.colorTexture,\r\n { intensity: mask_smoothness, quality: 1 }\r\n );\r\n //scan\r\n smoothTex.wrapS = this._inputWrap;\r\n smoothTex.wrapT = this._inputWrap;\r\n smoothTex.minFilter = this._inputFilter;\r\n smoothTex.magFilter = this._inputFilter;\r\n canvas.context.bindRenderTarget(this._scan);\r\n canvas.draw(this._histogram_scan_shader, {\r\n uniforms: { size: this._outputSize, tex: smoothTex },\r\n });\r\n //blur\r\n const blurTex = this._blurHQ.render(canvas, this._scan.colorTexture, {\r\n intensity: mask_blur,\r\n quality: 1,\r\n });\r\n //mask blit\r\n blurTex.wrapS = this._inputWrap;\r\n blurTex.wrapT = this._inputWrap;\r\n blurTex.minFilter = this._inputFilter;\r\n blurTex.magFilter = this._inputFilter;\r\n canvas.context.bindRenderTarget(this._output);\r\n canvas.draw(this._maskBlit, {\r\n uniforms: {\r\n size: this._outputSize,\r\n tex,\r\n targetTex: this._target.colorTexture,\r\n opacityTex: blurTex,\r\n },\r\n });\r\n } else {\r\n canvas.context.bindRenderTarget(this._output);\r\n canvas.draw(this._withoutMaskBlit, {\r\n uniforms: {\r\n size: this._outputSize,\r\n tex,\r\n targetTex: this._target.colorTexture,\r\n },\r\n });\r\n }\r\n\r\n return this._output.colorTexture;\r\n }\r\n\r\n release() {\r\n this._mean.release();\r\n this._target.release();\r\n this._targetAlpha.release();\r\n this._blurHQ.release();\r\n this._scan.release();\r\n this._output.release();\r\n }\r\n}\r\n\r\nclass ScreenPass {\r\n _blit: BigTri;\r\n constructor() {\r\n this._blit = BigTri({\r\n fs: `\r\n precision highp float;\r\n #define SHADER_NAME SCREEN\r\n uniform sampler2D tex;\r\n uniform vec2 size;\r\n void main () {\r\n vec2 uv = gl_FragCoord.xy / size;\r\n gl_FragColor = texture2D(tex, uv);\r\n }\r\n `,\r\n });\r\n }\r\n\r\n render(canvas, input) {\r\n canvas.context.setScreenViewport([0, 0, canvas.width, canvas.height]);\r\n\r\n canvas.context.bindRenderTarget(null);\r\n canvas.context.clear();\r\n\r\n if (!input) return;\r\n input.wrapS = GL.REPEAT;\r\n input.wrapT = GL.REPEAT;\r\n input.magFilter = GL.NEAREST;\r\n input.minFilter = GL.NEAREST;\r\n canvas.draw(this._blit, {\r\n uniforms: {\r\n size: [canvas.width, canvas.height],\r\n inputSize: [input.width, input.height],\r\n tex: input,\r\n },\r\n });\r\n }\r\n}\r\nlet ColorReplacerInstance = null;\r\n\r\nconst defaultParams = {\r\n sourceMode: ColorMatchPass.AVERAGE,\r\n sourceColor: [0.5, 0.5, 0.5],\r\n targetColor: [0.5, 0.5, 0.5],\r\n color_variation_hue: 0,\r\n color_variation_chroma: 1,\r\n color_variation_luma: 1,\r\n useMask: true,\r\n mask_hue: 30,\r\n mask_chroma: 0.5,\r\n mask_luma: 0.5,\r\n mask_blur: 0,\r\n mask_smoothness: 0,\r\n};\r\n\r\nexport const DefaultMatchColorParams = { ...defaultParams };\r\n\r\nexport class ColorReplacer {\r\n _colorMatch: ColorMatchPass;\r\n _screen: ScreenPass;\r\n _canvas: WebGLCanvas;\r\n _baseTexture: any;\r\n\r\n constructor(canvas?: HTMLCanvasElement) {\r\n this._colorMatch = new ColorMatchPass();\r\n this._screen = new ScreenPass();\r\n\r\n if (!canvas) {\r\n canvas = document.createElement(\"canvas\");\r\n }\r\n canvas.width = 2048;\r\n canvas.height = 2048;\r\n this._canvas = new WebGLCanvas(canvas);\r\n\r\n this._canvas._currentWidth = 2048;\r\n this._canvas._currentHeight = 2048;\r\n }\r\n\r\n static getInstance() {\r\n if (ColorReplacerInstance === null) {\r\n ColorReplacerInstance = new ColorReplacer();\r\n }\r\n return ColorReplacerInstance;\r\n }\r\n\r\n async setBaseTextur(imageUrl: string) {\r\n console.log(\"==>\", imageUrl);\r\n // let url = \"uv_grid_opengl.jpg\";\r\n this._baseTexture = (\r\n await loadtex({ base: imageUrl + \"?t=11\" }, { anisotropy: 1.0 })\r\n ).base;\r\n\r\n console.log(this._baseTexture);\r\n }\r\n\r\n setBaseImage(image: Image): void {\r\n this._baseTexture = new Texture({\r\n source: image,\r\n mipMaping: false,\r\n flipY: true,\r\n anisotropy: 1.0,\r\n });\r\n }\r\n\r\n replace(params: any) {\r\n if (!this._baseTexture) return;\r\n\r\n params = Object.assign(defaultParams, params);\r\n\r\n console.log(params);\r\n\r\n const replaced = this._colorMatch.render(\r\n this._canvas,\r\n this._baseTexture,\r\n params\r\n );\r\n this._screen.render(this._canvas, replaced);\r\n return this._canvas.canvas;\r\n }\r\n}\r\n","import { nanoid } from \"nanoid\";\r\n\r\nexport function createUid(type = \"PackSource\") {\r\n return `${type}_${nanoid()}`;\r\n}\r\n\r\nexport function createOss() {\r\n return { url: \"\", size: 0 };\r\n}\r\n\r\nexport function createDiamond() {\r\n return {\r\n brightness: 1.0,\r\n color: [0.4, 0.4, 0.4],\r\n scaleX: 1,\r\n scaleY: 1,\r\n };\r\n}\r\n\r\nexport function createUV() {\r\n return { scale: 1, rotate: 0, offsetX: 0.5, offsetY: 0 };\r\n}\r\n\r\nexport function createBackground() {\r\n return {\r\n type: 1,\r\n color: [1, 1, 1],\r\n image: createOss(),\r\n };\r\n}\r\n\r\ntype MatFeature = {\r\n factor: number;\r\n color: number[];\r\n texture: {\r\n url: string;\r\n size: number;\r\n };\r\n useTexture: boolean;\r\n enable: boolean;\r\n};\r\n\r\nexport function createTexture<\r\n T extends Partial<MatFeature>,\r\n R extends T & { texture: any; useTexture: boolean }\r\n>(options: T): { [name in keyof R]: R[name] } {\r\n return Object.assign(\r\n { texture: createOss(), useTexture: false },\r\n options\r\n ) as any;\r\n}\r\n","import { createOss } from \"./create\";\r\n\r\nexport class PackEnvBackground {\r\n color = [1, 1, 1];\r\n image = createOss();\r\n type = 1;\r\n}","import { cloneDeep, isEqual } from \"lodash\";\r\nimport { createUid } from \"./create\";\r\n\r\ntype PackSourceType = typeof PackSource;\r\n\r\n// 资源基础类型\r\nexport abstract class PackSource {\r\n // 通过初始数据创建类型资源\r\n static create<T extends PackSourceType>(\r\n this: T,\r\n //@ts-ignore\r\n data: Partial<InstanceType<T>> = {}\r\n //@ts-ignore\r\n ): InstanceType<T> {\r\n if (data instanceof this) {\r\n //@ts-ignore\r\n return data as InstanceType<T>;\r\n }\r\n //@ts-ignore\r\n data.id || (data.id = createUid(this.prototype.constructor.name));\r\n const newSource = new (this as any)();\r\n Object.assign(newSource, data);\r\n newSource.onInit?.(data);\r\n return newSource;\r\n }\r\n // 通过已有数据来源创建类型资源\r\n static createOrigin<T extends PackSourceType>(this: T, origin: PackSource) {\r\n const newSource = cloneDeep(origin);\r\n newSource.id = createUid(this.prototype.constructor.name);\r\n newSource.origin = {\r\n sourceId: origin.id,\r\n };\r\n //@ts-ignore\r\n return newSource as InstanceType<T>;\r\n }\r\n // 通过类型创建资源数组\r\n static createGroup<T extends PackSourceType>(\r\n this: T,\r\n //@ts-ignore\r\n arr?: InstanceType<T>[]\r\n ) {\r\n class PackSourceGroup extends SourceGroup<T> {}\r\n PackSourceGroup.prototype.sourceType = this;\r\n const group = new PackSourceGroup();\r\n group.init(arr);\r\n return group;\r\n }\r\n\r\n id!: string;\r\n origin?: {\r\n sourceId: string;\r\n };\r\n\r\n onInit(data: any) {\r\n void data;\r\n }\r\n\r\n isHashEqual(data: any): boolean {\r\n const options = {\r\n excludeKeys: [\"id\", \"origin\"],\r\n };\r\n const d1 = createObjByOwnKeys(this, options);\r\n const d2 = createObjByOwnKeys(data, options);\r\n return isEqual(d1, d2);\r\n }\r\n}\r\n\r\n// 资源包类型,一类资源的数组类型\r\n//@ts-ignore\r\nexport abstract class SourceGroup<T extends PackSourceType> extends Array<\r\n//@ts-ignore\r\n InstanceType<T>\r\n> {\r\n declare sourceType: T;\r\n //@ts-ignore\r\n init(list?: InstanceType<T>[]) {\r\n this.length = 0;\r\n list && this.push(...list.map((d) => this.sourceType.create(d)));\r\n }\r\n\r\n //@ts-ignore\r\n add(data: InstanceType<T>) {\r\n if (data.origin?.sourceId) {\r\n const { sourceId } = data.origin;\r\n const currItem = this.find((d) => {\r\n if (sourceId === d.id || sourceId === d.origin?.sourceId) {\r\n if (d.isHashEqual(data)) {\r\n return true;\r\n }\r\n }\r\n });\r\n if (currItem) return currItem;\r\n }\r\n this.push(data);\r\n return data;\r\n }\r\n}\r\n\r\nfunction createObjByOwnKeys(obj: object, options?: { excludeKeys?: string[] }) {\r\n const keys = new Set(Object.getOwnPropertyNames(obj));\r\n options?.excludeKeys?.forEach((key) => {\r\n keys.delete(key);\r\n });\r\n const newObj: any = {};\r\n keys.forEach((key) => {\r\n newObj[key] = obj[key as keyof typeof obj];\r\n });\r\n return newObj;\r\n}\r\n","import { PackEnvBackground } from \"./PackEnvBackground\";\r\nimport { createOss } from \"./create\";\r\nimport { PackSource } from \"./extends\";\r\n\r\nexport class PackEnv extends PackSource {\r\n name = \"\";\r\n cusNum = \"\";\r\n thumbnail = createOss();\r\n hdr = createOss();\r\n file = createOss();\r\n background = new PackEnvBackground();\r\n\r\n options = {\r\n rotation: 0,\r\n exposure: 1,\r\n };\r\n\r\n toneMap = {\r\n method: 1, //0 \"linear\" 值0 \"reinhard\" 值 1 \"filmic”:值2\r\n exposure: 1.0,\r\n brightness: 0.1,\r\n contrast: 0.06,\r\n saturation: 1,\r\n };\r\n\r\n config: any = null;\r\n userData: any;\r\n}\r\n","import { createDiamond, createOss, createTexture, createUV } from \"./create\";\r\nimport { PackSource } from \"./extends\";\r\n\r\nexport class PackMat extends PackSource {\r\n name = \"未命名\";\r\n cusNum = \"未命名\";\r\n thumbnail = createOss();\r\n classType: \"pbr\" | \"diamond\" | \"cuscolor\" = \"pbr\";\r\n type: \"meta\" | \"spec\" = \"meta\";\r\n uvMap: \"box\" | \"uv\" = \"box\";\r\n cullFace = \"\";\r\n diamond = createDiamond();\r\n normal = createTexture({\r\n factor: 1,\r\n });\r\n metalness = createTexture({\r\n factor: 0,\r\n });\r\n roughness = createTexture({\r\n factor: 1,\r\n });\r\n gloss = createTexture({\r\n factor: 1,\r\n });\r\n albedo = createTexture({\r\n color: [0, 1, 0],\r\n });\r\n diffuse = createTexture({\r\n color: [0, 1, 0],\r\n });\r\n specular = createTexture({ \r\n color: [1, 1, 1],\r\n });\r\n displace = createTexture({\r\n factor: 1,\r\n enable: false,\r\n });\r\n opacity = createTexture({\r\n factor: 1,\r\n enable: false,\r\n });\r\n uv = createUV();\r\n cusUv = createUV();\r\n userData: any;\r\n // from?: MatFrom;\r\n\r\n colorMatch?: any;\r\n generateType?: \"colormatch\" | \"tech\" | undefined;\r\n}","import { createOss } from \"./create\";\r\nimport { PackSource } from \"./extends\";\r\n\r\nexport class PackProductComp extends PackSource {\r\n matId = \"\";\r\n groupId = \"\";\r\n uvMap = createOss();\r\n uvsize = { width: 0, height: 0 };\r\n name = \"\";\r\n index = 0;\r\n visible = true;\r\n locked = false; //当前部件是否被锁定\r\n userData: any;\r\n}\r\n","const _defaultText = { url: \"\", size: 0 };\r\n\r\nexport default function createTextureMat(image: { url: string; size: number }) {\r\n return {\r\n cullFace: \"\",\r\n metalnessWorkFlow: true,\r\n classType: \"pbr\",\r\n uvProjection: true,\r\n uvtransform: { offsetX: 0, offsetY: 0, rotate: 0, scale: 1 },\r\n channels: {\r\n Diamond: {\r\n brightness: 1.0,\r\n color: [0.4, 0.4, 0.4],\r\n scaleX: 1,\r\n scaleY: 1,\r\n },\r\n\r\n Albedo: {\r\n color: [0.509803950786591, 0.474509835243225, 0.474509835243225],\r\n texture: image,\r\n },\r\n Roughness: {\r\n factor: 1,\r\n invert: false,\r\n texture: { ..._defaultText },\r\n },\r\n\r\n Emissive: {\r\n color: [0, 0, 0],\r\n factor: 1,\r\n enable: false,\r\n },\r\n\r\n NormalMap: {\r\n enable: true,\r\n factor: 1,\r\n flipY: false,\r\n texture: { ..._defaultText },\r\n },\r\n\r\n BumpMap: {\r\n enable: false,\r\n factor: 1,\r\n texture: { ..._defaultText },\r\n },\r\n\r\n Opacity: {\r\n enable: false,\r\n type: \"ALPHA_BLEND\",\r\n factor: 1,\r\n invert: false,\r\n sampleChannel: \"a\",\r\n refractionTint: [1, 1, 1],\r\n refractUseDiffuse: false,\r\n refractUseShininessMap: false,\r\n IOR: 1,\r\n roughnessFactor: 0,\r\n texture: { ..._defaultText },\r\n },\r\n\r\n AO: {\r\n enable: false,\r\n occludeSpecular: false,\r\n factor: 0,\r\n texture: { ..._defaultText },\r\n },\r\n\r\n MetalnessPBR: {\r\n factor: 0,\r\n texture: { ..._defaultText },\r\n },\r\n SpecularF0: 0.5,\r\n ClearCoat: {\r\n enable: false,\r\n thickness: 5,\r\n intensity: 1,\r\n color: [1, 1, 1],\r\n reflectivity: 0,\r\n roughness: {\r\n factor: 0.04,\r\n },\r\n normalmap: {\r\n factor: 1,\r\n flipY: false,\r\n },\r\n },\r\n Displacement: {\r\n enable: false,\r\n factor: 0,\r\n texture: { ..._defaultText },\r\n },\r\n CavityMap: {\r\n enable: false,\r\n factor: 0,\r\n },\r\n },\r\n };\r\n}\r\n","import { PackMat } from \"./Pack\";\r\nimport createTextureMat from \"./defaultMat\";\r\nexport default class MatUtils {\r\n static createNativeMat(colorcard: PackMat) {\r\n const mat = createTextureMat({ url: \"\", size: 0 });\r\n if (!colorcard) {\r\n return mat;\r\n }\r\n const mat3d = colorcard;\r\n mat.metalnessWorkFlow = mat3d.type != \"spec\";\r\n mat.classType = mat3d.classType || \"pbr\";\r\n if (mat.classType == \"diamond\") {\r\n mat.channels.Diamond = { ...colorcard.diamond };\r\n return mat;\r\n }\r\n\r\n if (mat3d.type == \"spec\") {\r\n mat.channels.Albedo.color = mat3d.diffuse.color;\r\n if (mat3d.diffuse.useTexture) {\r\n mat.channels.Albedo.texture = mat3d.diffuse.texture;\r\n }\r\n\r\n mat.channels.Roughness.factor = mat3d.gloss.factor;\r\n if (mat3d.gloss.useTexture) {\r\n mat.channels.Roughness.texture = mat3d.gloss.texture;\r\n }\r\n\r\n //@ts-ignore\r\n mat.channels.MetalnessPBR.factor = mat3d.specular.color || [0, 0, 0];\r\n if (mat3d.specular.useTexture) {\r\n mat.channels.MetalnessPBR.texture = mat3d.specular.texture;\r\n }\r\n } else {\r\n //这里是金属流实现\r\n mat.channels.Albedo.color = mat3d.albedo?.color || [0, 1, 0];\r\n if (mat3d.albedo?.useTexture) {\r\n mat.channels.Albedo.texture = mat3d.albedo.texture;\r\n }\r\n\r\n if (mat3d.roughness) {\r\n mat.channels.Roughness.factor = mat3d.roughness?.factor;\r\n if (typeof mat3d.roughness?.factor !== \"number\") {\r\n mat.channels.Roughness.factor = 1;\r\n }\r\n if (mat3d.roughness.useTexture) {\r\n mat.channels.Roughness.texture = mat3d.roughness.texture;\r\n }\r\n }\r\n\r\n mat.channels.MetalnessPBR.factor = mat3d.metalness?.factor || 0;\r\n if (mat3d.metalness?.useTexture) {\r\n mat.channels.MetalnessPBR.texture = mat3d.metalness.texture;\r\n }\r\n }\r\n\r\n if (mat3d.uv) {\r\n //@ts-ignore\r\n mat.uvtransform = { ...mat3d.uv };\r\n }\r\n \r\n if (mat3d.cusUv) {\r\n if (mat3d.cusUv.offsetX) mat.uvtransform.offsetX += mat3d.cusUv.offsetX;\r\n if (mat3d.cusUv.offsetY) mat.uvtransform.offsetY += mat3d.cusUv.offsetY;\r\n if (mat3d.cusUv.rotate) mat.uvtransform.rotate += mat3d.cusUv.rotate;\r\n\r\n if (mat3d.cusUv.scale) {\r\n const orginScale = mat.uvtransform.scale;\r\n let scale = mat3d.cusUv.scale;\r\n if (scale < 0) {\r\n //放大\r\n scale = (1 - 0.9 * scale) * orginScale;\r\n } else {\r\n //缩小\r\n scale = orginScale * (1 - 0.09 * scale);\r\n }\r\n mat.uvtransform.scale = scale;\r\n }\r\n }\r\n\r\n if (mat3d.normal) {\r\n mat.channels.NormalMap.enable = true;\r\n mat.channels.NormalMap.texture = mat3d.normal.texture;\r\n }\r\n\r\n if (mat3d.displace && mat3d.displace.enable) {\r\n mat.channels.Displacement.enable = true;\r\n mat.channels.Displacement.texture = mat3d.displace.texture;\r\n mat.channels.Displacement.factor = mat3d.displace.factor;\r\n }\r\n\r\n if (mat3d.opacity && mat3d.opacity.enable) {\r\n mat.channels.Opacity.enable = true;\r\n mat.channels.Opacity.factor = mat3d.opacity.factor;\r\n mat.channels.Opacity.texture = mat3d.opacity.texture;\r\n }\r\n\r\n //@ts-ignore\r\n mat.uvProjection = mat3d.uvProjection;\r\n if (mat.uvProjection == undefined) {\r\n if (!mat3d.uvMap) {\r\n mat.uvProjection = true; //默认box映射\r\n } else {\r\n mat.uvProjection = mat3d.uvMap == \"box\";\r\n }\r\n }\r\n\r\n return mat;\r\n }\r\n}\r\n","import { Application, MeshLoader, ResController, ResLoader } from \"@/queen3d\";\r\nimport { ProductVisitor } from \"./productVisitor\";\r\nimport { ProdcutObj } from \"./productObj\";\r\nimport { initSceneEnv } from \"./actions/env\";\r\nimport {\r\n initMatGeom,\r\n initSceneGeoms,\r\n switchSceneProdComp,\r\n} from \"./actions/geom\";\r\n\r\n// import { initSceneStickers } from \"./actions/sticker\";\r\n// import { GeomLoader } from \"./loader\";\r\nimport { reactive } from \"vue\";\r\nimport { PackMat, PackProductComp, PackSceneProduct } from \"./objects\";\r\nimport MatUtils from \"./objects/material\";\r\n\r\ntype NativeNodes = {\r\n nodes: {\r\n [prodId: string]: string[]; // 单品id: compName[]\r\n };\r\n};\r\nclass GeomLoader extends ResLoader {\r\n async load(option: any) {\r\n let url = option.osgjs.url;\r\n url = url.replace(\r\n \"sku3d-test.obs.cn-east-3.myhuaweicloud.com\",\r\n \"obs.sku3d.com\"\r\n );\r\n return new MeshLoader().load(\r\n {\r\n id: option.id,\r\n url: url,\r\n },\r\n true,\r\n \"3.0\"\r\n );\r\n }\r\n}\r\nexport class Queen3dCtrl {\r\n queen3d = new Application();\r\n store = reactive({ showLoading: true });\r\n geomsCacher = new ResController(new GeomLoader());\r\n nativeProductMap = new Map<string, ProdcutObj>();\r\n nativeMatMap = new Map<string, NativeNodes>();\r\n config = { defaultAlbeoColor: [0, 1, 0] };\r\n\r\n currPackScene!: any;\r\n\r\n destroy = () => {\r\n this.queen3d.destory();\r\n };\r\n\r\n init(dom: HTMLElement) {\r\n const { queen3d } = this;\r\n queen3d.init(dom, {\r\n enablePicker: true,\r\n clickedOutline: true,\r\n });\r\n queen3d.afterInit(() => {\r\n queen3d.showGizmo(false);\r\n queen3d.gizmoAttach(null);\r\n if (queen3d.picker) {\r\n queen3d.picker.enable = false;\r\n }\r\n\r\n // const app = queen3d.getAppInstance();\r\n // app.on(\"tap:click\", (geom: any) => {\r\n // const compName = geom?._userdata?.name;\r\n // if (!compName) return;\r\n // const sceneProductId = new ProductVisitor(geom).sceneProdId;\r\n // switchSceneProdComp.call(this, sceneProductId, compName);\r\n // });\r\n });\r\n }\r\n packSource: any;\r\n async loadPackSource(source: any) {\r\n this.packSource = source;\r\n try {\r\n const queen3d = this.queen3d;\r\n queen3d.getAppInstance().scene?.clean();\r\n const scene = source.scenes[0];\r\n\r\n // 初始化环境光、光源、背景\r\n initSceneEnv(queen3d, source, scene, true);\r\n\r\n // 初始化模型\r\n await initSceneGeoms(source, scene, this.geomsCacher);\r\n\r\n //初始化单品\r\n await this.initSceneProducts(scene);\r\n\r\n // 初始化贴图\r\n //initSceneStickers.call(this);\r\n\r\n queen3d.updateController();\r\n queen3d.getAppInstance().setViewMode(\"left-top\");\r\n queen3d.redraw();\r\n\r\n // 初始化材质\r\n await this.initSceneMats(scene);\r\n\r\n this.queen3d.redraw();\r\n } finally {\r\n // queenApi.hideLoading();\r\n }\r\n }\r\n async loadMatSource(source: any) {\r\n const queen3d = this.queen3d;\r\n queen3d.getAppInstance().scene?.clean();\r\n const meshObj = await initMatGeom(source, this.geomsCacher);\r\n queen3d.addChild(meshObj.geom);\r\n queen3d.updateController();\r\n queen3d.getAppInstance().setViewMode(\"left-top\");\r\n queen3d.redraw();\r\n const mat = this.createNativeMat(source.mat);\r\n await meshObj.setGeomMat(\"fabric\", mat);\r\n queen3d.redraw();\r\n }\r\n\r\n async initSceneProducts(scene: any) {\r\n for (let i = 0; i < scene.products.length; i++) {\r\n const prod = scene.products[i];\r\n if (prod.visible == false) continue;\r\n\r\n const prodObj = await this.createSceneProductObj(prod);\r\n if (!prodObj) continue;\r\n\r\n this.queen3d.addChild(prodObj.node);\r\n }\r\n }\r\n findGeomDef(id: string) {\r\n return this.packSource.geoms.find((item: any) => item.id == id);\r\n }\r\n findProductDef(id: string) {\r\n return this.packSource.products.find((item: any) => item.id == id);\r\n }\r\n async createProductObj(\r\n prodId: string,\r\n sceneProdId: string\r\n ): Promise<ProdcutObj | undefined> {\r\n const prodConf = this.findProductDef(prodId);\r\n if (!prodConf) return;\r\n\r\n const geomCon = this.findGeomDef(prodConf.geomId);\r\n if (!geomCon) return;\r\n\r\n const meshObj = await this.geomsCacher.load(geomCon.osgjs.url, geomCon);\r\n\r\n return meshObj\r\n ? new ProdcutObj(meshObj, sceneProdId, false, geomCon.shadow?.url)\r\n : undefined;\r\n }\r\n\r\n // 添加材质\r\n addMat(mat: PackMat) {\r\n return this.packSource.mats.push(mat);\r\n }\r\n\r\n async createSceneProductObj(prod: PackSceneProduct) {\r\n const prodObj = await this.createProductObj(prod.prodId, prod.id);\r\n if (!prodObj) return;\r\n prodObj.on(\"onload\", () => {\r\n this.queen3d.redraw();\r\n });\r\n this.nativeProductMap.set(prod.id, prodObj);\r\n\r\n if (prodObj.nodeShadow) {\r\n prodObj.nodeShadow.setNodeMask(!prod.noShadow ? -1 : 0);\r\n }\r\n const srcProd = this.findProductDef(prod.prodId);\r\n\r\n const defaultMat = PackMat.create();\r\n defaultMat.albedo.color = this.config.defaultAlbeoColor || [1, 1, 0];\r\n\r\n if (!srcProd?.components || srcProd.components.length < 1) {\r\n this.addMat(defaultMat);\r\n const comps = PackProductComp.createGroup();\r\n const geoms = prodObj.mesh.getGeoms();\r\n geoms.forEach((g: any) => {\r\n comps.add(\r\n PackProductComp.create({\r\n name: g.node,\r\n matId: defaultMat.id,\r\n index: g.index,\r\n visible: true,\r\n userData: null,\r\n })\r\n );\r\n });\r\n srcProd && (srcProd.components = comps);\r\n } else {\r\n //根据当前模型的mesh顺序重新排序\r\n const geoms = prodObj.mesh.getGeoms();\r\n const comps = PackProductComp.createGroup();\r\n geoms.forEach((g: any) => {\r\n const c = srcProd?.components.find((c: any) => c.name == g.node);\r\n if (c) {\r\n comps.push(c);\r\n if (c.visible === undefined) c.visible = true;\r\n } else {\r\n comps.push(\r\n PackProductComp.create({\r\n name: g.node,\r\n matId: defaultMat.id,\r\n index: g.index,\r\n visible: true,\r\n userData: null,\r\n })\r\n );\r\n this.addMat(defaultMat);\r\n }\r\n });\r\n srcProd && (srcProd.components = comps);\r\n srcProd?.components.forEach((c: any) => {\r\n if (!c.matId) c.matId = defaultMat.id;\r\n if (c.visible === undefined) c.visible = true;\r\n });\r\n }\r\n\r\n this.nativeProductMap.set(prod.prodId, prodObj);\r\n\r\n //设置transform\r\n prodObj.updateTransform(prod.transform);\r\n //@ts-ignore\r\n prodObj.node.setNodeMask(prod.visible ? -1 : 0);\r\n\r\n //设置隐藏的部件\r\n const prodDef = this.findProductDef(prod.prodId);\r\n const components = prodDef?.components || [];\r\n const n = components.length;\r\n for (let k = 0; k < n; k++) {\r\n const comp = components[k];\r\n if (comp.visible === false) {\r\n prodObj.mesh.setGeomVisible(comp.name, false);\r\n }\r\n const m = this.createNativeMat(defaultMat);\r\n await prodObj.mesh.setGeomMat(comp.name, m as any);\r\n }\r\n return prodObj;\r\n }\r\n\r\n createNativeMat(colorCardConf: any) {\r\n return MatUtils.createNativeMat(colorCardConf);\r\n }\r\n\r\n async initSceneMats(scene: any) {\r\n const mats = this.initNativeMatMap(scene);\r\n\r\n for (const matId in mats) {\r\n this.nativeMatMap.set(matId, { nodes: mats[matId] as any });\r\n await this.initSceneMat(matId);\r\n }\r\n }\r\n\r\n initNativeMatMap(scene: any) {\r\n const mats: any = {};\r\n this.nativeMatMap.clear();\r\n\r\n scene.products.forEach((prod: any) => {\r\n const nativeProd = this.nativeProductMap.get(prod.id);\r\n const packProd = this.findProductDef(prod.prodId);\r\n if (!nativeProd || !packProd) return;\r\n\r\n packProd.components.forEach((comp: any) => {\r\n const matItem = mats[comp.matId] || (mats[comp.matId] = {});\r\n const matProdItem = matItem[prod.id] || (matItem[prod.id] = []);\r\n matProdItem.push(comp.name);\r\n });\r\n });\r\n\r\n Object.entries(mats).forEach(([matId, nodes]: [string, any]) => {\r\n this.nativeMatMap.set(matId, { nodes });\r\n });\r\n return mats;\r\n }\r\n findMatDef(id: string) {\r\n return this.packSource.mats.find((item: any) => item.id == id);\r\n }\r\n\r\n async initSceneMat(matId: string) {\r\n const mat = this.findMatDef(matId);\r\n const matNodes = this.nativeMatMap.get(matId)?.nodes;\r\n if (!matNodes || !mat) return;\r\n this.initPackMat(mat);\r\n\r\n // console.log(\"native origin=>\", mat);\r\n\r\n //@ts-ignore\r\n mat.cusUv = null;\r\n // mat.cusUv.offsetY = 0;\r\n // mat.cusUv.scale = 0;\r\n\r\n const nativeMat: any = this.createNativeMat(mat);\r\n // console.log(\"native mat=>\", nativeMat);\r\n\r\n for (const prodId in matNodes) {\r\n const nativeProd = this.nativeProductMap.get(prodId);\r\n if (!nativeProd) continue;\r\n for (const compName of matNodes[prodId]) {\r\n await nativeProd.mesh.setGeomMat(compName, nativeMat);\r\n }\r\n }\r\n this.queen3d.redraw();\r\n }\r\n\r\n initPackMat(mat: any) {\r\n mat.type === undefined && (mat.type = \"meta\");\r\n mat.classType === undefined && (mat.classType = \"pbr\");\r\n mat.cusUv = null;\r\n }\r\n}\r\n","import { css } from \"@linaria/core\";\nimport { defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { any, object } from \"vue-types\";\nimport { Spin } from \"ant-design-vue\";\nimport { LoadingOutlined } from \"@ant-design/icons-vue\";\nimport { Queen3dCtrl } from \"./Queen3dCtrl\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n const state = reactive({\n loading: false\n });\n const RefCanvas = ref();\n\n const initQueen = async () => {\n state.loading = true;\n const ctrl = new Queen3dCtrl();\n ctrl.init(RefCanvas.value);\n await ctrl.loadPackSource(props.src);\n state.loading = false;\n };\n\n onMounted(() => {\n initQueen();\n });\n return () => {\n return <div class={ContentStyle}>\r\n {state.loading && <Spin class={loadingStyle} indicator={<LoadingOutlined style={{\n fontSize: \"40px\",\n color: \"#fff\"\n }} />} />}\r\n <canvas ref={RefCanvas} />\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"c1e0zl9j\";\nconst loadingStyle = \"l12ccz8n\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/MeshOsgjs.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent } from \"vue\";\nimport { any, string } from \"vue-types\";\nimport MeshOsgjs from \"./MeshOsgjs\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n /* eslint-disable */\n const source = props.src.source;\n const geom = source.geoms[0];\n\n if (!geom) {\n return () => <div>数据错误!</div>;\n } //设置默认的环境球 场景\n\n\n const scene = {\n background: {\n color: [0.749, 0.749, 0.749],\n type: 1\n },\n id: \"001\",\n products: [{\n id: \"1\",\n prodId: source.products[0].id,\n transform: {\n pos: [0, 0, 0],\n rotation: [0, 0, 0, 1],\n scale: [1, 1, 1]\n },\n visible: true\n }]\n };\n source.scenes = [scene];\n\n if (geom.osgjs.url) {\n return () => <MeshOsgjs src={source} />;\n }\n\n return () => {\n return <div class={ContentStyle}>\r\n 不支持的单品格式\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"cwuhi4d\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/Mesh.linaria.css\");","import { debounce } from \"lodash\";\r\nimport {ref, Ref , onMounted, onUnmounted} from \"vue\"\r\n\r\nexport function useContainerRefWithRadio(radio:number, gap: number, contentRef: Ref) {\r\n const containerRef = ref();\r\n const resizeHandler = debounce(changeContainerStyle, 200);\r\n \r\n onMounted(() => {\r\n window.addEventListener(\"resize\", resizeHandler);\r\n });\r\n onUnmounted(() => {\r\n window.removeEventListener(\"resize\", resizeHandler);\r\n });\r\n \r\n function changeContainerStyle() {\r\n const containerEl = containerRef.value;\r\n const contentEl = contentRef.value;\r\n const width = containerEl.clientWidth;\r\n const height = containerEl.clientHeight;\r\n \r\n if (!radio) {\r\n contentEl.style = \"\";\r\n } else {\r\n const contentRatio = width / height;\r\n const contentGap = gap * 2;\r\n if (contentRatio > radio) {\r\n contentEl.style = `height:${height - contentGap}px;width:${\r\n (height - contentGap) * radio\r\n }px`;\r\n } else {\r\n contentEl.style = `width:${width - contentGap}px;height:${\r\n (width - contentGap) / radio\r\n }px`;\r\n }\r\n }\r\n }\r\n return containerRef;\r\n }","import { css } from \"@linaria/core\";\nimport { defineComponent, onMounted, reactive, ref } from \"vue\";\nimport { any } from \"vue-types\";\nimport { Spin } from \"ant-design-vue\";\nimport { LoadingOutlined } from \"@ant-design/icons-vue\";\nimport { Queen3dCtrl } from \"./Queen3dCtrl\";\nimport { useContainerRefWithRadio } from \"./utils\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n const state = reactive({\n loading: false\n });\n const RefCanvas = ref();\n const containerRef = useContainerRefWithRadio(0, 0, RefCanvas);\n\n const initQueen = async () => {\n state.loading = true;\n const ctrl = new Queen3dCtrl();\n ctrl.init(RefCanvas.value);\n await ctrl.loadPackSource(props.src);\n state.loading = false;\n };\n\n onMounted(() => {\n initQueen();\n });\n return () => {\n return <div class={ContentStyle} ref={containerRef}>\r\n {state.loading && <Spin class={loadingStyle} indicator={<LoadingOutlined style={{\n fontSize: \"40px\",\n color: \"#fff\"\n }} />} />}\r\n <canvas ref={RefCanvas} />\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"cyfieek\";\nconst loadingStyle = \"lje6630\";\nconst CanvasStyle = \"c1mmjrib\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/SceneOsgjs.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent } from \"vue\";\nimport { any, string } from \"vue-types\";\nimport SceneOsgjs from \"./SceneOsgjs\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n /* eslint-disable */\n const pack = props.src;\n const source = pack.source;\n const geom = source.geoms[0];\n\n if (!geom) {\n return () => <div>数据错误!</div>;\n }\n\n if (geom.osgjs.url) {\n return () => <SceneOsgjs src={source} />;\n }\n\n return () => {\n return <div class={ContentStyle}>\r\n 不支持的场景格式\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"c11ml4pn\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/Scene.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { any, object } from \"vue-types\";\nimport { Spin } from \"ant-design-vue\";\nimport { LoadingOutlined } from \"@ant-design/icons-vue\";\nimport { Queen3dCtrl } from \"./Queen3dCtrl\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n const state = reactive({\n loading: false\n });\n const RefCanvas = ref();\n\n const initQueen = async () => {\n state.loading = true;\n const ctrl = new Queen3dCtrl();\n ctrl.init(RefCanvas.value);\n await ctrl.loadMatSource(props.src);\n state.loading = false;\n };\n\n onMounted(() => {\n initQueen();\n });\n return () => {\n return <div class={ContentStyle}>\r\n {state.loading && <Spin class={loadingStyle} indicator={<LoadingOutlined style={{\n fontSize: \"40px\",\n color: \"#fff\"\n }} />} />}\r\n <canvas ref={RefCanvas} />\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"ctk4eb2\";\nconst loadingStyle = \"l1mi9dz2\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/MatOsgjs.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent, reactive, ref } from \"vue\";\nimport { any } from \"vue-types\";\nimport MatOsgjs from \"./MatOsgjs\";\nexport default defineComponent({\n props: {\n src: any().isRequired\n },\n\n setup(props) {\n const state = reactive({\n loading: false\n });\n const RefCanvas = ref();\n /* eslint-disable */\n\n const source = props.src.source;\n const mat = source.mat;\n\n if (!mat) {\n return () => <div>数据错误!</div>;\n }\n\n if (mat?.albedo?.texture?.url) {\n return () => <MatOsgjs src={source} />;\n }\n\n return () => {\n return <div class={ContentStyle}>不支持的材质格式</div>;\n };\n }\n\n});\nconst ContentStyle = \"c1kvi1js\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/Mat.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent } from \"vue\";\nimport { string } from \"vue-types\";\nexport default defineComponent({\n props: {\n src: string().isRequired\n },\n\n setup(props) {\n return () => {\n return <div class={ContentStyle}>\r\n <img src={props.src} />\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"c1k0h6io\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/Image.linaria.css\");","import { css } from \"@linaria/core\";\nimport { defineComponent, onMounted, reactive, ref } from \"vue\";\nimport { AssetTypes } from \"@queenjs/assets/src/const\";\nimport Mesh from \"./Mesh\";\nimport Scene from \"./Scene\";\nimport Mat from \"./Mat\";\nimport Image from \"./Image\";\nexport default defineComponent({\n setup(props) {\n const RefAsset = ref();\n const state = reactive({\n assetType: \"\",\n loaded: false,\n previewId: \"\"\n });\n onMounted(async () => {\n window.addEventListener(\"message\", e => {\n try {\n if (!e.data || typeof e.data != \"string\") {\n return;\n }\n\n const msgData = JSON.parse(e.data);\n state.assetType = msgData.assetType;\n RefAsset.value = msgData.data;\n state.previewId = Date.now() + \"\";\n console.log(\"preview=>\", msgData);\n } catch (e) {\n console.error(e);\n }\n });\n window.parent?.postMessage(JSON.stringify({\n type: \"ready\"\n }), \"*\");\n });\n\n function renderAsset() {\n if (state.assetType == AssetTypes.Mesh.id) return <Mesh src={RefAsset.value} key={state.previewId} />;\n if (state.assetType == AssetTypes.Scene.id) return <Scene src={RefAsset.value} key={state.previewId} />;\n if (state.assetType == AssetTypes.Mat.id) return <Mat src={RefAsset.value} key={state.previewId} />;\n if (state.assetType == AssetTypes.Image.id) return <Image src={RefAsset.value} key={state.previewId} />;\n return <div>\r\n \r\n </div>;\n }\n\n return () => {\n return <div class={ContentStyle}>\r\n {renderAsset()}\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"c142sydk\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/preview/index.linaria.css\");","import P from 'bluebird';\r\nimport BoundingBox from '../osg/BoundingBox';\r\nimport StateSet from '../osg/StateSet';\r\nimport Input from '../osgDB/Input';\r\nimport Registry from '../osgDB/Registry';\r\nimport BasicAnimationManager from '../osgAnimation/BasicAnimationManager';\r\nimport Skeleton from '../osgAnimation/Skeleton';\r\nimport Bone from '../osgAnimation/Bone';\r\nimport StackedTranslate from '../osgAnimation/StackedTranslate';\r\nimport StackedQuaternion from '../osgAnimation/StackedQuaternion';\r\nimport StackedScale from '../osgAnimation/StackedScale';\r\nimport RigGeometry from '../osgAnimation/RigGeometry';\r\nimport MorphGeometry from '../osgAnimation/MorphGeometry';\r\nimport channelFactory from '../osgAnimation/channel';\r\nimport animationFactory from '../osgAnimation/animation';\r\nimport notify from '../osg/notify';\r\n\r\nimport Node from '../osg/Node';\r\nimport Geometry from '../osg/Geometry';\r\nimport Texture from '../osg/Texture';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport CullFace from '../osg/CullFace';\r\nimport Image from '../osg/Image';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport UpdateBone from '../osgAnimation/UpdateBone';\r\nimport UpdateMorph from '../osgAnimation/UpdateMorph';\r\nimport UpdateMatrixTransform from '../osgAnimation/UpdateMatrixTransform';\r\nimport fileHelper from '../osgDB/fileHelper';\r\n\r\nimport Uniform from '../osg/Uniform';\r\nimport { mat4, vec3 } from '../osg/glMatrix';\r\n\r\nvar createQuatChannel = channelFactory.createQuatChannel;\r\nvar createVec3Channel = channelFactory.createVec3Channel;\r\nvar createFloatChannel = channelFactory.createFloatChannel;\r\n\r\nvar ReaderWriterGLTF = function() {\r\n // Contains all the needed glTF files (.gltf, .bin, etc...)\r\n this._filesMap = undefined;\r\n this._loadedFiles = undefined;\r\n this._bufferViewCache = undefined;\r\n this._basicAnimationManager = undefined;\r\n this._visitedNodes = undefined;\r\n this._animatedNodes = undefined;\r\n this._bones = undefined;\r\n this._skeletonToInfluenceMap = undefined;\r\n this._inputImgReader = undefined;\r\n this._localPath = '';\r\n\r\n this._extensions = [];\r\n\r\n this._nodeAnimationTypes = undefined;\r\n this.init();\r\n};\r\n\r\nfunction base64ToArrayBuffer(base64) {\r\n var binary_string = window.atob(base64);\r\n var len = binary_string.length;\r\n var bytes = new Uint8Array(len);\r\n for (var i = 0; i < len; i++) {\r\n bytes[i] = binary_string.charCodeAt(i);\r\n }\r\n return bytes.buffer;\r\n}\r\n\r\nReaderWriterGLTF.WEBGL_COMPONENT_TYPES = {\r\n 5120: Int8Array,\r\n 5121: Uint8Array,\r\n 5122: Int16Array,\r\n 5123: Uint16Array,\r\n 5125: Uint32Array,\r\n 5126: Float32Array\r\n};\r\n\r\nReaderWriterGLTF.TYPE_TABLE = {\r\n SCALAR: 1,\r\n VEC2: 2,\r\n VEC3: 3,\r\n VEC4: 4,\r\n MAT2: 4,\r\n MAT3: 9,\r\n MAT4: 16\r\n};\r\n\r\nReaderWriterGLTF.ATTRIBUTE_OSGJS_TABLE = {\r\n POSITION: 'Vertex',\r\n NORMAL: 'Normal',\r\n TANGENT: 'Tangent',\r\n TEXCOORD_0: 'TexCoord0',\r\n TEXCOORD_1: 'TexCoord1',\r\n TEXCOORD_2: 'TexCoord2',\r\n TEXCOORD_3: 'TexCoord3',\r\n TEXCOORD_4: 'TexCoord4',\r\n TEXCOORD_5: 'TexCoord5',\r\n TEXCOORD_6: 'TexCoord6',\r\n TEXCOORD_7: 'TexCoord7',\r\n TEXCOORD_8: 'TexCoord8',\r\n TEXCOORD_9: 'TexCoord9',\r\n TEXCOORD_10: 'TexCoord10',\r\n TEXCOORD_11: 'TexCoord11',\r\n TEXCOORD_12: 'TexCoord12',\r\n TEXCOORD_13: 'TexCoord13',\r\n TEXCOORD_14: 'TexCoord14',\r\n TEXCOORD_15: 'TexCoord15',\r\n COLOR_0: 'Color',\r\n JOINTS_0: 'Bones',\r\n WEIGHTS_0: 'Weights'\r\n};\r\n\r\nReaderWriterGLTF.TEXTURE_FORMAT = {\r\n 6406: Texture.ALPHA,\r\n 6407: Texture.RGB,\r\n 6408: Texture.RGBA,\r\n 6409: Texture.LUMINANCE,\r\n 6410: Texture.LUMINANCE_ALPHA\r\n};\r\n\r\nReaderWriterGLTF.TYPE_CHANNEL_PATH = {\r\n translation: {\r\n VEC3: createVec3Channel\r\n },\r\n scale: {\r\n VEC3: createVec3Channel\r\n },\r\n rotation: {\r\n VEC4: createQuatChannel\r\n },\r\n weights: {\r\n SCALAR: createFloatChannel\r\n }\r\n};\r\n\r\nReaderWriterGLTF.TYPE_STACKED_TRANSFORMS = {\r\n translation: StackedTranslate,\r\n scale: StackedScale,\r\n rotation: StackedQuaternion\r\n};\r\n\r\nReaderWriterGLTF.PBR_SPEC_EXT = 'KHR_materials_pbrSpecularGlossiness';\r\nReaderWriterGLTF.PBR_SPEC_MODE = 'PBR_specular_glossiness';\r\nReaderWriterGLTF.PBR_METAL_MODE = 'PBR_metal_roughness';\r\n\r\nReaderWriterGLTF.ALBEDO_TEXTURE_UNIT = 2;\r\nReaderWriterGLTF.DIFFUSE_TEXTURE_UNIT = 2;\r\nReaderWriterGLTF.SPECULAR_GLOSSINESS_TEXTURE_UNIT = 3;\r\nReaderWriterGLTF.METALLIC_ROUGHNESS_TEXTURE_UNIT = 3;\r\nReaderWriterGLTF.SPECULAR_TEXTURE_UNIT = 4;\r\nReaderWriterGLTF.NORMAL_TEXTURE_UNIT = 5;\r\nReaderWriterGLTF.AO_TEXTURE_UNIT = 6;\r\nReaderWriterGLTF.EMISSIVE_TEXTURE_UNIT = 7;\r\n\r\nReaderWriterGLTF.ALBEDO_UNIFORM = 'albedoMap';\r\nReaderWriterGLTF.METALLIC_ROUGHNESS_UNIFORM = 'metallicRoughnessMap';\r\nReaderWriterGLTF.SPECULAR_UNIFORM = 'specularMap';\r\nReaderWriterGLTF.NORMAL_UNIFORM = 'normalMap';\r\nReaderWriterGLTF.AO_UNIFORM = 'aoMap';\r\nReaderWriterGLTF.EMISSIVE_UNIFORM = 'emissiveMap';\r\n\r\nReaderWriterGLTF.prototype = {\r\n init: function() {\r\n this._glTFJSON = undefined;\r\n this._nodeAnimationTypes = [];\r\n this._bufferViewCache = {};\r\n this._basicAnimationManager = undefined;\r\n this._localPath = '';\r\n this._visitedNodes = {};\r\n this._animatedNodes = {};\r\n this._bones = {};\r\n this._skeletonToInfluenceMap = {};\r\n this._stateSetMap = {};\r\n this._filesMap = {};\r\n this._inputReader = new Input();\r\n this._rootStateSet = new StateSet();\r\n\r\n this._defaultBlendFunc = new BlendFunc();\r\n this._transparentBlendFunc = new BlendFunc('SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA');\r\n this._defaultCullFace = new CullFace();\r\n this._doubleSideCullFace = new CullFace(CullFace.DISABLE);\r\n },\r\n\r\n // Adds variable to help to convert nodes to osgjs\r\n // - add parent variable to all nodes\r\n // - add unique node name\r\n _preProcessNodes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n var name;\r\n for (var i = 0; i < nodes.length; i++) {\r\n var node = nodes[i];\r\n name = node.name || '';\r\n name += '_' + i.toString();\r\n node.osgjsNodeName = name;\r\n\r\n var children = node.children;\r\n\r\n if (!children) continue;\r\n\r\n for (var j = 0; j < children.length; j++) {\r\n var child = children[j];\r\n nodes[child].parent = i;\r\n }\r\n }\r\n for (var k = 0; k < meshes.length; k++) {\r\n var mesh = meshes[k];\r\n name = mesh.name || '';\r\n name += '_' + k.toString();\r\n mesh.osgjsNodeName = name;\r\n }\r\n },\r\n\r\n loadBuffers: P.method(function() {\r\n var promises = [];\r\n var buffers = this._gltfJSON.buffers;\r\n for (var i = 0; i < buffers.length; i++) {\r\n var buffer = buffers[i];\r\n promises.push(\r\n this.loadURI(buffer.uri, { responseType: 'arraybuffer' }).then(function(\r\n arrayBuffer\r\n ) {\r\n buffer.data = arrayBuffer;\r\n })\r\n );\r\n }\r\n return P.all(promises);\r\n }),\r\n\r\n loadBufferViews: function() {\r\n var buffers = this._gltfJSON.buffers;\r\n var bufferViews = this._gltfJSON.bufferViews;\r\n for (var i = 0; i < bufferViews.length; i++) {\r\n var bufferView = bufferViews[i];\r\n var bufferIndex = bufferView.buffer;\r\n var buffer = buffers[bufferIndex];\r\n var byteLength = bufferView.byteLength || 0;\r\n var byteOffset = bufferView.byteOffset || 0;\r\n bufferView.data = buffer.data.slice(byteOffset, byteOffset + byteLength);\r\n }\r\n },\r\n\r\n loadAccessors: function() {\r\n var bufferViews = this._gltfJSON.bufferViews;\r\n var accessors = this._gltfJSON.accessors;\r\n for (var i = 0; i < accessors.length; i++) {\r\n var accessor = accessors[i];\r\n var bufferViewIndex = accessor.bufferView;\r\n var bufferView = bufferViews[bufferViewIndex];\r\n\r\n var itemSize = ReaderWriterGLTF.TYPE_TABLE[accessor.type];\r\n var TypedArray = ReaderWriterGLTF.WEBGL_COMPONENT_TYPES[accessor.componentType];\r\n\r\n // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.\r\n var elementBytes = TypedArray.BYTES_PER_ELEMENT;\r\n var itemBytes = elementBytes * itemSize;\r\n var byteStride = bufferView.byteStride;\r\n var normalized = accessor.normalized === true;\r\n var bufferArray;\r\n\r\n // The buffer is not interleaved if the stride is the item size in bytes.\r\n if (byteStride && byteStride !== itemBytes) {\r\n // Use the full buffer if it's interleaved.\r\n notify.warn('GLTF interleaved accessors not supported');\r\n } else {\r\n var data = new TypedArray(\r\n bufferView.data,\r\n accessor.byteOffset,\r\n accessor.count * itemSize\r\n );\r\n bufferArray = new BufferArray(undefined, data, itemSize);\r\n bufferArray.setNormalize(normalized);\r\n }\r\n accessor.data = bufferArray;\r\n }\r\n },\r\n\r\n _computeNodeMatrix: function(node) {\r\n var matrix;\r\n if (node.matrix) {\r\n matrix = mat4.clone(node.matrix);\r\n } else if (node.translation || node.rotation || node.scale) {\r\n var translation = mat4.IDENTITY;\r\n var rotation = mat4.IDENTITY;\r\n var scale = mat4.IDENTITY;\r\n if (node.translation)\r\n translation = mat4.fromTranslation(mat4.create(), node.translation);\r\n if (node.rotation) rotation = mat4.fromQuat(mat4.create(), node.rotation);\r\n if (node.scale) scale = mat4.fromScaling(mat4.create(), node.scale);\r\n matrix = mat4.create();\r\n mat4.multiply(matrix, rotation, scale);\r\n mat4.multiply(matrix, translation, matrix);\r\n }\r\n return matrix;\r\n },\r\n\r\n loadNodes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var skins = this._gltfJSON.skins;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n // create all nodes\r\n // children relationship will be done in loadScenes\r\n for (var i = 0; i < nodes.length; i++) {\r\n var node = nodes[i];\r\n if (node.usedAsBone) continue;\r\n if (node.skin !== undefined) {\r\n var skin = skins[node.skin];\r\n var skeleton = skin.osgjsNode;\r\n if (!skin.osgjsNodeAttached) {\r\n node.osgjsNode = skeleton;\r\n skin.osgjsNodeAttached = i;\r\n }\r\n var mesh = meshes[node.mesh];\r\n mesh.osgjsGeometry.setBoneNameID(skin.osgjsBoneMapID);\r\n skeleton.addChild(mesh.osgjsGeometry);\r\n } else {\r\n if (node.matrix || node.translation || node.rotation || node.scale) {\r\n node.osgjsNode = this._createMatrixTransform(i);\r\n }\r\n if (node.mesh !== undefined) {\r\n if (node.osgjsNode) {\r\n node.osgjsNode.addChild(meshes[node.mesh].osgjsGeometry);\r\n } else {\r\n node.osgjsNode = meshes[node.mesh].osgjsGeometry;\r\n }\r\n }\r\n if (!node.osgjsNode) {\r\n node.osgjsNode = new Node();\r\n }\r\n }\r\n if (node.name) node.osgjsNode.setName(node.name);\r\n }\r\n },\r\n\r\n _linkNodes: function(parent) {\r\n var nodes = this._gltfJSON.nodes;\r\n var children = parent.children;\r\n if (!children) return;\r\n\r\n for (var i = 0; i < children.length; i++) {\r\n var node = nodes[children[i]];\r\n\r\n // skip node used as bone\r\n if (node.usedAsBone) continue;\r\n\r\n var osgjsChild = node.osgjsNode;\r\n if (osgjsChild && !parent.osgjsNode.hasChild(osgjsChild)) {\r\n parent.osgjsNode.addChild(osgjsChild);\r\n this._linkNodes(node);\r\n }\r\n }\r\n },\r\n\r\n loadSkins: function() {\r\n var skins = this._gltfJSON.skins;\r\n if (!skins) return;\r\n\r\n for (var i = 0; i < skins.length; i++) {\r\n this._processSkin(i);\r\n }\r\n },\r\n\r\n loadScenes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var scenes = this._gltfJSON.scenes;\r\n\r\n this._osgjsScene = [];\r\n\r\n for (var i = 0; i < scenes.length; i++) {\r\n var scene = scenes[i];\r\n var sceneNodes = scene.nodes;\r\n var rootNodes = [];\r\n for (var j = 0; j < sceneNodes.length; j++) {\r\n var node = nodes[sceneNodes[j]];\r\n this._linkNodes(node);\r\n rootNodes.push(node.osgjsNode);\r\n }\r\n\r\n var root = rootNodes[0];\r\n if (rootNodes.length > 1) {\r\n root = new Node();\r\n for (var r = 0; r < rootNodes.length; r++) {\r\n root.addChild(rootNodes[r]);\r\n }\r\n }\r\n this._osgjsScene.push(root);\r\n }\r\n },\r\n\r\n _assignGeometryAttributes: function(osgjsGeometry, gltfAttributes, index) {\r\n var accessors = this._gltfJSON.accessors;\r\n for (var attribute in gltfAttributes) {\r\n var accessorIndex = gltfAttributes[attribute];\r\n var accessor = accessors[accessorIndex];\r\n var osgjsAttributeName = ReaderWriterGLTF.ATTRIBUTE_OSGJS_TABLE[attribute];\r\n if (index !== undefined) osgjsAttributeName += '_' + index.toString();\r\n osgjsGeometry.getVertexAttributeList()[osgjsAttributeName] = accessor.data;\r\n accessor.data._target = BufferArray.ARRAY_BUFFER;\r\n }\r\n },\r\n\r\n _assignGeometryPrimitives: function(osgjsGeometry, primitive) {\r\n var accessors = this._gltfJSON.accessors;\r\n var indexes = accessors[primitive.indices];\r\n indexes.data._target = BufferArray.ELEMENT_ARRAY_BUFFER;\r\n var primitiveMode = primitive.mode !== undefined ? primitive.mode : primitiveSet.TRIANGLES;\r\n var osgPrimitive = new DrawElements(primitiveMode, indexes.data);\r\n osgjsGeometry.getPrimitiveSetList().push(osgPrimitive);\r\n },\r\n\r\n _getMorphTargetName: function(mesh, index) {\r\n return mesh.osgjsNodeName + '_target_' + index.toString();\r\n },\r\n\r\n _computeAbsoluteMorphData: function(baseAttributes, morphAttributes) {\r\n var accessors = this._gltfJSON.accessors;\r\n for (var attribute in morphAttributes) {\r\n var accessorIndex = morphAttributes[attribute];\r\n var accessor = accessors[accessorIndex];\r\n\r\n if (accessor.morphAbsoluteComputed) continue; // dont compute twice absolute targets\r\n accessor.morphAbsoluteComputed = true;\r\n\r\n var baseAccessorIndex = baseAttributes[attribute];\r\n var baseAccessor = accessors[baseAccessorIndex];\r\n\r\n var base = baseAccessor.data.getElements();\r\n var target = accessor.data.getElements();\r\n var nbElements = base.length;\r\n for (var i = 0; i < nbElements; i++) {\r\n target[i] += base[i];\r\n }\r\n }\r\n },\r\n\r\n _processMorphGeometry: function(mesh, primitiveIndex) {\r\n var primitive = mesh.primitives[primitiveIndex];\r\n var geometry = new MorphGeometry();\r\n var morphUpdateCallback = new UpdateMorph();\r\n morphUpdateCallback.setName(mesh.osgjsNodeName);\r\n geometry.setName(mesh.osgjsNodeName);\r\n for (var t = 0; t < primitive.targets.length; t++) {\r\n this._computeAbsoluteMorphData(primitive.attributes, primitive.targets[t]);\r\n var targetName = this._getMorphTargetName(mesh, t);\r\n var morphTarget = new Geometry();\r\n morphTarget.setName(targetName);\r\n morphUpdateCallback.addTarget(targetName, t);\r\n this._assignGeometryAttributes(morphTarget, primitive.targets[t]);\r\n geometry.getMorphTargets().push(morphTarget);\r\n }\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n geometry.mergeChildrenVertexAttributeList();\r\n\r\n // set result in gltf mesh\r\n mesh.osgjsMorphGeometry = geometry;\r\n mesh.osgjsUpdateMorph = morphUpdateCallback;\r\n },\r\n\r\n loadMeshes: function() {\r\n var meshes = this._gltfJSON.meshes;\r\n var materials = this._gltfJSON.materials;\r\n\r\n for (var i = 0; i < meshes.length; i++) {\r\n var mesh = meshes[i];\r\n var name = mesh.name;\r\n var osgjsGeometries = [];\r\n for (var j = 0; j < mesh.primitives.length; j++) {\r\n var geometry = undefined;\r\n var primitive = mesh.primitives[j];\r\n var morphUpdateCallback = undefined;\r\n // means we have morph target\r\n if (primitive.targets && primitive.targets.length) {\r\n this._processMorphGeometry(mesh, j);\r\n geometry = mesh.osgjsMorphGeometry;\r\n morphUpdateCallback = mesh.osgjsUpdateMorph;\r\n }\r\n\r\n if (primitive.attributes.JOINTS_0) {\r\n var rigGeometry = new RigGeometry();\r\n if (!geometry) {\r\n geometry = new Geometry();\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n }\r\n var bbox = new BoundingBox();\r\n geometry.computeBoundingBox(bbox);\r\n rigGeometry.setBound(bbox);\r\n\r\n rigGeometry.setSourceGeometry(geometry);\r\n rigGeometry.mergeChildrenData();\r\n geometry = rigGeometry;\r\n }\r\n\r\n if (!geometry) {\r\n geometry = new Geometry();\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n }\r\n\r\n if (name) geometry.setName(name);\r\n\r\n // if has a morph geometry we addd the update callback on the top geometry\r\n if (morphUpdateCallback) geometry.addUpdateCallback(morphUpdateCallback);\r\n\r\n var osgjsStateSet = materials[primitive.material].osgjsStateSet;\r\n geometry.setStateSet(osgjsStateSet);\r\n geometry.setUserData(osgjsStateSet.getUserData());\r\n osgjsGeometries.push(geometry);\r\n }\r\n\r\n if (osgjsGeometries.length > 1) {\r\n var node = new Node();\r\n for (var c = 0; c < osgjsGeometries.length; c++) node.addChild(osgjsGeometries[c]);\r\n geometry = node;\r\n }\r\n mesh.osgjsGeometry = geometry;\r\n }\r\n },\r\n\r\n loadImages: function() {\r\n var images = this._gltfJSON.images;\r\n if (!images) return P.resolve();\r\n var promises = [];\r\n\r\n for (var i = 0; i < images.length; i++) {\r\n var image = images[i];\r\n var url = window.decodeURI(image.uri);\r\n var promise = this.loadURI(url).then(\r\n function(imageData) {\r\n var osgjsImage = new Image();\r\n osgjsImage.setImage(imageData);\r\n this.osgjsImage = osgjsImage;\r\n }.bind(image)\r\n );\r\n promises.push(promise);\r\n }\r\n return P.all(promises);\r\n },\r\n\r\n _texture: function(gltfTexture) {\r\n var textures = this._gltfJSON.textures;\r\n var images = this._gltfJSON.images;\r\n var texture = textures[gltfTexture.index];\r\n var image = images[texture.source];\r\n\r\n if (texture.osgjsTexture) return texture.osgjsTexture;\r\n\r\n var osgjsTexture = new Texture();\r\n texture.osgjsTexture = osgjsTexture;\r\n\r\n // GLTF texture origin is correct\r\n osgjsTexture.setFlipY(false);\r\n osgjsTexture.setWrapS('REPEAT');\r\n osgjsTexture.setWrapT('REPEAT');\r\n\r\n if (image.osgjsImage) {\r\n var format = ReaderWriterGLTF.TEXTURE_FORMAT[texture.format];\r\n osgjsTexture.setImage(image.osgjsImage, format);\r\n }\r\n return osgjsTexture;\r\n },\r\n\r\n _pbrMetallicRoughnessTextureUniforms: function() {\r\n var stateSet = this._rootStateSet;\r\n if (stateSet.getUniformList()[ReaderWriterGLTF.ALBEDO_UNIFORM]) return;\r\n\r\n var albedo = Uniform.createInt(\r\n ReaderWriterGLTF.ALBEDO_TEXTURE_UNIT,\r\n ReaderWriterGLTF.ALBEDO_UNIFORM\r\n );\r\n var metalnessRoughness = Uniform.createInt(\r\n ReaderWriterGLTF.METALLIC_ROUGHNESS_TEXTURE_UNIT,\r\n ReaderWriterGLTF.METALLIC_ROUGHNESS_UNIFORM\r\n );\r\n stateSet.addUniform(albedo);\r\n stateSet.addUniform(metalnessRoughness);\r\n },\r\n\r\n _pbrMetallicRoughness: function(material, stateSet) {\r\n stateSet.setUserData({\r\n pbrWorklow: ReaderWriterGLTF.PBR_METAL_MODE\r\n });\r\n this._pbrMetallicRoughnessTextureUniforms();\r\n\r\n var osgjsTexture;\r\n // baseColor\r\n if (material.baseColorTexture) {\r\n osgjsTexture = this._texture(material.baseColorTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.ALBEDO_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n } else if (material.baseColorFactor) {\r\n //PBR default uniforms\r\n var color = Uniform.createFloat4(material.baseColorFactor, 'uBaseColorFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n // metallic\r\n if (material.metallicFactor !== undefined) {\r\n var metallic = Uniform.createFloat1(material.metallicFactor, 'uMetallicFactor');\r\n stateSet.addUniform(metallic);\r\n }\r\n\r\n if (material.roughnessFactor !== undefined) {\r\n var roughness = Uniform.createFloat1(material.roughnessFactor, 'uRoughnessFactor');\r\n stateSet.addUniform(roughness);\r\n }\r\n\r\n if (material.metallicRoughnessTexture) {\r\n osgjsTexture = this._texture(material.metallicRoughnessTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.METALLIC_ROUGHNESS_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n },\r\n\r\n _KHR_materials_pbrSpecularGlossinessTextureUniforms: function() {\r\n if (this._extensions['KHR_materials_pbrSpecularGlossinessTextureUniforms']) return;\r\n this._extensions['KHR_materials_pbrSpecularGlossinessTextureUniforms'] = true;\r\n\r\n var stateSet = this._rootStateSet;\r\n var albedo = Uniform.createInt(\r\n ReaderWriterGLTF.DIFFUSE_TEXTURE_UNIT,\r\n ReaderWriterGLTF.ALBEDO_UNIFORM\r\n );\r\n var specluarGlossiness = Uniform.createInt(\r\n ReaderWriterGLTF.SPECULAR_GLOSSINESS_TEXTURE_UNIT,\r\n ReaderWriterGLTF.METALLIC_ROUGHNESS_UNIFORM\r\n );\r\n var specular = Uniform.createInt(\r\n ReaderWriterGLTF.SPECULAR_TEXTURE_UNIT,\r\n ReaderWriterGLTF.SPECULAR_UNIFORM\r\n );\r\n\r\n stateSet.addUniform(albedo);\r\n stateSet.addUniform(specluarGlossiness);\r\n stateSet.addUniform(specular);\r\n },\r\n\r\n _KHR_materials_pbrSpecularGlossiness: function(material, stateSet) {\r\n stateSet.setUserData({\r\n pbrWorklow: ReaderWriterGLTF.PBR_SPEC_MODE\r\n });\r\n\r\n this._KHR_materials_pbrSpecularGlossinessTextureUniforms();\r\n\r\n var osgjsTexture;\r\n var color;\r\n if (material.diffuseTexture) {\r\n osgjsTexture = this._texture(material.diffuseTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.DIFFUSE_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n } else if (material.diffuseFactor) {\r\n color = Uniform.createFloat4(material.diffuseFactor, 'uBaseColorFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n if (material.specularFactor) {\r\n color = Uniform.createFloat3(material.specularFactor, 'uSpecularFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n if (material.glossinessFactor !== undefined) {\r\n var factor = Uniform.createFloat(material.glossinessFactor, 'uGlossinessFactor');\r\n stateSet.addUniform(factor);\r\n }\r\n\r\n if (material.specularGlossinessTexture) {\r\n osgjsTexture = this._texture(material.specularGlossinessTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.SPECULAR_GLOSSINESS_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n },\r\n\r\n loadMaterials: function() {\r\n var materials = this._gltfJSON.materials;\r\n var hasTransparentMaterial = false;\r\n var hasDoubleSidedMaterial = false;\r\n\r\n var rootStateSet = this._rootStateSet;\r\n rootStateSet.addUniform(\r\n Uniform.createInt(\r\n ReaderWriterGLTF.EMISSIVE_TEXTURE_UNIT,\r\n ReaderWriterGLTF.EMISSIVE_UNIFORM\r\n )\r\n );\r\n rootStateSet.addUniform(\r\n Uniform.createInt(ReaderWriterGLTF.AO_TEXTURE_UNIT, ReaderWriterGLTF.AO_UNIFORM)\r\n );\r\n rootStateSet.addUniform(\r\n Uniform.createInt(ReaderWriterGLTF.NORMAL_TEXTURE_UNIT, ReaderWriterGLTF.NORMAL_UNIFORM)\r\n );\r\n rootStateSet.addUniform(Uniform.createFloat3(vec3.ZERO, 'uEmissiveFactor'));\r\n\r\n for (var i = 0; i < materials.length; i++) {\r\n var material = materials[i];\r\n var stateSet = new StateSet();\r\n var osgjsTexture;\r\n material.osgjsStateSet = stateSet;\r\n\r\n if (material.pbrMetallicRoughness) {\r\n this._pbrMetallicRoughness(material.pbrMetallicRoughness, stateSet);\r\n } else if (material.extensions.KHR_materials_pbrSpecularGlossiness) {\r\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/Khronos/KHR_materials_pbrSpecularGlossiness/README.md\r\n this._KHR_materials_pbrSpecularGlossiness(\r\n material.extensions.KHR_materials_pbrSpecularGlossiness,\r\n stateSet\r\n );\r\n }\r\n\r\n if (material.normalTexture) {\r\n osgjsTexture = this._texture(material.normalTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.NORMAL_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n\r\n if (material.occlusionTexture) {\r\n osgjsTexture = this._texture(material.occlusionTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.AO_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n\r\n if (material.emissiveTexture) {\r\n osgjsTexture = this._texture(material.emissiveTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterGLTF.EMISSIVE_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n if (material.emissiveFactor) {\r\n stateSet.addUniform(\r\n Uniform.createFloat3(material.emissiveFactor, 'uEmissiveFactor')\r\n );\r\n }\r\n\r\n if (material.alphaMode === 'BLEND') {\r\n hasTransparentMaterial = true;\r\n stateSet.setAttributeAndModes(this._transparentBlendFunc);\r\n stateSet.setRenderingHint('TRANSPARENT_BIN');\r\n }\r\n\r\n if (material.doubleSided) {\r\n hasDoubleSidedMaterial = true;\r\n stateSet.setAttributeAndModes(this._doubleSideCullFace);\r\n }\r\n }\r\n\r\n // need to add a default blend func if we have transparent materials in the model\r\n if (hasTransparentMaterial) {\r\n rootStateSet.setAttributeAndModes(this._defaultBlendFunc);\r\n }\r\n\r\n if (hasDoubleSidedMaterial) {\r\n rootStateSet.setAttributeAndModes(this._defaultCullFace);\r\n }\r\n },\r\n\r\n _createBone: function(nodeID) {\r\n var nodes = this._gltfJSON.nodes;\r\n var node = nodes[nodeID];\r\n node.usedAsBone = true;\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n\r\n var osgjsNode = new Bone();\r\n var name = node.osgjsNodeName;\r\n osgjsNode.setName(name);\r\n\r\n var matrix = this._computeNodeMatrix(node) || mat4.IDENTITY;\r\n osgjsNode.setMatrix(matrix);\r\n\r\n var updateCallback = new UpdateBone();\r\n updateCallback.setName(osgjsNode.getName());\r\n osgjsNode.addUpdateCallback(updateCallback);\r\n\r\n if (nodeAnimationTypes[nodeID]) {\r\n var stackTransforms = updateCallback.getStackedTransforms();\r\n for (var channelType in nodeAnimationTypes[nodeID]) {\r\n var StackedType = ReaderWriterGLTF.TYPE_STACKED_TRANSFORMS[channelType];\r\n var stack = new StackedType(channelType);\r\n stackTransforms.push(stack);\r\n }\r\n }\r\n\r\n // we set the default updateBone matrix with the bone matrix to avoid to copy identity\r\n // matrix when no animation is yet started\r\n updateCallback.setMatrix(matrix);\r\n //osgjsNode.addChild(shape.createAxisGeometry());\r\n return osgjsNode;\r\n },\r\n\r\n _createMatrixTransform: function(nodeID) {\r\n var nodes = this._gltfJSON.nodes;\r\n var node = nodes[nodeID];\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n\r\n var osgjsNode = new MatrixTransform();\r\n var name = node.osgjsNodeName;\r\n osgjsNode.setName(name);\r\n\r\n var matrix = this._computeNodeMatrix(node) || mat4.IDENTITY;\r\n osgjsNode.setMatrix(matrix);\r\n\r\n if (nodeAnimationTypes[nodeID]) {\r\n var updateCallback = new UpdateMatrixTransform();\r\n updateCallback.setName(osgjsNode.getName());\r\n osgjsNode.addUpdateCallback(updateCallback);\r\n updateCallback.setMatrix(matrix);\r\n\r\n var stackTransforms = updateCallback.getStackedTransforms();\r\n for (var channelType in nodeAnimationTypes[nodeID]) {\r\n var StackedType = ReaderWriterGLTF.TYPE_STACKED_TRANSFORMS[channelType];\r\n var stack = new StackedType(channelType);\r\n stackTransforms.push(stack);\r\n }\r\n }\r\n\r\n return osgjsNode;\r\n },\r\n\r\n _processSkin: function(skinID) {\r\n var skins = this._gltfJSON.skins;\r\n var nodes = this._gltfJSON.nodes;\r\n var skin = skins[skinID];\r\n var joints = skin.joints;\r\n\r\n var inverseBindMatrixAccessor, arrayBuffer;\r\n if (skin.inverseBindMatrices !== undefined) {\r\n inverseBindMatrixAccessor = this._gltfJSON.accessors[skin.inverseBindMatrices].data;\r\n arrayBuffer = inverseBindMatrixAccessor.getElements().buffer;\r\n }\r\n\r\n var skeleton = new Skeleton();\r\n skin.osgjsNode = skeleton;\r\n skeleton.setName('skin ID ' + skinID);\r\n var nodeID;\r\n var boneMap = {};\r\n var boneMapID = {};\r\n var node;\r\n var bone;\r\n // first create all bones\r\n for (var i = 0; i < joints.length; i++) {\r\n nodeID = joints[i];\r\n bone = this._createBone(nodeID);\r\n if (skin.inverseBindMatrices !== undefined) {\r\n var matrix = new Float32Array(arrayBuffer, i * 16 * 4, 16);\r\n bone.setInvBindMatrixInSkeletonSpace(matrix);\r\n }\r\n boneMap[nodeID] = bone;\r\n boneMapID[bone.getName()] = i;\r\n }\r\n skin.osgjsBoneMapID = boneMapID;\r\n\r\n for (var boneID in boneMap) {\r\n node = nodes[boneID];\r\n var parentID = node.parent;\r\n bone = boneMap[boneID];\r\n if (parentID === undefined || joints.indexOf(parentID) === -1) {\r\n skeleton.addChild(bone);\r\n } else {\r\n var boneParent = boneMap[parentID];\r\n boneParent.addChild(bone);\r\n }\r\n }\r\n },\r\n\r\n loadAnimations: function() {\r\n var animations = this._gltfJSON.animations;\r\n if (!animations) return;\r\n\r\n var accessors = this._gltfJSON.accessors;\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n var nodes = this._gltfJSON.nodes;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n var osgjsAnimations = [];\r\n for (var i = 0; i < animations.length; i++) {\r\n var channels = animations[i].channels;\r\n var samplers = animations[i].samplers;\r\n var osgjsChannels = [];\r\n for (var j = 0; j < channels.length; j++) {\r\n var channel = channels[j];\r\n var sampler = samplers[channel.sampler];\r\n var times = accessors[sampler.input].data.getElements();\r\n var accessorValues = accessors[sampler.output];\r\n var values = accessorValues.data.getElements();\r\n // target.id is deprecated\r\n var target = channel.target;\r\n var createChannel =\r\n ReaderWriterGLTF.TYPE_CHANNEL_PATH[target.path][accessorValues.type];\r\n\r\n var nodeIndex = target.node !== undefined ? target.node : target.id;\r\n var node = nodes[nodeIndex];\r\n var channelName = target.path;\r\n var targetName = nodes[nodeIndex].osgjsNodeName;\r\n // needs to get the updateCallback name of the morph geometry\r\n if (channelName === 'weights') {\r\n // if morph target we need to split each channel into scalar for each target\r\n var mesh = meshes[node.mesh];\r\n\r\n var nbTargets = mesh.primitives[0].targets.length;\r\n var nkKeys = times.length;\r\n for (var targetIndex = 0; targetIndex < nbTargets; targetIndex++) {\r\n var weights = new Float32Array(nkKeys);\r\n for (var v = 0; v < nkKeys; v++) {\r\n weights[v] = values[v * nbTargets + targetIndex];\r\n }\r\n targetName = this._getMorphTargetName(mesh, targetIndex);\r\n osgjsChannels.push(createChannel(weights, times, targetName, targetIndex));\r\n }\r\n } else {\r\n osgjsChannels.push(createChannel(values, times, targetName, channelName));\r\n }\r\n\r\n if (!nodeAnimationTypes[nodeIndex]) nodeAnimationTypes[nodeIndex] = {};\r\n nodeAnimationTypes[nodeIndex][channelName] = true;\r\n }\r\n\r\n var animationName = 'animation-' + i.toString();\r\n osgjsAnimations.push(animationFactory.createAnimation(osgjsChannels, animationName));\r\n }\r\n\r\n var animationManager = new BasicAnimationManager();\r\n animationManager.init(osgjsAnimations);\r\n this._animationManager = animationManager;\r\n },\r\n\r\n loadURI: P.method(function(uri, options) {\r\n // is base64 inline data\r\n if (uri.substr(0, 5) === 'data:') {\r\n return base64ToArrayBuffer(uri);\r\n }\r\n\r\n var result = this._filesMap[uri];\r\n if (result !== undefined) return result;\r\n return fileHelper.requestURI(uri, options);\r\n }),\r\n\r\n readNodeURL: function(url, options) {\r\n var self = this;\r\n\r\n this.init();\r\n if (options && options.filesMap !== undefined && Object.keys(options.filesMap).length > 0) {\r\n // it comes from the ZIP plugin or from drag'n drop\r\n // So we already have all the files.\r\n this._filesMap = options.filesMap;\r\n var glTFFile = this._filesMap[url];\r\n return this.readJSON(glTFFile, url);\r\n }\r\n\r\n var index = url.lastIndexOf('/');\r\n this._localPath = index === -1 ? '' : url.substr(0, index + 1);\r\n // Else it is a usual XHR request\r\n return fileHelper.requestURI(url).then(function(file) {\r\n return self.readJSON(file);\r\n });\r\n },\r\n\r\n readJSON: P.method(function(json, url) {\r\n this._gltfJSON = json;\r\n\r\n return P.all([this.loadBuffers(), this.loadImages()]).then(\r\n function() {\r\n this.loadBufferViews();\r\n this.loadAccessors();\r\n this._preProcessNodes();\r\n this.loadMaterials();\r\n this.loadMeshes();\r\n this.loadAnimations();\r\n this.loadSkins();\r\n this.loadNodes();\r\n this.loadScenes();\r\n\r\n var root = new MatrixTransform();\r\n root.addChild(this._osgjsScene[0]);\r\n root.setName(url);\r\n if (this._animationManager) root.addUpdateCallback(this._animationManager);\r\n root.setStateSet(this._rootStateSet);\r\n return root;\r\n }.bind(this)\r\n );\r\n })\r\n};\r\n\r\nRegistry.instance().addReaderWriter('gltf', new ReaderWriterGLTF());\r\n\r\nexport default ReaderWriterGLTF;\r\n","import P from 'bluebird';\r\nimport notify from '../osg/notify';\r\nimport fileHelper from '../osgDB/fileHelper.js';\r\nimport Registry from '../osgDB/Registry';\r\nimport ReaderParser from '../osgDB/readerParser';\r\nvar JSZip = window.JSZip;\r\n\r\nvar ReaderWriterZIP = function() {\r\n this._options = undefined;\r\n this._filesMap = {};\r\n this._fileName = ''; // The file containing the model of the archive ( gltf, glb, osgjs, b3dm, etc )\r\n};\r\n\r\nReaderWriterZIP.prototype = {\r\n readNodeURL: function(url, options) {\r\n if (JSZip === undefined) {\r\n notify.error('You need to add JSZip as a dependency');\r\n return P.reject(this);\r\n }\r\n notify.log('starting to read: ' + url);\r\n // Check if we already have the file\r\n var self = this;\r\n if (options && options.filesMap !== undefined) {\r\n // it comes from drag'n drop\r\n if (options.filesMap[url] !== undefined) {\r\n // Now url is a File\r\n var file = options.filesMap[url];\r\n return this.readZipFile(file).then(function() {\r\n if (!self._fileName) return P.reject(self);\r\n // At this point we have the main file name and a Map containing all the resources\r\n return ReaderParser.readNodeURL(self._fileName, {\r\n filesMap: self._filesMap\r\n });\r\n });\r\n }\r\n }\r\n\r\n var filePromise = fileHelper.requestURI(url, {\r\n responseType: 'blob'\r\n });\r\n\r\n return filePromise.then(function(zfile) {\r\n self.readZipFile(zfile).then(function() {\r\n // At this point we have the main file name and a Map containing all the resources\r\n return ReaderParser.readNodeURL(self._fileName, {\r\n filesMap: self._filesMap\r\n });\r\n });\r\n });\r\n },\r\n\r\n readZipFile: function(fileOrBlob) {\r\n fileHelper.unzip(fileOrBlob).then(\r\n function(filesMap) {\r\n for (var fileName in filesMap) {\r\n var extension = fileHelper.getExtension(fileName);\r\n // Check if the file is readable by any osgDB plugin\r\n var readerWriter = Registry.instance().getReaderWriterForExtension(extension);\r\n\r\n // We need a hack for osgjs til it is converted to a readerwriter\r\n if (readerWriter !== undefined || extension === 'osgjs') {\r\n // So this is the main file to read\r\n this._fileName = fileName;\r\n break;\r\n }\r\n }\r\n }.bind(this)\r\n );\r\n }\r\n};\r\n\r\nRegistry.instance().addReaderWriter('zip', new ReaderWriterZIP());\r\n\r\nexport default ReaderWriterZIP;\r\n","import P from 'bluebird';\r\nimport BoundingBox from '../osg/BoundingBox';\r\nimport StateSet from '../osg/StateSet';\r\nimport Input from '../osgDB/Input';\r\nimport Registry from '../osgDB/Registry';\r\nimport BasicAnimationManager from '../osgAnimation/BasicAnimationManager';\r\nimport Skeleton from '../osgAnimation/Skeleton';\r\nimport Bone from '../osgAnimation/Bone';\r\nimport StackedTranslate from '../osgAnimation/StackedTranslate';\r\nimport StackedQuaternion from '../osgAnimation/StackedQuaternion';\r\nimport StackedScale from '../osgAnimation/StackedScale';\r\nimport RigGeometry from '../osgAnimation/RigGeometry';\r\nimport MorphGeometry from '../osgAnimation/MorphGeometry';\r\nimport channelFactory from '../osgAnimation/channel';\r\nimport animationFactory from '../osgAnimation/animation';\r\nimport notify from '../osg/notify';\r\n\r\nimport Node from '../osg/Node';\r\nimport Geometry from '../osg/Geometry';\r\nimport Texture from '../osg/Texture';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport CullFace from '../osg/CullFace';\r\nimport Image from '../osg/Image';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport UpdateBone from '../osgAnimation/UpdateBone';\r\nimport UpdateMorph from '../osgAnimation/UpdateMorph';\r\nimport UpdateMatrixTransform from '../osgAnimation/UpdateMatrixTransform';\r\nimport fileHelper from '../osgDB/fileHelper';\r\n\r\nimport Uniform from '../osg/Uniform';\r\nimport { mat4, vec3 } from '../osg/glMatrix';\r\n\r\nvar createQuatChannel = channelFactory.createQuatChannel;\r\nvar createVec3Channel = channelFactory.createVec3Channel;\r\nvar createFloatChannel = channelFactory.createFloatChannel;\r\n\r\nvar ReaderWriterQueen = function() {\r\n // Contains all the needed glTF files (.gltf, .bin, etc...)\r\n this._filesMap = undefined;\r\n this._loadedFiles = undefined;\r\n this._bufferViewCache = undefined;\r\n this._basicAnimationManager = undefined;\r\n this._visitedNodes = undefined;\r\n this._animatedNodes = undefined;\r\n this._bones = undefined;\r\n this._skeletonToInfluenceMap = undefined;\r\n this._inputImgReader = undefined;\r\n this._localPath = '';\r\n\r\n this._extensions = [];\r\n\r\n this._nodeAnimationTypes = undefined;\r\n this.init();\r\n};\r\n\r\nfunction base64ToArrayBuffer(base64) {\r\n try {\r\n return new P(function(resolve, reject) {\r\n // create request\r\n const req = new Request( base64, {\r\n credentials: 'include',\r\n });\r\n fetch( req ).then( response => {\r\n debugger;\r\n if ( response.status === 200 || response.status === 0 ) { \r\n response.arrayBuffer().then((bf)=>{\r\n resolve(bf);\r\n })\r\n }\r\n });\r\n });\r\n } catch (error) {\r\n console.error('Error decoding string:', error);\r\n }\r\n return new Uint8Array(0);\r\n}\r\n\r\n\r\nReaderWriterQueen.WEBGL_COMPONENT_TYPES = {\r\n 5120: Int8Array,\r\n 5121: Uint8Array,\r\n 5122: Int16Array,\r\n 5123: Uint16Array,\r\n 5125: Uint32Array,\r\n 5126: Float32Array\r\n};\r\n\r\nReaderWriterQueen.TYPE_TABLE = {\r\n SCALAR: 1,\r\n VEC2: 2,\r\n VEC3: 3,\r\n VEC4: 4,\r\n MAT2: 4,\r\n MAT3: 9,\r\n MAT4: 16\r\n};\r\n\r\nReaderWriterQueen.ATTRIBUTE_OSGJS_TABLE = {\r\n POSITION: 'Vertex',\r\n NORMAL: 'Normal',\r\n TANGENT: 'Tangent',\r\n TEXCOORD_0: 'TexCoord0',\r\n TEXCOORD_1: 'TexCoord1',\r\n TEXCOORD_2: 'TexCoord2',\r\n TEXCOORD_3: 'TexCoord3',\r\n TEXCOORD_4: 'TexCoord4',\r\n TEXCOORD_5: 'TexCoord5',\r\n TEXCOORD_6: 'TexCoord6',\r\n TEXCOORD_7: 'TexCoord7',\r\n TEXCOORD_8: 'TexCoord8',\r\n TEXCOORD_9: 'TexCoord9',\r\n TEXCOORD_10: 'TexCoord10',\r\n TEXCOORD_11: 'TexCoord11',\r\n TEXCOORD_12: 'TexCoord12',\r\n TEXCOORD_13: 'TexCoord13',\r\n TEXCOORD_14: 'TexCoord14',\r\n TEXCOORD_15: 'TexCoord15',\r\n COLOR_0: 'Color',\r\n JOINTS_0: 'Bones',\r\n WEIGHTS_0: 'Weights'\r\n};\r\n\r\nReaderWriterQueen.TEXTURE_FORMAT = {\r\n 6406: Texture.ALPHA,\r\n 6407: Texture.RGB,\r\n 6408: Texture.RGBA,\r\n 6409: Texture.LUMINANCE,\r\n 6410: Texture.LUMINANCE_ALPHA\r\n};\r\n\r\nReaderWriterQueen.TYPE_CHANNEL_PATH = {\r\n translation: {\r\n VEC3: createVec3Channel\r\n },\r\n scale: {\r\n VEC3: createVec3Channel\r\n },\r\n rotation: {\r\n VEC4: createQuatChannel\r\n },\r\n weights: {\r\n SCALAR: createFloatChannel\r\n }\r\n};\r\n\r\nReaderWriterQueen.TYPE_STACKED_TRANSFORMS = {\r\n translation: StackedTranslate,\r\n scale: StackedScale,\r\n rotation: StackedQuaternion\r\n};\r\n\r\nReaderWriterQueen.PBR_SPEC_EXT = 'KHR_materials_pbrSpecularGlossiness';\r\nReaderWriterQueen.PBR_SPEC_MODE = 'PBR_specular_glossiness';\r\nReaderWriterQueen.PBR_METAL_MODE = 'PBR_metal_roughness';\r\n\r\nReaderWriterQueen.ALBEDO_TEXTURE_UNIT = 2;\r\nReaderWriterQueen.DIFFUSE_TEXTURE_UNIT = 2;\r\nReaderWriterQueen.SPECULAR_GLOSSINESS_TEXTURE_UNIT = 3;\r\nReaderWriterQueen.METALLIC_ROUGHNESS_TEXTURE_UNIT = 3;\r\nReaderWriterQueen.SPECULAR_TEXTURE_UNIT = 4;\r\nReaderWriterQueen.NORMAL_TEXTURE_UNIT = 5;\r\nReaderWriterQueen.AO_TEXTURE_UNIT = 6;\r\nReaderWriterQueen.EMISSIVE_TEXTURE_UNIT = 7;\r\n\r\nReaderWriterQueen.ALBEDO_UNIFORM = 'albedoMap';\r\nReaderWriterQueen.METALLIC_ROUGHNESS_UNIFORM = 'metallicRoughnessMap';\r\nReaderWriterQueen.SPECULAR_UNIFORM = 'specularMap';\r\nReaderWriterQueen.NORMAL_UNIFORM = 'normalMap';\r\nReaderWriterQueen.AO_UNIFORM = 'aoMap';\r\nReaderWriterQueen.EMISSIVE_UNIFORM = 'emissiveMap';\r\n\r\nReaderWriterQueen.prototype = {\r\n init: function() {\r\n this._glTFJSON = undefined;\r\n this._nodeAnimationTypes = [];\r\n this._bufferViewCache = {};\r\n this._basicAnimationManager = undefined;\r\n this._localPath = '';\r\n this._visitedNodes = {};\r\n this._animatedNodes = {};\r\n this._bones = {};\r\n this._skeletonToInfluenceMap = {};\r\n this._stateSetMap = {};\r\n this._filesMap = {};\r\n this._inputReader = new Input();\r\n this._rootStateSet = new StateSet();\r\n\r\n this._defaultBlendFunc = new BlendFunc();\r\n this._transparentBlendFunc = new BlendFunc('SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA');\r\n this._defaultCullFace = new CullFace();\r\n this._doubleSideCullFace = new CullFace(CullFace.DISABLE);\r\n },\r\n\r\n // Adds variable to help to convert nodes to osgjs\r\n // - add parent variable to all nodes\r\n // - add unique node name\r\n _preProcessNodes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n var name;\r\n for (var i = 0; i < nodes.length; i++) {\r\n var node = nodes[i];\r\n name = node.name || '';\r\n name += '_' + i.toString();\r\n node.osgjsNodeName = name;\r\n\r\n var children = node.children;\r\n\r\n if (!children) continue;\r\n\r\n for (var j = 0; j < children.length; j++) {\r\n var child = children[j];\r\n nodes[child].parent = i;\r\n }\r\n }\r\n for (var k = 0; k < meshes.length; k++) {\r\n var mesh = meshes[k];\r\n name = mesh.name || '';\r\n name += '_' + k.toString();\r\n mesh.osgjsNodeName = name;\r\n }\r\n },\r\n\r\n loadBuffers: P.method(function() {\r\n var promises = [];\r\n var buffers = this._gltfJSON.buffers;\r\n for (var i = 0; i < buffers.length; i++) {\r\n var buffer = buffers[i];\r\n promises.push(\r\n this.loadURI(buffer.uri, { responseType: 'arraybuffer' }).then(function(\r\n arrayBuffer\r\n ) {\r\n buffer.data = arrayBuffer;\r\n })\r\n );\r\n }\r\n return P.all(promises);\r\n }),\r\n\r\n loadBufferViews: function() {\r\n var buffers = this._gltfJSON.buffers;\r\n var bufferViews = this._gltfJSON.bufferViews;\r\n for (var i = 0; i < bufferViews.length; i++) {\r\n var bufferView = bufferViews[i];\r\n var bufferIndex = bufferView.buffer;\r\n var buffer = buffers[bufferIndex];\r\n var byteLength = bufferView.byteLength || 0;\r\n var byteOffset = bufferView.byteOffset || 0;\r\n bufferView.data = buffer.data.slice(byteOffset, byteOffset + byteLength);\r\n }\r\n },\r\n\r\n loadAccessors: function() {\r\n var bufferViews = this._gltfJSON.bufferViews;\r\n var accessors = this._gltfJSON.accessors;\r\n for (var i = 0; i < accessors.length; i++) {\r\n var accessor = accessors[i];\r\n var bufferViewIndex = accessor.bufferView;\r\n var bufferView = bufferViews[bufferViewIndex];\r\n\r\n var itemSize = ReaderWriterQueen.TYPE_TABLE[accessor.type];\r\n var TypedArray = ReaderWriterQueen.WEBGL_COMPONENT_TYPES[accessor.componentType];\r\n\r\n // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.\r\n var elementBytes = TypedArray.BYTES_PER_ELEMENT;\r\n var itemBytes = elementBytes * itemSize;\r\n var byteStride = bufferView.byteStride;\r\n var normalized = accessor.normalized === true;\r\n var bufferArray;\r\n\r\n // The buffer is not interleaved if the stride is the item size in bytes.\r\n if (byteStride && byteStride !== itemBytes) {\r\n // Use the full buffer if it's interleaved.\r\n notify.warn('GLTF interleaved accessors not supported');\r\n } else {\r\n var data = new TypedArray(\r\n bufferView.data,\r\n accessor.byteOffset,\r\n accessor.count * itemSize\r\n );\r\n bufferArray = new BufferArray(undefined, data, itemSize);\r\n bufferArray.setNormalize(normalized);\r\n }\r\n accessor.data = bufferArray;\r\n }\r\n },\r\n\r\n _computeNodeMatrix: function(node) {\r\n var matrix;\r\n if (node.matrix) {\r\n matrix = mat4.clone(node.matrix);\r\n } else if (node.translation || node.rotation || node.scale) {\r\n var translation = mat4.IDENTITY;\r\n var rotation = mat4.IDENTITY;\r\n var scale = mat4.IDENTITY;\r\n if (node.translation)\r\n translation = mat4.fromTranslation(mat4.create(), node.translation);\r\n if (node.rotation) rotation = mat4.fromQuat(mat4.create(), node.rotation);\r\n if (node.scale) scale = mat4.fromScaling(mat4.create(), node.scale);\r\n matrix = mat4.create();\r\n mat4.multiply(matrix, rotation, scale);\r\n mat4.multiply(matrix, translation, matrix);\r\n }\r\n return matrix;\r\n },\r\n\r\n loadNodes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var skins = this._gltfJSON.skins;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n // create all nodes\r\n // children relationship will be done in loadScenes\r\n for (var i = 0; i < nodes.length; i++) {\r\n var node = nodes[i];\r\n if (node.usedAsBone) continue;\r\n if (node.skin !== undefined) {\r\n var skin = skins[node.skin];\r\n var skeleton = skin.osgjsNode;\r\n if (!skin.osgjsNodeAttached) {\r\n node.osgjsNode = skeleton;\r\n skin.osgjsNodeAttached = i;\r\n }\r\n var mesh = meshes[node.mesh];\r\n mesh.osgjsGeometry.setBoneNameID(skin.osgjsBoneMapID);\r\n skeleton.addChild(mesh.osgjsGeometry);\r\n } else {\r\n if (node.matrix || node.translation || node.rotation || node.scale) {\r\n node.osgjsNode = this._createMatrixTransform(i);\r\n }\r\n if (node.mesh !== undefined) {\r\n if (node.osgjsNode) {\r\n node.osgjsNode.addChild(meshes[node.mesh].osgjsGeometry);\r\n } else {\r\n node.osgjsNode = meshes[node.mesh].osgjsGeometry;\r\n }\r\n }\r\n if (!node.osgjsNode) {\r\n node.osgjsNode = new Node();\r\n }\r\n }\r\n if (node.name) node.osgjsNode.setName(node.name);\r\n }\r\n },\r\n\r\n _linkNodes: function(parent) {\r\n var nodes = this._gltfJSON.nodes;\r\n var children = parent.children;\r\n if (!children) return;\r\n\r\n for (var i = 0; i < children.length; i++) {\r\n var node = nodes[children[i]];\r\n\r\n // skip node used as bone\r\n if (node.usedAsBone) continue;\r\n\r\n var osgjsChild = node.osgjsNode;\r\n if (osgjsChild && !parent.osgjsNode.hasChild(osgjsChild)) {\r\n parent.osgjsNode.addChild(osgjsChild);\r\n this._linkNodes(node);\r\n }\r\n }\r\n },\r\n\r\n loadSkins: function() {\r\n var skins = this._gltfJSON.skins;\r\n if (!skins) return;\r\n\r\n for (var i = 0; i < skins.length; i++) {\r\n this._processSkin(i);\r\n }\r\n },\r\n\r\n loadScenes: function() {\r\n var nodes = this._gltfJSON.nodes;\r\n var scenes = this._gltfJSON.scenes;\r\n\r\n this._osgjsScene = [];\r\n\r\n for (var i = 0; i < scenes.length; i++) {\r\n var scene = scenes[i];\r\n var sceneNodes = scene.nodes;\r\n var rootNodes = [];\r\n for (var j = 0; j < sceneNodes.length; j++) {\r\n var node = nodes[sceneNodes[j]];\r\n this._linkNodes(node);\r\n rootNodes.push(node.osgjsNode);\r\n }\r\n\r\n var root = rootNodes[0];\r\n if (rootNodes.length > 1) {\r\n root = new Node();\r\n for (var r = 0; r < rootNodes.length; r++) {\r\n root.addChild(rootNodes[r]);\r\n }\r\n }\r\n this._osgjsScene.push(root);\r\n }\r\n },\r\n\r\n _assignGeometryAttributes: function(osgjsGeometry, gltfAttributes, index) {\r\n var accessors = this._gltfJSON.accessors;\r\n for (var attribute in gltfAttributes) {\r\n var accessorIndex = gltfAttributes[attribute];\r\n var accessor = accessors[accessorIndex];\r\n var osgjsAttributeName = ReaderWriterQueen.ATTRIBUTE_OSGJS_TABLE[attribute];\r\n if (index !== undefined) osgjsAttributeName += '_' + index.toString();\r\n osgjsGeometry.getVertexAttributeList()[osgjsAttributeName] = accessor.data;\r\n accessor.data._target = BufferArray.ARRAY_BUFFER;\r\n }\r\n },\r\n\r\n _assignGeometryPrimitives: function(osgjsGeometry, primitive) {\r\n var accessors = this._gltfJSON.accessors;\r\n var indexes = accessors[primitive.indices];\r\n indexes.data._target = BufferArray.ELEMENT_ARRAY_BUFFER;\r\n var primitiveMode = primitive.mode !== undefined ? primitive.mode : primitiveSet.TRIANGLES;\r\n var osgPrimitive = new DrawElements(primitiveMode, indexes.data);\r\n osgjsGeometry.getPrimitiveSetList().push(osgPrimitive);\r\n },\r\n\r\n _getMorphTargetName: function(mesh, index) {\r\n return mesh.osgjsNodeName + '_target_' + index.toString();\r\n },\r\n\r\n _computeAbsoluteMorphData: function(baseAttributes, morphAttributes) {\r\n var accessors = this._gltfJSON.accessors;\r\n for (var attribute in morphAttributes) {\r\n var accessorIndex = morphAttributes[attribute];\r\n var accessor = accessors[accessorIndex];\r\n\r\n if (accessor.morphAbsoluteComputed) continue; // dont compute twice absolute targets\r\n accessor.morphAbsoluteComputed = true;\r\n\r\n var baseAccessorIndex = baseAttributes[attribute];\r\n var baseAccessor = accessors[baseAccessorIndex];\r\n\r\n var base = baseAccessor.data.getElements();\r\n var target = accessor.data.getElements();\r\n var nbElements = base.length;\r\n for (var i = 0; i < nbElements; i++) {\r\n target[i] += base[i];\r\n }\r\n }\r\n },\r\n\r\n _processMorphGeometry: function(mesh, primitiveIndex) {\r\n var primitive = mesh.primitives[primitiveIndex];\r\n var geometry = new MorphGeometry();\r\n var morphUpdateCallback = new UpdateMorph();\r\n morphUpdateCallback.setName(mesh.osgjsNodeName);\r\n geometry.setName(mesh.osgjsNodeName);\r\n for (var t = 0; t < primitive.targets.length; t++) {\r\n this._computeAbsoluteMorphData(primitive.attributes, primitive.targets[t]);\r\n var targetName = this._getMorphTargetName(mesh, t);\r\n var morphTarget = new Geometry();\r\n morphTarget.setName(targetName);\r\n morphUpdateCallback.addTarget(targetName, t);\r\n this._assignGeometryAttributes(morphTarget, primitive.targets[t]);\r\n geometry.getMorphTargets().push(morphTarget);\r\n }\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n geometry.mergeChildrenVertexAttributeList();\r\n\r\n // set result in gltf mesh\r\n mesh.osgjsMorphGeometry = geometry;\r\n mesh.osgjsUpdateMorph = morphUpdateCallback;\r\n },\r\n\r\n loadMeshes: function() {\r\n var meshes = this._gltfJSON.meshes;\r\n var materials = this._gltfJSON.materials;\r\n\r\n for (var i = 0; i < meshes.length; i++) {\r\n var mesh = meshes[i];\r\n var name = mesh.name;\r\n var osgjsGeometries = [];\r\n for (var j = 0; j < mesh.primitives.length; j++) {\r\n var geometry = undefined;\r\n var primitive = mesh.primitives[j];\r\n var morphUpdateCallback = undefined;\r\n // means we have morph target\r\n if (primitive.targets && primitive.targets.length) {\r\n this._processMorphGeometry(mesh, j);\r\n geometry = mesh.osgjsMorphGeometry;\r\n morphUpdateCallback = mesh.osgjsUpdateMorph;\r\n }\r\n\r\n if (primitive.attributes.JOINTS_0) {\r\n var rigGeometry = new RigGeometry();\r\n if (!geometry) {\r\n geometry = new Geometry();\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n }\r\n var bbox = new BoundingBox();\r\n geometry.computeBoundingBox(bbox);\r\n rigGeometry.setBound(bbox);\r\n\r\n rigGeometry.setSourceGeometry(geometry);\r\n rigGeometry.mergeChildrenData();\r\n geometry = rigGeometry;\r\n }\r\n\r\n if (!geometry) {\r\n geometry = new Geometry();\r\n this._assignGeometryAttributes(geometry, primitive.attributes);\r\n this._assignGeometryPrimitives(geometry, primitive);\r\n }\r\n\r\n if (name) geometry.setName(name);\r\n\r\n // if has a morph geometry we addd the update callback on the top geometry\r\n if (morphUpdateCallback) geometry.addUpdateCallback(morphUpdateCallback);\r\n\r\n var osgjsStateSet = materials[primitive.material].osgjsStateSet;\r\n geometry.setStateSet(osgjsStateSet);\r\n geometry.setUserData(osgjsStateSet.getUserData());\r\n osgjsGeometries.push(geometry);\r\n }\r\n\r\n if (osgjsGeometries.length > 1) {\r\n var node = new Node();\r\n for (var c = 0; c < osgjsGeometries.length; c++) node.addChild(osgjsGeometries[c]);\r\n geometry = node;\r\n }\r\n mesh.osgjsGeometry = geometry;\r\n }\r\n },\r\n\r\n loadImages: function() {\r\n var images = this._gltfJSON.images;\r\n if (!images) return P.resolve();\r\n\r\n var promises = [];\r\n \r\n for (var i = 0; i < images.length; i++) {\r\n var image = images[i];\r\n if (!image.uri) continue;\r\n \r\n var url = window.decodeURI(image.uri);\r\n var promise = this.loadURI(url).then(\r\n function(imageData) {\r\n var osgjsImage = new Image();\r\n osgjsImage.setImage(imageData);\r\n this.osgjsImage = osgjsImage;\r\n }.bind(image)\r\n );\r\n promises.push(promise);\r\n }\r\n return P.all(promises);\r\n },\r\n\r\n _texture: function(gltfTexture) {\r\n var textures = this._gltfJSON.textures;\r\n var images = this._gltfJSON.images;\r\n var texture = textures[gltfTexture.index];\r\n var image = images[texture.source];\r\n\r\n if (texture.osgjsTexture) return texture.osgjsTexture;\r\n\r\n var osgjsTexture = new Texture();\r\n texture.osgjsTexture = osgjsTexture;\r\n\r\n // GLTF texture origin is correct\r\n osgjsTexture.setFlipY(false);\r\n osgjsTexture.setWrapS('REPEAT');\r\n osgjsTexture.setWrapT('REPEAT');\r\n\r\n if (image.osgjsImage) {\r\n var format = ReaderWriterQueen.TEXTURE_FORMAT[texture.format];\r\n osgjsTexture.setImage(image.osgjsImage, format);\r\n }\r\n return osgjsTexture;\r\n },\r\n\r\n _pbrMetallicRoughnessTextureUniforms: function() {\r\n var stateSet = this._rootStateSet;\r\n if (stateSet.getUniformList()[ReaderWriterQueen.ALBEDO_UNIFORM]) return;\r\n\r\n var albedo = Uniform.createInt(\r\n ReaderWriterQueen.ALBEDO_TEXTURE_UNIT,\r\n ReaderWriterQueen.ALBEDO_UNIFORM\r\n );\r\n var metalnessRoughness = Uniform.createInt(\r\n ReaderWriterQueen.METALLIC_ROUGHNESS_TEXTURE_UNIT,\r\n ReaderWriterQueen.METALLIC_ROUGHNESS_UNIFORM\r\n );\r\n stateSet.addUniform(albedo);\r\n stateSet.addUniform(metalnessRoughness);\r\n },\r\n\r\n _pbrMetallicRoughness: function(material, stateSet) {\r\n stateSet.setUserData({\r\n pbrWorklow: ReaderWriterQueen.PBR_METAL_MODE\r\n });\r\n this._pbrMetallicRoughnessTextureUniforms();\r\n\r\n var osgjsTexture;\r\n // baseColor\r\n if (material.baseColorTexture) {\r\n osgjsTexture = this._texture(material.baseColorTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.ALBEDO_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n } else if (material.baseColorFactor) {\r\n //PBR default uniforms\r\n var color = Uniform.createFloat4(material.baseColorFactor, 'uBaseColorFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n // metallic\r\n if (material.metallicFactor !== undefined) {\r\n var metallic = Uniform.createFloat1(material.metallicFactor, 'uMetallicFactor');\r\n stateSet.addUniform(metallic);\r\n }\r\n\r\n if (material.roughnessFactor !== undefined) {\r\n var roughness = Uniform.createFloat1(material.roughnessFactor, 'uRoughnessFactor');\r\n stateSet.addUniform(roughness);\r\n }\r\n\r\n if (material.metallicRoughnessTexture) {\r\n osgjsTexture = this._texture(material.metallicRoughnessTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.METALLIC_ROUGHNESS_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n },\r\n\r\n _KHR_materials_pbrSpecularGlossinessTextureUniforms: function() {\r\n if (this._extensions['KHR_materials_pbrSpecularGlossinessTextureUniforms']) return;\r\n this._extensions['KHR_materials_pbrSpecularGlossinessTextureUniforms'] = true;\r\n\r\n var stateSet = this._rootStateSet;\r\n var albedo = Uniform.createInt(\r\n ReaderWriterQueen.DIFFUSE_TEXTURE_UNIT,\r\n ReaderWriterQueen.ALBEDO_UNIFORM\r\n );\r\n var specluarGlossiness = Uniform.createInt(\r\n ReaderWriterQueen.SPECULAR_GLOSSINESS_TEXTURE_UNIT,\r\n ReaderWriterQueen.METALLIC_ROUGHNESS_UNIFORM\r\n );\r\n var specular = Uniform.createInt(\r\n ReaderWriterQueen.SPECULAR_TEXTURE_UNIT,\r\n ReaderWriterQueen.SPECULAR_UNIFORM\r\n );\r\n\r\n stateSet.addUniform(albedo);\r\n stateSet.addUniform(specluarGlossiness);\r\n stateSet.addUniform(specular);\r\n },\r\n\r\n _KHR_materials_pbrSpecularGlossiness: function(material, stateSet) {\r\n stateSet.setUserData({\r\n pbrWorklow: ReaderWriterQueen.PBR_SPEC_MODE\r\n });\r\n\r\n this._KHR_materials_pbrSpecularGlossinessTextureUniforms();\r\n\r\n var osgjsTexture;\r\n var color;\r\n if (material.diffuseTexture) {\r\n osgjsTexture = this._texture(material.diffuseTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.DIFFUSE_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n } else if (material.diffuseFactor) {\r\n color = Uniform.createFloat4(material.diffuseFactor, 'uBaseColorFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n if (material.specularFactor) {\r\n color = Uniform.createFloat3(material.specularFactor, 'uSpecularFactor');\r\n stateSet.addUniform(color);\r\n }\r\n\r\n if (material.glossinessFactor !== undefined) {\r\n var factor = Uniform.createFloat(material.glossinessFactor, 'uGlossinessFactor');\r\n stateSet.addUniform(factor);\r\n }\r\n\r\n if (material.specularGlossinessTexture) {\r\n osgjsTexture = this._texture(material.specularGlossinessTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.SPECULAR_GLOSSINESS_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n },\r\n\r\n loadMaterials: function() {\r\n var materials = this._gltfJSON.materials;\r\n var hasTransparentMaterial = false;\r\n var hasDoubleSidedMaterial = false;\r\n\r\n var rootStateSet = this._rootStateSet;\r\n rootStateSet.addUniform(\r\n Uniform.createInt(\r\n ReaderWriterQueen.EMISSIVE_TEXTURE_UNIT,\r\n ReaderWriterQueen.EMISSIVE_UNIFORM\r\n )\r\n );\r\n rootStateSet.addUniform(\r\n Uniform.createInt(ReaderWriterQueen.AO_TEXTURE_UNIT, ReaderWriterQueen.AO_UNIFORM)\r\n );\r\n rootStateSet.addUniform(\r\n Uniform.createInt(ReaderWriterQueen.NORMAL_TEXTURE_UNIT, ReaderWriterQueen.NORMAL_UNIFORM)\r\n );\r\n rootStateSet.addUniform(Uniform.createFloat3(vec3.ZERO, 'uEmissiveFactor'));\r\n\r\n for (var i = 0; i < materials.length; i++) {\r\n var material = materials[i];\r\n var stateSet = new StateSet();\r\n var osgjsTexture;\r\n material.osgjsStateSet = stateSet;\r\n\r\n if (material.pbrMetallicRoughness) {\r\n this._pbrMetallicRoughness(material.pbrMetallicRoughness, stateSet);\r\n } else if (material.extensions.KHR_materials_pbrSpecularGlossiness) {\r\n // https://github.com/KhronosGroup/glTF/blob/master/extensions/Khronos/KHR_materials_pbrSpecularGlossiness/README.md\r\n this._KHR_materials_pbrSpecularGlossiness(\r\n material.extensions.KHR_materials_pbrSpecularGlossiness,\r\n stateSet\r\n );\r\n }\r\n\r\n if (material.normalTexture) {\r\n osgjsTexture = this._texture(material.normalTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.NORMAL_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n\r\n if (material.occlusionTexture) {\r\n osgjsTexture = this._texture(material.occlusionTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.AO_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n\r\n if (material.emissiveTexture) {\r\n osgjsTexture = this._texture(material.emissiveTexture);\r\n stateSet.setTextureAttributeAndModes(\r\n ReaderWriterQueen.EMISSIVE_TEXTURE_UNIT,\r\n osgjsTexture\r\n );\r\n }\r\n if (material.emissiveFactor) {\r\n stateSet.addUniform(\r\n Uniform.createFloat3(material.emissiveFactor, 'uEmissiveFactor')\r\n );\r\n }\r\n\r\n if (material.alphaMode === 'BLEND') {\r\n hasTransparentMaterial = true;\r\n stateSet.setAttributeAndModes(this._transparentBlendFunc);\r\n stateSet.setRenderingHint('TRANSPARENT_BIN');\r\n }\r\n\r\n if (material.doubleSided) {\r\n hasDoubleSidedMaterial = true;\r\n stateSet.setAttributeAndModes(this._doubleSideCullFace);\r\n }\r\n }\r\n\r\n // need to add a default blend func if we have transparent materials in the model\r\n if (hasTransparentMaterial) {\r\n rootStateSet.setAttributeAndModes(this._defaultBlendFunc);\r\n }\r\n\r\n if (hasDoubleSidedMaterial) {\r\n rootStateSet.setAttributeAndModes(this._defaultCullFace);\r\n }\r\n },\r\n\r\n _createBone: function(nodeID) {\r\n var nodes = this._gltfJSON.nodes;\r\n var node = nodes[nodeID];\r\n node.usedAsBone = true;\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n\r\n var osgjsNode = new Bone();\r\n var name = node.osgjsNodeName;\r\n osgjsNode.setName(name);\r\n\r\n var matrix = this._computeNodeMatrix(node) || mat4.IDENTITY;\r\n osgjsNode.setMatrix(matrix);\r\n\r\n var updateCallback = new UpdateBone();\r\n updateCallback.setName(osgjsNode.getName());\r\n osgjsNode.addUpdateCallback(updateCallback);\r\n\r\n if (nodeAnimationTypes[nodeID]) {\r\n var stackTransforms = updateCallback.getStackedTransforms();\r\n for (var channelType in nodeAnimationTypes[nodeID]) {\r\n var StackedType = ReaderWriterQueen.TYPE_STACKED_TRANSFORMS[channelType];\r\n var stack = new StackedType(channelType);\r\n stackTransforms.push(stack);\r\n }\r\n }\r\n\r\n // we set the default updateBone matrix with the bone matrix to avoid to copy identity\r\n // matrix when no animation is yet started\r\n updateCallback.setMatrix(matrix);\r\n //osgjsNode.addChild(shape.createAxisGeometry());\r\n return osgjsNode;\r\n },\r\n\r\n _createMatrixTransform: function(nodeID) {\r\n var nodes = this._gltfJSON.nodes;\r\n var node = nodes[nodeID];\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n\r\n var osgjsNode = new MatrixTransform();\r\n var name = node.osgjsNodeName;\r\n osgjsNode.setName(name);\r\n\r\n var matrix = this._computeNodeMatrix(node) || mat4.IDENTITY;\r\n osgjsNode.setMatrix(matrix);\r\n\r\n if (nodeAnimationTypes[nodeID]) {\r\n var updateCallback = new UpdateMatrixTransform();\r\n updateCallback.setName(osgjsNode.getName());\r\n osgjsNode.addUpdateCallback(updateCallback);\r\n updateCallback.setMatrix(matrix);\r\n\r\n var stackTransforms = updateCallback.getStackedTransforms();\r\n for (var channelType in nodeAnimationTypes[nodeID]) {\r\n var StackedType = ReaderWriterQueen.TYPE_STACKED_TRANSFORMS[channelType];\r\n var stack = new StackedType(channelType);\r\n stackTransforms.push(stack);\r\n }\r\n }\r\n\r\n return osgjsNode;\r\n },\r\n\r\n _processSkin: function(skinID) {\r\n var skins = this._gltfJSON.skins;\r\n var nodes = this._gltfJSON.nodes;\r\n var skin = skins[skinID];\r\n var joints = skin.joints;\r\n\r\n var inverseBindMatrixAccessor, arrayBuffer;\r\n if (skin.inverseBindMatrices !== undefined) {\r\n inverseBindMatrixAccessor = this._gltfJSON.accessors[skin.inverseBindMatrices].data;\r\n arrayBuffer = inverseBindMatrixAccessor.getElements().buffer;\r\n }\r\n\r\n var skeleton = new Skeleton();\r\n skin.osgjsNode = skeleton;\r\n skeleton.setName('skin ID ' + skinID);\r\n var nodeID;\r\n var boneMap = {};\r\n var boneMapID = {};\r\n var node;\r\n var bone;\r\n // first create all bones\r\n for (var i = 0; i < joints.length; i++) {\r\n nodeID = joints[i];\r\n bone = this._createBone(nodeID);\r\n if (skin.inverseBindMatrices !== undefined) {\r\n var matrix = new Float32Array(arrayBuffer, i * 16 * 4, 16);\r\n bone.setInvBindMatrixInSkeletonSpace(matrix);\r\n }\r\n boneMap[nodeID] = bone;\r\n boneMapID[bone.getName()] = i;\r\n }\r\n skin.osgjsBoneMapID = boneMapID;\r\n\r\n for (var boneID in boneMap) {\r\n node = nodes[boneID];\r\n var parentID = node.parent;\r\n bone = boneMap[boneID];\r\n if (parentID === undefined || joints.indexOf(parentID) === -1) {\r\n skeleton.addChild(bone);\r\n } else {\r\n var boneParent = boneMap[parentID];\r\n boneParent.addChild(bone);\r\n }\r\n }\r\n },\r\n\r\n loadAnimations: function() {\r\n var animations = this._gltfJSON.animations;\r\n if (!animations) return;\r\n\r\n var accessors = this._gltfJSON.accessors;\r\n var nodeAnimationTypes = this._nodeAnimationTypes;\r\n var nodes = this._gltfJSON.nodes;\r\n var meshes = this._gltfJSON.meshes;\r\n\r\n var osgjsAnimations = [];\r\n for (var i = 0; i < animations.length; i++) {\r\n var channels = animations[i].channels;\r\n var samplers = animations[i].samplers;\r\n var osgjsChannels = [];\r\n for (var j = 0; j < channels.length; j++) {\r\n var channel = channels[j];\r\n var sampler = samplers[channel.sampler];\r\n var times = accessors[sampler.input].data.getElements();\r\n var accessorValues = accessors[sampler.output];\r\n var values = accessorValues.data.getElements();\r\n // target.id is deprecated\r\n var target = channel.target;\r\n var createChannel =\r\n ReaderWriterQueen.TYPE_CHANNEL_PATH[target.path][accessorValues.type];\r\n\r\n var nodeIndex = target.node !== undefined ? target.node : target.id;\r\n var node = nodes[nodeIndex];\r\n var channelName = target.path;\r\n var targetName = nodes[nodeIndex].osgjsNodeName;\r\n // needs to get the updateCallback name of the morph geometry\r\n if (channelName === 'weights') {\r\n // if morph target we need to split each channel into scalar for each target\r\n var mesh = meshes[node.mesh];\r\n\r\n var nbTargets = mesh.primitives[0].targets.length;\r\n var nkKeys = times.length;\r\n for (var targetIndex = 0; targetIndex < nbTargets; targetIndex++) {\r\n var weights = new Float32Array(nkKeys);\r\n for (var v = 0; v < nkKeys; v++) {\r\n weights[v] = values[v * nbTargets + targetIndex];\r\n }\r\n targetName = this._getMorphTargetName(mesh, targetIndex);\r\n osgjsChannels.push(createChannel(weights, times, targetName, targetIndex));\r\n }\r\n } else {\r\n osgjsChannels.push(createChannel(values, times, targetName, channelName));\r\n }\r\n\r\n if (!nodeAnimationTypes[nodeIndex]) nodeAnimationTypes[nodeIndex] = {};\r\n nodeAnimationTypes[nodeIndex][channelName] = true;\r\n }\r\n\r\n var animationName = 'animation-' + i.toString();\r\n osgjsAnimations.push(animationFactory.createAnimation(osgjsChannels, animationName));\r\n }\r\n\r\n var animationManager = new BasicAnimationManager();\r\n animationManager.init(osgjsAnimations);\r\n this._animationManager = animationManager;\r\n },\r\n\r\n loadURI: P.method(function(uri, options) {\r\n // is base64 inline data\r\n if (uri.substr(0, 5) === 'data:') {\r\n return base64ToArrayBuffer(uri);\r\n }\r\n\r\n var result = this._filesMap[uri];\r\n if (result !== undefined) return result;\r\n return fileHelper.requestURI(uri, options);\r\n }),\r\n\r\n readNodeURL: function(url, options) {\r\n var self = this;\r\n\r\n this.init();\r\n if (options && options.filesMap !== undefined && Object.keys(options.filesMap).length > 0) {\r\n // it comes from the ZIP plugin or from drag'n drop\r\n // So we already have all the files.\r\n this._filesMap = options.filesMap;\r\n var glTFFile = this._filesMap[url];\r\n return this.readJSON(glTFFile, url);\r\n }\r\n\r\n var index = url.lastIndexOf('/');\r\n this._localPath = index === -1 ? '' : url.substr(0, index + 1);\r\n // Else it is a usual XHR request\r\n return fileHelper.requestURI(url).then(function(file) {\r\n return self.readJSON(file);\r\n });\r\n },\r\n\r\n readJSON: P.method(function(json, url) {\r\n if (typeof json == \"string\") json = JSON.parse(json);\r\n\r\n this._gltfJSON = json;\r\n\r\n return P.all([this.loadBuffers(), this.loadImages()]).then(\r\n function() {\r\n this.loadBufferViews();\r\n this.loadAccessors();\r\n this._preProcessNodes();\r\n this.loadMaterials();\r\n this.loadMeshes();\r\n this.loadAnimations();\r\n this.loadSkins();\r\n this.loadNodes();\r\n this.loadScenes();\r\n\r\n var root = new MatrixTransform();\r\n root.addChild(this._osgjsScene[0]);\r\n root.setName(url);\r\n if (this._animationManager) root.addUpdateCallback(this._animationManager);\r\n root.setStateSet(this._rootStateSet);\r\n return root;\r\n }.bind(this)\r\n );\r\n })\r\n};\r\n\r\nRegistry.instance().addReaderWriter('queen', new ReaderWriterQueen());\r\n\r\nexport default ReaderWriterQueen;\r\n","import ReaderWriterGLTF from './ReaderWriterGLTF';\r\nimport ReaderWriterZIP from './ReaderWriterZIP';\r\nimport ReaderWriterQueen from './ReaderWriterQueen';\r\n\r\nvar osgPlugins = {};\r\n\r\nosgPlugins.ReaderWriterGLTF = ReaderWriterGLTF;\r\nosgPlugins.ReaderWriterZIP = ReaderWriterZIP;\r\nosgPlugins.ReaderWriterQueen = ReaderWriterQueen;\r\n\r\nexport default osgPlugins;\r\n","import readerParser from \"@/queen3d/queen/osgDB/readerParser\";\r\nimport osgPlugins from \"@/queen3d/queen/osgPlugins/osgPlugins\";\r\n\r\nimport UVTransformAttribute from \"@/queen3d/queen/application/UVTransformAttribute\";\r\nimport MaterialUtils from \"@/queen3d/queen/application/material/MaterialUtils\";\r\nimport { GeomNodeVisitor } from \"@/queen3d/queen/application/objects/GeomNodeVisitor\";\r\nimport { GeomNodeVisitorV3 } from \"@/queen3d/queen/application/objects/GeomNodeVisitorV3\";\r\n\r\nimport UVProjectionAttribute from \"@/queen3d/queen/application/UVProjectionAttribute\";\r\n\r\n//@ts-ignore\r\nwindow.osgPlugins = osgPlugins;\r\n\r\n export function loadFileTest() {\r\n\r\n debugger\r\n const model = readerParser.readNodeURL(\"/dotqueen/dotqueen.queen\");\r\n\r\n if (typeof model == \"string\") {\r\n console.error(model);\r\n return null;\r\n }\r\n\r\n // const Visitor = options.version == \"3.0\" ? GeomNodeVisitorV3 : GeomNodeVisitor;\r\n // const pm = new Visitor(function(node) {\r\n // MaterialUtils.resetGeometryStateSet(node);\r\n // const uvTranform = new UVTransformAttribute();\r\n // node.getOrCreateStateSet().setAttributeAndModes(uvTranform);\r\n\r\n // if (options && options.uvproject) {\r\n // const UVProjection = new UVProjectionAttribute();\r\n // node.getOrCreateStateSet().setAttributeAndModes(UVProjection);\r\n // }\r\n // });\r\n // model.accept(pm);\r\n return model;\r\n }","import { css } from \"@linaria/core\";\nimport { defineComponent, onMounted, reactive, ref } from \"vue\";\nimport { loadFileTest } from \"./test\";\nexport default defineComponent({\n setup(props) {\n onMounted(() => {\n loadFileTest();\n });\n\n function renderAsset() {\n return <div>\r\n .queen文件加载\r\n </div>;\n }\n\n return () => {\n return <div class={ContentStyle}>\r\n {renderAsset()}\r\n </div>;\n };\n }\n\n});\nconst ContentStyle = \"cwonz6i\";\n\nrequire(\"../../../../../.linaria-cache/src/pages/website/routes/dotqueen/index.linaria.css\");","import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';\r\nimport Preview from './preview';\r\nimport Dotqueen from './dotqueen';\r\nconst routes: Array<RouteRecordRaw> = [\r\n {\r\n path: '/',\r\n name: 'preview',\r\n component: Preview,\r\n }, {\r\n path: '/dotqueen',\r\n name: 'dotqueen',\r\n component: Dotqueen,\r\n }\r\n];\r\n\r\nconst router = createRouter({\r\n history: createWebHashHistory(),\r\n routes,\r\n});\r\n\r\nexport default router;\r\n","import { defineComponent } from 'vue';\r\nexport default defineComponent({\r\n setup() {\r\n return () => <router-view />;\r\n },\r\n});\r\n","import { createApp } from 'vue';\r\nimport routes from './routes';\r\nimport App from './App';\r\n\r\nconst app = createApp(App);\r\napp.use(routes);\r\napp.mount('#app');\r\n","import PooledArray from './PooledArray';\r\n\r\nvar PooledMap = function() {\r\n this._keys = new PooledArray();\r\n this._map = {};\r\n};\r\n\r\nPooledMap.prototype = {\r\n reset: function() {\r\n var array = this._keys.getArray();\r\n var arrayLength = this._keys.getLength();\r\n for (var i = 0; i < arrayLength; i++) {\r\n var key = array[i];\r\n this._map[key] = undefined;\r\n }\r\n this._keys.reset();\r\n },\r\n /**\r\n * Set a key value\r\n * you have to check that the key does not exist before otherwise you could hit performance hit when calling reset/forEach\r\n */\r\n set: function(key, value) {\r\n this._keys.push(key);\r\n this._map[key] = value;\r\n },\r\n hasKey: function(key) {\r\n return this._map[key] !== undefined;\r\n },\r\n getMap: function() {\r\n return this._map;\r\n },\r\n getKeys: function() {\r\n return this._keys;\r\n },\r\n forEach: function(func) {\r\n var array = this._keys.getArray();\r\n var arrayLength = this._keys.getLength();\r\n for (var i = 0; i < arrayLength; i++) {\r\n var key = array[i];\r\n func(key, this._map[key]);\r\n }\r\n }\r\n};\r\n\r\nexport default PooledMap;","import utils from './utils';\r\nimport Object from './Object';\r\nimport BoundingBox from './BoundingBox';\r\nimport BoundingSphere from './BoundingSphere';\r\nimport StateSet from './StateSet';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport { mat4 } from './glMatrix';\r\nimport PooledResource from './PooledResource';\r\nimport ComputeMatrixFromNodePath from './computeMatrixFromNodePath';\r\nimport TransformEnums from './transformEnums';\r\n\r\n/**\r\n * Node that can contains child node\r\n * @class Node\r\n */\r\nvar Node = function() {\r\n Object.call(this);\r\n\r\n this.children = [];\r\n this._parents = [];\r\n /*jshint bitwise: false */\r\n this.nodeMask = ~0;\r\n /*jshint bitwise: true */\r\n\r\n this._boundingSphere = new BoundingSphere();\r\n this._boundingSphereComputed = false;\r\n\r\n this._boundingBox = new BoundingBox();\r\n this._boundingBoxComputed = false;\r\n\r\n this._updateCallbacks = [];\r\n this._cullCallback = undefined;\r\n this._cullingActive = true;\r\n this._numChildrenWithCullingDisabled = 0;\r\n this._numChildrenRequiringUpdateTraversal = 0;\r\n\r\n // it's a tmp object for internal use, do not use\r\n this._tmpBox = new BoundingBox();\r\n};\r\n\r\nvar pooledMatrix = new PooledResource(mat4.create);\r\nvar nodeGetMat = function() {\r\n var matrix = pooledMatrix.getOrCreateObject();\r\n return mat4.identity(matrix);\r\n};\r\n\r\n/** @lends Node.prototype */\r\nutils.createPrototypeNode(\r\n Node,\r\n utils.objectInherit(Object.prototype, {\r\n /**\r\n Return StateSet and create it if it does not exist yet\r\n @type StateSet\r\n */\r\n getOrCreateStateSet: function() {\r\n if (!this.stateset) this.setStateSet(new StateSet());\r\n return this.stateset;\r\n },\r\n\r\n getStateSet: function() {\r\n return this.stateset;\r\n },\r\n\r\n accept: function(nv) {\r\n if (nv.validNodeMask(this)) {\r\n nv.pushOntoNodePath(this);\r\n nv.apply(this);\r\n nv.popFromNodePath();\r\n }\r\n },\r\n\r\n dirtyBound: function() {\r\n if (this._boundingSphereComputed === true || this._boundingBoxComputed === true) {\r\n this._boundingSphereComputed = false;\r\n this._boundingBoxComputed = false;\r\n var parents = this._parents;\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n parents[i].dirtyBound();\r\n }\r\n }\r\n },\r\n\r\n setNodeMask: function(mask) {\r\n this.nodeMask = mask;\r\n },\r\n\r\n getNodeMask: function() {\r\n return this.nodeMask;\r\n },\r\n\r\n setStateSet: function(stateSet) {\r\n if (this.stateset === stateSet) return;\r\n\r\n var deltaUpdate = 0;\r\n\r\n if (this.stateset) {\r\n if (this.stateset.requiresUpdateTraversal()) deltaUpdate--;\r\n this.stateset.removeParent(this);\r\n }\r\n\r\n if (stateSet) {\r\n stateSet.addParent(this);\r\n if (stateSet.requiresUpdateTraversal()) ++deltaUpdate;\r\n }\r\n\r\n if (deltaUpdate !== 0)\r\n this.setNumChildrenRequiringUpdateTraversal(\r\n this.getNumChildrenRequiringUpdateTraversal() + deltaUpdate\r\n );\r\n\r\n this.stateset = stateSet;\r\n },\r\n\r\n _updateNumChildrenRequeringUpdateTraversal: function(delta) {\r\n if (this._numChildrenRequiringUpdateTraversal === 0 && this._parents.length) {\r\n // the number of callbacks has changed, need to pass this\r\n // on to parents so they know whether app traversal is\r\n // required on this subgraph.\r\n for (var i = 0, l = this._parents.length; i < l; i++) {\r\n var parent = this._parents[i];\r\n var num = parent.getNumChildrenRequiringUpdateTraversal();\r\n parent.setNumChildrenRequiringUpdateTraversal(num + delta);\r\n }\r\n }\r\n },\r\n\r\n setNumChildrenRequiringUpdateTraversal: function(num) {\r\n // if no changes just return.\r\n if (this._numChildrenRequiringUpdateTraversal === num) return;\r\n\r\n // note, if _updateCallback is set then the\r\n // parents won't be affected by any changes to\r\n // _numChildrenRequiringUpdateTraversal so no need to inform them.\r\n if (!this._updateCallbacks.length && this._parents.length) {\r\n // need to pass on changes to parents.\r\n var delta = 0;\r\n if (this._numChildrenRequiringUpdateTraversal > 0) --delta;\r\n if (num > 0) ++delta;\r\n\r\n if (delta !== 0) {\r\n // the number of callbacks has changed, need to pass this\r\n // on to parents so they know whether app traversal is\r\n // required on this subgraph.\r\n var parents = this._parents;\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n var parent = parents[i];\r\n var parentNum = parent.getNumChildrenRequiringUpdateTraversal();\r\n parent.setNumChildrenRequiringUpdateTraversal(parentNum + delta);\r\n }\r\n }\r\n }\r\n\r\n // finally update this objects value.\r\n this._numChildrenRequiringUpdateTraversal = num;\r\n },\r\n\r\n getNumChildrenRequiringUpdateTraversal: function() {\r\n return this._numChildrenRequiringUpdateTraversal;\r\n },\r\n\r\n /** Get update node callback, called during update traversal.\r\n @type Oject\r\n */\r\n getUpdateCallback: function() {\r\n return this._updateCallbacks[0];\r\n },\r\n\r\n addUpdateCallback: function(cb) {\r\n var hasExistingCallback = Boolean(this._updateCallbacks.length);\r\n this._updateCallbacks.push(cb);\r\n\r\n // send the signal on first add\r\n if (!hasExistingCallback) this._updateNumChildrenRequeringUpdateTraversal(1);\r\n },\r\n\r\n removeUpdateCallback: function(cb) {\r\n var arrayIdx = this._updateCallbacks.indexOf(cb);\r\n if (arrayIdx === -1) return;\r\n this._updateCallbacks.splice(arrayIdx, 1);\r\n\r\n // send the signal when no more callback\r\n if (!this._updateCallbacks.length) this._updateNumChildrenRequeringUpdateTraversal(-1);\r\n },\r\n getUpdateCallbackList: function() {\r\n return this._updateCallbacks;\r\n },\r\n\r\n /**\r\n <p>\r\n Set cull node callback, called during cull traversal.\r\n The Object must have the following method\r\n cull(node, nodeVisitor) {}\r\n note, callback is responsible for scenegraph traversal so\r\n they must return true to traverse.\r\n </p>\r\n <p>\r\n Here a dummy CullCallback example\r\n </p>\r\n @example\r\n var DummyCullCallback = function() {};\r\n DummyCullCallback.prototype = {\r\n cull: function(node, nodeVisitor) {\r\n return true;\r\n }\r\n };\r\n\r\n @param Oject callback\r\n */\r\n setCullCallback: function(cb) {\r\n this._cullCallback = cb;\r\n },\r\n getCullCallback: function() {\r\n return this._cullCallback;\r\n },\r\n\r\n hasChild: function(child) {\r\n for (var i = 0, l = this.children.length; i < l; i++) {\r\n if (this.children[i] === child) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n\r\n addChild: function(child) {\r\n if (this.children.indexOf(child) !== -1) return undefined;\r\n\r\n this.children.push(child);\r\n child.addParent(this);\r\n this.dirtyBound();\r\n\r\n // could now require app traversal thanks to the new subgraph,\r\n // so need to check and update if required.\r\n if (\r\n child.getNumChildrenRequiringUpdateTraversal() > 0 ||\r\n child.getUpdateCallbackList().length\r\n ) {\r\n this.setNumChildrenRequiringUpdateTraversal(\r\n this.getNumChildrenRequiringUpdateTraversal() + 1\r\n );\r\n }\r\n\r\n // We need to check if culling is active in the child\r\n if (\r\n child.getNumChildrenWithCullingDisabled() > 0 ||\r\n child.getCullingActive() === false\r\n ) {\r\n this.setNumChildrenWithCullingDisabled(\r\n this.getNumChildrenWithCullingDisabled() + 1\r\n );\r\n }\r\n\r\n return child;\r\n },\r\n\r\n getChildren: function() {\r\n return this.children;\r\n },\r\n getNumChildren: function() {\r\n return this.children.length;\r\n },\r\n getChild: function(num) {\r\n return this.children[num];\r\n },\r\n getParents: function() {\r\n\r\n return this._parents;\r\n },\r\n\r\n addParent: function(parent) {\r\n this._parents.push(parent);\r\n },\r\n\r\n removeParents: function() {\r\n this._parents = []\r\n },\r\n\r\n removeParent: function(parent) {\r\n var idx = this._parents.indexOf(parent);\r\n if (idx === -1) return;\r\n this._parents.splice(idx, 1);\r\n },\r\n\r\n removeChildren: function() {\r\n var children = this.children;\r\n var nbChildren = children.length;\r\n if (!nbChildren) return;\r\n\r\n var updateCallbackRemoved = 0;\r\n\r\n for (var i = 0; i < nbChildren; i++) {\r\n var child = children[i];\r\n child.removeParent(this);\r\n if (\r\n child.getNumChildrenRequiringUpdateTraversal() > 0 ||\r\n child.getUpdateCallbackList().length\r\n )\r\n ++updateCallbackRemoved;\r\n }\r\n\r\n children.length = 0;\r\n if (updateCallbackRemoved)\r\n this.setNumChildrenRequiringUpdateTraversal(\r\n this.getNumChildrenRequiringUpdateTraversal() - updateCallbackRemoved\r\n );\r\n\r\n this.dirtyBound();\r\n },\r\n\r\n // preserve order\r\n removeChild: function(child) {\r\n var children = this.children;\r\n var id = children.indexOf(child);\r\n if (id === -1) return;\r\n\r\n child.removeParent(this);\r\n children.splice(id, 1);\r\n this.dirtyBound();\r\n\r\n if (\r\n child.getNumChildrenRequiringUpdateTraversal() > 0 ||\r\n child.getUpdateCallbackList().length\r\n )\r\n this.setNumChildrenRequiringUpdateTraversal(\r\n this.getNumChildrenRequiringUpdateTraversal() - 1\r\n );\r\n },\r\n\r\n traverse: function(visitor) {\r\n var children = this.children;\r\n for (var i = 0, l = children.length; i < l; i++) {\r\n var child = children[i];\r\n child.accept(visitor);\r\n }\r\n },\r\n\r\n ascend: function(visitor) {\r\n var parents = this._parents;\r\n for (var i = 0, l = parents.length; i < l; i++) {\r\n var parent = parents[i];\r\n parent.accept(visitor);\r\n }\r\n },\r\n\r\n getBoundingBox: function() {\r\n if (!this._boundingBoxComputed) {\r\n this.computeBoundingBox(this._boundingBox);\r\n this._boundingBoxComputed = true;\r\n }\r\n return this._boundingBox;\r\n },\r\n\r\n computeBoundingBox: function(bbox) {\r\n // circular dependency... not sure if the global visitor instance should be instancied here\r\n var ComputeBoundsVisitor = require('./ComputeBoundsVisitor').default;\r\n var cbv = (ComputeBoundsVisitor.instance =\r\n ComputeBoundsVisitor.instance || new ComputeBoundsVisitor());\r\n cbv.setNodeMaskOverride(~0x0); // traverse everything to be consistent with computeBoundingSphere\r\n cbv.reset();\r\n\r\n cbv.apply(this);\r\n bbox.copy(cbv.getBoundingBox());\r\n return bbox;\r\n },\r\n\r\n getBoundingSphere: function() {\r\n return this.getBound();\r\n },\r\n\r\n getBound: function() {\r\n if (!this._boundingSphereComputed) {\r\n this.computeBoundingSphere(this._boundingSphere);\r\n this._boundingSphereComputed = true;\r\n }\r\n return this._boundingSphere;\r\n },\r\n\r\n computeBoundingSphere: function(bSphere) {\r\n var children = this.children;\r\n var l = children.length;\r\n\r\n bSphere.init();\r\n if (l === 0) return bSphere;\r\n\r\n var cc, i;\r\n var bb = this._tmpBox;\r\n bb.init();\r\n for (i = 0; i < l; i++) {\r\n cc = children[i];\r\n if (cc.referenceFrame !== TransformEnums.ABSOLUTE_RF) {\r\n bb.expandByBoundingSphere(cc.getBound());\r\n }\r\n }\r\n if (!bb.valid()) return bSphere;\r\n\r\n bSphere.set(bb.center(bSphere.center()), 0.0);\r\n for (i = 0; i < l; i++) {\r\n cc = children[i];\r\n if (cc.referenceFrame !== TransformEnums.ABSOLUTE_RF) {\r\n bSphere.expandRadiusBySphere(cc.getBound());\r\n }\r\n }\r\n return bSphere;\r\n },\r\n\r\n // matrixCreate allow user handling of garbage collection of matrices\r\n getWorldMatrices: (function() {\r\n var CollectParentPaths = function() {\r\n this.nodePaths = [];\r\n this.halt = undefined;\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_PARENTS);\r\n };\r\n CollectParentPaths.prototype = utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function() {\r\n this.nodePath.length = 0;\r\n this.nodePaths.length = 0;\r\n },\r\n apply: function(node) {\r\n if (\r\n node._parents.length === 0 ||\r\n node === this.halt ||\r\n node.referenceFrame === TransformEnums.ABSOLUTE_RF\r\n ) {\r\n // copy\r\n this.nodePaths.push(this.nodePath.slice(0));\r\n } else {\r\n this.traverse(node);\r\n }\r\n }\r\n });\r\n var collected = new CollectParentPaths();\r\n collected.setNodeMaskOverride(~0x0); // traverse everything\r\n\r\n return function computeLocalToWorldList(halt, matrixCreate) {\r\n collected.reset();\r\n collected.halt = halt;\r\n\r\n this.accept(collected);\r\n var matrixList = [];\r\n\r\n var matrixGenerator = matrixCreate || mat4.create;\r\n for (var i = 0, l = collected.nodePaths.length; i < l; i++) {\r\n var np = collected.nodePaths[i];\r\n var m = matrixGenerator();\r\n if (np.length !== 0) {\r\n ComputeMatrixFromNodePath.computeLocalToWorld(np, true, m);\r\n }\r\n matrixList.push(m);\r\n }\r\n\r\n return matrixList;\r\n };\r\n })(),\r\n\r\n // same as getWorldMatrices GC: Perf WIN\r\n getWorldMatrix: function(halt, matrix) {\r\n // pass allocator on master\r\n var matrixList = this.getWorldMatrices(halt, nodeGetMat);\r\n\r\n if (matrixList.length === 0) {\r\n mat4.identity(matrix);\r\n } else {\r\n mat4.copy(matrix, matrixList[0]);\r\n }\r\n\r\n pooledMatrix.reset();\r\n return matrix;\r\n },\r\n\r\n setCullingActive: function(value) {\r\n if (this._cullingActive === value) return;\r\n if (this._numChildrenWithCullingDisabled === 0 && this._parents.length > 0) {\r\n var delta = 0;\r\n if (!this._cullingActive) --delta;\r\n if (!value) ++delta;\r\n if (delta !== 0) {\r\n for (var i = 0, k = this._parents.length; i < k; i++) {\r\n this._parents[i].setNumChildrenWithCullingDisabled(\r\n this._parents[i].getNumChildrenWithCullingDisabled() + delta\r\n );\r\n }\r\n }\r\n }\r\n this._cullingActive = value;\r\n },\r\n\r\n getCullingActive: function() {\r\n return this._cullingActive;\r\n },\r\n\r\n isCullingActive: function() {\r\n return (\r\n this._numChildrenWithCullingDisabled === 0 &&\r\n this._cullingActive &&\r\n this.getBound().valid()\r\n );\r\n },\r\n\r\n setNumChildrenWithCullingDisabled: function(num) {\r\n if (this._numChildrenWithCullingDisabled === num) return;\r\n if (this._cullingActive && this._parents.length > 0) {\r\n var delta = 0;\r\n if (this._numChildrenWithCullingDisabled > 0) --delta;\r\n if (num > 0) ++delta;\r\n if (delta !== 0) {\r\n for (var i = 0, k = this._parents.length; i < k; i++) {\r\n this._parents[i].setNumChildrenWithCullingDisabled(\r\n this._parents[i].getNumChildrenWithCullingDisabled() + delta\r\n );\r\n }\r\n }\r\n }\r\n this._numChildrenWithCullingDisabled = num;\r\n },\r\n\r\n getNumChildrenWithCullingDisabled: function() {\r\n return this._numChildrenWithCullingDisabled;\r\n },\r\n\r\n releaseGLObjects: function() {\r\n if (this.stateset !== undefined) this.stateset.releaseGLObjects();\r\n }\r\n }),\r\n 'osg',\r\n 'Node'\r\n);\r\n\r\nexport default Node;","import utils from './utils';\r\nimport Node from './Node';\r\nimport TransformEnums from './transformEnums';\r\nimport { vec3 } from './glMatrix';\r\n\r\n/**\r\n * LightSource is a positioned node to use with StateAttribute Light\r\n * @class LightSource\r\n */\r\nvar LightSource = function() {\r\n Node.call(this);\r\n this.setCullingActive(false);\r\n this._light = undefined;\r\n this._referenceFrame = TransformEnums.RELATIVE_RF;\r\n};\r\n\r\n/** @lends LightSource.prototype */\r\nutils.createPrototypeNode(\r\n LightSource,\r\n utils.objectInherit(Node.prototype, {\r\n getLight: function() {\r\n return this._light;\r\n },\r\n setLight: function(light) {\r\n this._light = light;\r\n },\r\n setReferenceFrame: function(value) {\r\n this._referenceFrame = value;\r\n },\r\n getReferenceFrame: function() {\r\n return this._referenceFrame;\r\n },\r\n computeBoundingSphere: (function() {\r\n var tmp = vec3.create();\r\n\r\n return function(bsphere) {\r\n Node.prototype.computeBoundingSphere.call(this, bsphere);\r\n\r\n if (\r\n this._light !== undefined &&\r\n this._referenceFrame === TransformEnums.RELATIVE_RF\r\n ) {\r\n var position = this._light.getPosition();\r\n\r\n if (position[3] !== 0.0) {\r\n bsphere.expandByVec3(vec3.scale(tmp, position, 1.0 / position[3]));\r\n }\r\n }\r\n\r\n return bsphere;\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'LightSource'\r\n);\r\n\r\nexport default LightSource;","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport Geometry from '../osg/Geometry';\r\nimport RigGeometry from '../osgAnimation/RigGeometry';\r\nimport Uniform from '../osg/Uniform';\r\nimport StateSet from '../osg/StateSet';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport ShaderGenerator from '../osgShader/ShaderGenerator';\r\nimport Compiler from '../osgShader/Compiler';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport Depth from '../osg/Depth';\r\n\r\n////////////////////////\r\n// COMPILER DEBUG GEOMETRY\r\n////////////////////////\r\nvar CompilerColorGeometry = function() {\r\n Compiler.apply(this, arguments);\r\n};\r\n\r\nvar configColor = Compiler.cloneStateAttributeConfig(Compiler);\r\nconfigColor.textureAttribute = [];\r\nconfigColor.attribute = ['PointSize', 'Morph', 'Skinning'];\r\n\r\nCompiler.setStateAttributeConfig(CompilerColorGeometry, configColor);\r\n\r\nutils.createPrototypeObject(\r\n CompilerColorGeometry,\r\n utils.objectInherit(Compiler.prototype, {\r\n getCompilerName: function() {\r\n return 'CompilerDebugGeometry';\r\n },\r\n initTextureAttributes: function() {},\r\n createFragmentShaderGraph: function() {\r\n var frag = this.getNode('glFragColor');\r\n\r\n this.getNode('SetAlpha')\r\n .inputs({\r\n color: this.getOrCreateUniform('vec3', 'uColorDebug'),\r\n alpha: this.createVariable('float').setValue('1.0')\r\n })\r\n .outputs({\r\n result: frag\r\n });\r\n\r\n return [frag];\r\n }\r\n }),\r\n 'osgUtil',\r\n 'CompilerColorGeometry'\r\n);\r\n\r\nvar ShaderGeneratorCompilerColorGeometry = function() {\r\n ShaderGenerator.apply(this, arguments);\r\n this.setShaderCompiler(CompilerColorGeometry);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ShaderGeneratorCompilerColorGeometry,\r\n utils.objectInherit(ShaderGenerator.prototype, {}),\r\n 'osgUtil',\r\n 'ShaderGeneratorCompilerColorGeometry'\r\n);\r\n\r\n////////////////////////\r\n// COMPILER SKINNING DEBUG\r\n////////////////////////\r\nvar CompilerColorSkinning = function() {\r\n Compiler.apply(this, arguments);\r\n};\r\n\r\nvar configSkinning = Compiler.cloneStateAttributeConfig(Compiler);\r\nconfigSkinning.textureAttribute = [];\r\n\r\nCompiler.setStateAttributeConfig(CompilerColorSkinning, configSkinning);\r\n\r\nutils.createPrototypeObject(\r\n CompilerColorSkinning,\r\n utils.objectInherit(Compiler.prototype, {\r\n getCompilerName: function() {\r\n return 'CompilerDebugSkinning';\r\n },\r\n initTextureAttributes: function() {},\r\n createFragmentShaderGraph: function() {\r\n var frag = this.getNode('glFragColor');\r\n\r\n this.getNode('SetAlpha')\r\n .inputs({\r\n color: this.getOrCreateVarying('vec3', 'vBonesColor'),\r\n alpha: this.createVariable('float').setValue('1.0')\r\n })\r\n .outputs({\r\n result: frag\r\n });\r\n\r\n return [frag];\r\n },\r\n declareVertexVaryings: function(roots) {\r\n var color = this.getOrCreateVarying('vec3', 'vBonesColor');\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateAttribute('vec3', 'BonesColor'))\r\n .outputs(color);\r\n return Compiler.prototype.declareVertexVaryings.call(this, roots);\r\n }\r\n }),\r\n 'osgUtil',\r\n 'CompilerColorSkinning'\r\n);\r\n\r\nvar ShaderGeneratorCompilerColorSkinning = function() {\r\n ShaderGenerator.apply(this, arguments);\r\n this.setShaderCompiler(CompilerColorSkinning);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ShaderGeneratorCompilerColorSkinning,\r\n utils.objectInherit(ShaderGenerator.prototype, {}),\r\n 'osgUtil',\r\n 'ShaderGeneratorCompilerColorSkinning'\r\n);\r\n\r\n///////////////////////////\r\n// DISPLAY GEOMETRY VISITOR\r\n///////////////////////////\r\n\r\nvar GeometryColorDebugVisitor = function() {\r\n NodeVisitor.call(this);\r\n this._debugColor = true;\r\n this._debugSkinning = false;\r\n\r\n this._stCenter = new StateSet(); // state set of center crosses\r\n this._stCenter.setShaderGeneratorName('debugGeometry');\r\n};\r\n\r\nGeometryColorDebugVisitor.CompilerColorGeometry = CompilerColorGeometry;\r\nGeometryColorDebugVisitor.ShaderGeneratorCompilerColorGeometry = ShaderGeneratorCompilerColorGeometry;\r\n\r\nGeometryColorDebugVisitor.CompilerSkinningGeometry = CompilerColorSkinning;\r\nGeometryColorDebugVisitor.ShaderGeneratorCompilerColorSkinning = ShaderGeneratorCompilerColorSkinning;\r\n\r\nutils.createPrototypeObject(\r\n GeometryColorDebugVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n setGeometryDebug: function(node) {\r\n this._stCenter.setAttributeAndModes(new Depth(Depth.ALWAYS));\r\n this._debugColor = true;\r\n this._debugSkinning = false;\r\n this.apply(node);\r\n },\r\n\r\n setSkinningDebug: function(node) {\r\n this._stCenter.setAttributeAndModes(new Depth(Depth.NEVER));\r\n this._debugColor = false;\r\n this._debugSkinning = true;\r\n this.apply(node);\r\n },\r\n\r\n disableDebug: function(node) {\r\n this._stCenter.setAttributeAndModes(new Depth(Depth.NEVER));\r\n this._debugColor = false;\r\n this._debugSkinning = false;\r\n this.apply(node);\r\n },\r\n\r\n _debugCenterGeometry: function(node, color) {\r\n // draw cross with slightly different color than the geometry\r\n var bb = node.getBound();\r\n\r\n var verts = new Float32Array(18);\r\n var off = bb.radius() * 0.1;\r\n verts[0] = off;\r\n verts[3] = -off;\r\n\r\n verts[7] = off;\r\n verts[10] = -off;\r\n\r\n verts[14] = off;\r\n verts[17] = -off;\r\n\r\n var geo = new Geometry();\r\n geo.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, verts, 3);\r\n var primitive = new DrawArrays(primitiveSet.LINES, 0, 6);\r\n geo.getPrimitives().push(primitive);\r\n\r\n var mt = new MatrixTransform();\r\n var center = bb.center();\r\n mt.getMatrix()[12] = center[0];\r\n mt.getMatrix()[13] = center[1];\r\n mt.getMatrix()[14] = center[2];\r\n\r\n mt.addChild(geo);\r\n this.nodePath[this.nodePath.length - 2].addChild(mt);\r\n color = vec3.fromValues(color[0] * 0.8, color[1] * 0.8, color[2] * 0.8);\r\n geo.getOrCreateStateSet().addUniform(Uniform.createFloat3(color, 'uColorDebug'));\r\n mt.setStateSet(this._stCenter);\r\n\r\n mt._isCenterDebug = true;\r\n },\r\n\r\n _debugRigGeometry: function(node) {\r\n // a bone can be shared between several rigs so we use the instanceID to get unique color\r\n var vList = node.getVertexAttributeList();\r\n if (vList.BonesColor) return;\r\n\r\n var eltBones = vList.Bones.getElements();\r\n var eltWeights = vList.Weights.getElements();\r\n\r\n var bones = node._rigTransformImplementation._bones;\r\n var nbBones = eltBones.length / 4;\r\n\r\n var bonesColor = new Float32Array(nbBones * 3);\r\n\r\n for (var i = 0; i < nbBones; ++i) {\r\n var idb = i * 4;\r\n var c0 = bones[eltBones[idb]].getOrCreateDebugColor();\r\n var c1 = bones[eltBones[idb + 1]].getOrCreateDebugColor();\r\n var c2 = bones[eltBones[idb + 2]].getOrCreateDebugColor();\r\n var c3 = bones[eltBones[idb + 3]].getOrCreateDebugColor();\r\n\r\n var w0 = eltWeights[idb];\r\n var w1 = eltWeights[idb + 1];\r\n var w2 = eltWeights[idb + 2];\r\n var w3 = eltWeights[idb + 3];\r\n\r\n var idc = i * 3;\r\n bonesColor[idc] = w0 * c0[0] + w1 * c1[0] + w2 * c2[0] + w3 * c3[0];\r\n bonesColor[idc + 1] = w0 * c0[1] + w1 * c1[1] + w2 * c2[1] + w3 * c3[1];\r\n bonesColor[idc + 2] = w0 * c0[2] + w1 * c1[2] + w2 * c2[2] + w3 * c3[2];\r\n }\r\n\r\n vList.BonesColor = new BufferArray(BufferArray.ARRAY_BUFFER, bonesColor, 3);\r\n },\r\n\r\n _debugGeometry: function(node) {\r\n var debugColor = this._debugColor;\r\n var debugSkinning = this._debugSkinning && node instanceof RigGeometry;\r\n\r\n if (!debugColor && !debugSkinning) {\r\n if (node._originalStateSet !== undefined) {\r\n node.setStateSet(node._originalStateSet || undefined);\r\n }\r\n return;\r\n }\r\n\r\n if (node._originalStateSet === undefined) {\r\n node._originalStateSet = node.getStateSet() || null;\r\n }\r\n\r\n var stateSet = new StateSet();\r\n node.setStateSet(stateSet);\r\n\r\n if (debugSkinning) {\r\n stateSet.setShaderGeneratorName('debugSkinning');\r\n this._debugRigGeometry(node);\r\n return;\r\n }\r\n\r\n // debug color\r\n var color = vec3.fromValues(Math.random(), Math.random(), Math.random());\r\n stateSet.addUniform(Uniform.createFloat3(color, 'uColorDebug'));\r\n stateSet.setShaderGeneratorName('debugGeometry');\r\n\r\n this._debugCenterGeometry(node, color);\r\n },\r\n\r\n apply: function(node) {\r\n if (node._isNormalDebug || node._isCenterDebug) return;\r\n\r\n if (node instanceof Geometry) {\r\n this._debugGeometry(node);\r\n }\r\n\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgUtil',\r\n 'GeometryColorDebugVisitor'\r\n);\r\n\r\nexport default GeometryColorDebugVisitor;","import utils from './utils';\r\nimport Transform from './Transform';\r\nimport CullSettings from './CullSettings';\r\nimport { mat4 } from './glMatrix';\r\nimport Texture from './Texture';\r\nimport TransformEnums from './transformEnums';\r\nimport { vec4 } from './glMatrix';\r\n\r\n/**\r\n * Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.\r\n * @class Camera\r\n * @inherits Transform CullSettings\r\n */\r\nvar Camera = function() {\r\n Transform.call(this);\r\n CullSettings.call(this);\r\n\r\n this.viewport = undefined;\r\n this._graphicContext = undefined;\r\n this._scissor = undefined;\r\n this.setClearColor(vec4.fromValues(0, 0, 0, 1.0));\r\n this.setClearDepth(1.0);\r\n\r\n /*jshint bitwise: false */\r\n this.setClearMask(Camera.COLOR_BUFFER_BIT | Camera.DEPTH_BUFFER_BIT);\r\n /*jshint bitwise: true */\r\n\r\n this.setViewMatrix(mat4.create());\r\n this.setProjectionMatrix(mat4.create());\r\n this.renderOrder = Camera.NESTED_RENDER;\r\n this.renderOrderNum = 0;\r\n\r\n this._view = undefined;\r\n this._renderer = undefined;\r\n this._attachments = {};\r\n};\r\n\r\nCamera.PRE_RENDER = 0;\r\nCamera.NESTED_RENDER = 1;\r\nCamera.POST_RENDER = 2;\r\n\r\nCamera.COLOR_BUFFER_BIT = 0x00004000;\r\nCamera.DEPTH_BUFFER_BIT = 0x00000100;\r\nCamera.STENCIL_BUFFER_BIT = 0x00000400;\r\n\r\n/** @lends Camera.prototype */\r\nutils.createPrototypeNode(\r\n Camera,\r\n utils.objectInherit(\r\n CullSettings.prototype,\r\n utils.objectInherit(Transform.prototype, {\r\n // at which view this camera is attached\r\n getView: function() {\r\n return this._view;\r\n },\r\n\r\n setView: function(view) {\r\n this._view = view;\r\n },\r\n\r\n getRenderer: function() {\r\n return this._renderer;\r\n },\r\n\r\n setRenderer: function(renderer) {\r\n this._renderer = renderer;\r\n },\r\n\r\n // Set the final draw callback for custom operations\r\n // to be done after the drawing of\r\n // the camera's subgraph and pre render stages.\r\n setFinalDrawCallback: function(cb) {\r\n this._finalDrawCallback = cb;\r\n },\r\n\r\n getFinalDrawCallback: function() {\r\n return this._finalDrawCallback;\r\n },\r\n\r\n // Set the initial draw callback for custom operations\r\n // to be done before the drawing of\r\n // the camera's subgraph and pre render stages.\r\n setInitialDrawCallback: function(cb) {\r\n this._initialDrawCallback = cb;\r\n },\r\n\r\n getInitialDrawCallback: function() {\r\n return this._initialDrawCallback;\r\n },\r\n\r\n getAttachments: function() {\r\n return this._attachments;\r\n },\r\n\r\n setGraphicContext: function(gc) {\r\n this._graphicContext = gc;\r\n },\r\n getGraphicContext: function() {\r\n return this._graphicContext;\r\n },\r\n setClearDepth: function(depth) {\r\n this.clearDepth = depth;\r\n },\r\n getClearDepth: function() {\r\n return this.clearDepth;\r\n },\r\n\r\n setClearMask: function(mask) {\r\n this.clearMask = mask;\r\n },\r\n getClearMask: function() {\r\n return this.clearMask;\r\n },\r\n\r\n setClearColor: function(color) {\r\n this.clearColor = color;\r\n },\r\n getClearColor: function() {\r\n return this.clearColor;\r\n },\r\n\r\n setViewport: function(vp) {\r\n this.viewport = vp;\r\n this.getOrCreateStateSet().setAttributeAndModes(vp);\r\n },\r\n getViewport: function() {\r\n return this.viewport;\r\n },\r\n\r\n setScissor: function(scissor) {\r\n this._scissor = scissor;\r\n this.getOrCreateStateSet().setAttributeAndModes(this._scissor);\r\n },\r\n getScissor: function() {\r\n return this._scissor;\r\n },\r\n\r\n setViewMatrix: function(matrix) {\r\n this.modelviewMatrix = matrix;\r\n },\r\n setViewMatrixAsLookAt: function(eye, center, up) {\r\n mat4.lookAt(this.getViewMatrix(), eye, center, up);\r\n },\r\n setProjectionMatrix: function(matrix) {\r\n this.projectionMatrix = matrix;\r\n },\r\n\r\n /** Set to an orthographic projection. See OpenGL glOrtho for documentation further details.*/\r\n setProjectionMatrixAsOrtho: function(left, right, bottom, top, zNear, zFar) {\r\n mat4.ortho(this.getProjectionMatrix(), left, right, bottom, top, zNear, zFar);\r\n },\r\n isRenderToTextureCamera: function() {\r\n return window.Object.keys(this._attachments).length > 0;\r\n },\r\n\r\n getViewMatrix: function() {\r\n return this.modelviewMatrix;\r\n },\r\n getProjectionMatrix: function() {\r\n return this.projectionMatrix;\r\n },\r\n getRenderOrder: function() {\r\n return this.renderOrder;\r\n },\r\n setRenderOrder: function(order, orderNum) {\r\n this.renderOrder = order;\r\n this.renderOrderNum = orderNum;\r\n },\r\n getFrameBufferObject: function() {\r\n return this.frameBufferObject;\r\n },\r\n setFrameBufferObject: function(fbo) {\r\n this.frameBufferObject = fbo;\r\n },\r\n detachAll: function() {\r\n this._attachments = {};\r\n\r\n if (this.frameBufferObject) {\r\n this.frameBufferObject.dirty();\r\n }\r\n },\r\n\r\n // TODO: fix in case of shared fbo\r\n // TODO: fix adding a resize case\r\n resetAttachments: function() {\r\n if (this.frameBufferObject) {\r\n this.frameBufferObject.reset();\r\n // remove framebuffer\r\n this.frameBufferObject = 0;\r\n }\r\n\r\n // removes camera attachement\r\n this._attachments = {};\r\n },\r\n\r\n attachTexture: function(bufferComponent, texture, textureTarget) {\r\n if (this.frameBufferObject) {\r\n this.frameBufferObject.dirty();\r\n }\r\n\r\n // because before the argument was level and the spec says\r\n // it must always be 0 ! is valid for 0 or undefined\r\n if (!textureTarget) {\r\n textureTarget = Texture.TEXTURE_2D;\r\n }\r\n\r\n this._attachments[bufferComponent] = {\r\n attachment: bufferComponent,\r\n texture: texture,\r\n textureTarget: textureTarget\r\n };\r\n },\r\n\r\n attachRenderBuffer: function(bufferComponent, internalFormat) {\r\n if (this.frameBufferObject) {\r\n this.frameBufferObject.dirty();\r\n }\r\n this._attachments[bufferComponent] = {\r\n format: internalFormat,\r\n attachment: bufferComponent\r\n };\r\n },\r\n\r\n computeLocalToWorldMatrix: function(matrix /*,nodeVisitor*/ ) {\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.mul(matrix, matrix, this.modelviewMatrix);\r\n } else {\r\n // absolute\r\n mat4.copy(matrix, this.modelviewMatrix);\r\n }\r\n return true;\r\n },\r\n\r\n computeWorldToLocalMatrix: (function() {\r\n var minverse = mat4.create();\r\n return function(matrix /*, nodeVisitor */ ) {\r\n mat4.invert(minverse, this.modelviewMatrix);\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.mul(matrix, minverse, matrix);\r\n } else {\r\n mat4.copy(matrix, minverse);\r\n }\r\n return true;\r\n };\r\n })()\r\n })\r\n ),\r\n 'osg',\r\n 'Camera'\r\n);\r\n\r\nexport default Camera;","export default {\r\n ArrayType: Float64Array\r\n};\r\n","import mth from './math'\r\nimport * as glm from 'gl-matrix'\r\nimport config from '../config.js'\r\n\r\nglm.glMatrix.setMatrixArrayType(config.ArrayType)\r\n//todo fixme 不能设置只读属性\r\nglm.glMatrix.EPSILON = 1e-9\r\n\r\nvar vec2 = glm.vec2\r\nvar vec3 = glm.vec3\r\nvar vec4 = glm.vec4\r\nvar mat4 = glm.mat4\r\nvar mat3 = glm.mat3\r\nvar quat = glm.quat\r\n\r\n// osg vec3 additions\r\n\r\nvec3.create32 = function () {\r\n return new Float32Array(3)\r\n}\r\n\r\nvec3.create64 = function () {\r\n return new Float64Array(3)\r\n}\r\n\r\nvec3.fromValues32 = function (a, b, c) {\r\n var out = new Float32Array(3)\r\n out[0] = a\r\n out[1] = b\r\n out[2] = c\r\n return out\r\n}\r\n\r\nvec3.fromValues64 = function (a, b, c) {\r\n var out = new Float64Array(3)\r\n out[0] = a\r\n out[1] = b\r\n out[2] = c\r\n return out\r\n}\r\n\r\nvec3.init = function (out) {\r\n return vec3.set(out, 0.0, 0.0, 0.0)\r\n}\r\n\r\nvec3.transformMat4Rotate = function (out, v, m) {\r\n var x = v[0],\r\n y = v[1],\r\n z = v[2]\r\n out[0] = m[0] * x + m[1] * y + m[2] * z\r\n out[1] = m[4] * x + m[5] * y + m[6] * z\r\n out[2] = m[8] * x + m[9] * y + m[10] * z\r\n return out\r\n}\r\n\r\nvec3.valid = function (a) {\r\n if (mth.isNaN(a[0])) return false\r\n if (mth.isNaN(a[1])) return false\r\n if (mth.isNaN(a[2])) return false\r\n return true\r\n}\r\nvec3.neg = vec3.negate\r\nvec3.ZERO = vec3.create()\r\nvec3.ONE = vec3.fromValues(1.0, 1.0, 1.0)\r\nvec3.INFINITY = vec3.fromValues(Infinity, Infinity, Infinity)\r\nvec3.NEGATIVE_INFINITY = vec3.fromValues(-Infinity, -Infinity, -Infinity)\r\n\r\n// osg vec2 additions\r\n\r\nvec2.create32 = function () {\r\n return new Float32Array(2)\r\n}\r\n\r\nvec2.create64 = function () {\r\n return new Float64Array(2)\r\n}\r\n\r\nvec2.fromValues32 = function (a, b) {\r\n var out = new Float32Array(2)\r\n out[0] = a\r\n out[1] = b\r\n return out\r\n}\r\n\r\nvec2.fromValues64 = function (a, b) {\r\n var out = new Float64Array(2)\r\n out[0] = a\r\n out[1] = b\r\n return out\r\n}\r\n\r\nvec2.init = function (out) {\r\n return vec2.set(out, 0.0, 0.0)\r\n}\r\n\r\nvec2.valid = function (a) {\r\n if (mth.isNaN(a[0])) return false\r\n if (mth.isNaN(a[1])) return false\r\n return true\r\n}\r\n\r\nvec2.abs = function(out, a) {\r\n out[0] = Math.abs(a[0])\r\n out[1] = Math.abs(a[1]) \r\n return out\r\n}\r\n\r\nvec2.ZERO = vec2.create()\r\nvec2.ONE = vec2.fromValues(1.0, 1.0)\r\nvec2.INFINITY = vec2.fromValues(Infinity, Infinity)\r\nvec2.NEGATIVE_INFINITY = vec2.fromValues(-Infinity, -Infinity)\r\n\r\n// osg vec4 additions\r\n\r\nvec4.create32 = function () {\r\n return new Float32Array(4)\r\n}\r\n\r\nvec4.create64 = function () {\r\n return new Float64Array(4)\r\n}\r\n\r\nvec4.fromValues32 = function (a, b, c, d) {\r\n var out = new Float32Array(4)\r\n out[0] = a\r\n out[1] = b\r\n out[2] = c\r\n out[3] = d\r\n return out\r\n}\r\n\r\nvec4.fromValues64 = function (a, b, c, d) {\r\n var out = new Float64Array(4)\r\n out[0] = a\r\n out[1] = b\r\n out[2] = c\r\n out[3] = d\r\n return out\r\n}\r\n\r\nvec4.init = function (out) {\r\n return vec4.set(out, 0.0, 0.0, 0.0, 0.0)\r\n}\r\n\r\nvec4.valid = function (a) {\r\n if (mth.isNaN(a[0])) return false\r\n if (mth.isNaN(a[1])) return false\r\n if (mth.isNaN(a[2])) return false\r\n if (mth.isNaN(a[3])) return false\r\n return true\r\n}\r\nvec4.neg = vec4.negate\r\nvec4.ZERO = vec4.create()\r\nvec4.ONE = vec4.fromValues(1.0, 1.0, 1.0, 1.0)\r\nvec4.INFINITY = vec4.fromValues(Infinity, Infinity, Infinity, Infinity)\r\nvec4.NEGATIVE_INFINITY = vec4.fromValues(-Infinity, -Infinity, -Infinity, -Infinity)\r\n\r\n// quat\r\n\r\nquat.IDENTITY = quat.create()\r\n\r\nquat.zeroRotation = function (q) {\r\n return q[0] === 0.0 && q[1] === 0.0 && q[2] === 0.0 && q[3] === 1.0\r\n}\r\n\r\nquat.create32 = function () {\r\n var out = new Float32Array(4)\r\n out[3] = 1.0\r\n return out\r\n}\r\n\r\nquat.create64 = function () {\r\n var out = new Float64Array(4)\r\n out[3] = 1.0\r\n return out\r\n}\r\n\r\nquat.fromEuler = function (out, x, y, z) {\r\n let halfToRad = (0.5 * Math.PI) / 180.0\r\n x *= halfToRad\r\n y *= halfToRad\r\n z *= halfToRad\r\n let sx = Math.sin(x)\r\n let cx = Math.cos(x)\r\n let sy = Math.sin(y)\r\n let cy = Math.cos(y)\r\n let sz = Math.sin(z)\r\n let cz = Math.cos(z)\r\n out[0] = sx * cy * cz - cx * sy * sz\r\n out[1] = cx * sy * cz + sx * cy * sz\r\n out[2] = cx * cy * sz - sx * sy * cz\r\n out[3] = cx * cy * cz + sx * sy * sz\r\n return out\r\n}\r\n\r\n/**\r\n * Returns an euler angle representation of a quaternion\r\n * @param {vec3} out Euler angles, pitch-yaw-roll\r\n * @param {quat} mat Quaternion\r\n * @return {vec3} out\r\n */\r\nquat.getEulerDeprecated = function (out, quat) {\r\n let x = quat[0],\r\n y = quat[1],\r\n z = quat[2],\r\n w = quat[3],\r\n x2 = x * x,\r\n y2 = y * y,\r\n z2 = z * z,\r\n w2 = w * w\r\n let unit = x2 + y2 + z2 + w2\r\n let test = x * w - y * z\r\n if (test > 0.499995 * unit) {\r\n //TODO: Use glmatrix.EPSILON\r\n // singularity at the north pole\r\n out[0] = Math.PI / 2\r\n out[1] = 2 * Math.atan2(y, x)\r\n out[2] = 0\r\n } else if (test < -0.499995 * unit) {\r\n //TODO: Use glmatrix.EPSILON\r\n // singularity at the south pole\r\n out[0] = -Math.PI / 2\r\n out[1] = 2 * Math.atan2(y, x)\r\n out[2] = 0\r\n } else {\r\n out[0] = Math.asin(2 * (x * z - w * y))\r\n out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2))\r\n out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2))\r\n }\r\n // TODO: Return them as degrees and not as radians\r\n //out[0] *= 180./Math.PI;\r\n //out[1] *= 180./Math.PI;\r\n //out[2] *= 180./Math.PI;\r\n return out\r\n}\r\n\r\nquat.getEuler = function (out, quat) {\r\n let x, y, z\r\n\r\n const qx = quat[0]\r\n const qy = quat[1]\r\n const qz = quat[2]\r\n const qw = quat[3]\r\n\r\n const a2 = 2 * (qw * qy - qx * qz)\r\n\r\n if (a2 <= -0.99999) {\r\n x = 2 * Math.atan2(qx, qw)\r\n y = -Math.PI / 2\r\n z = 0\r\n } else if (a2 >= 0.99999) {\r\n x = 2 * Math.atan2(qx, qw)\r\n y = Math.PI / 2\r\n z = 0\r\n } else {\r\n x = Math.atan2(2 * (qw * qx + qy * qz), 1 - 2 * (qx * qx + qy * qy))\r\n y = Math.asin(a2)\r\n z = Math.atan2(2 * (qw * qz + qx * qy), 1 - 2 * (qy * qy + qz * qz))\r\n }\r\n\r\n out[0] = x * 180.0 / Math.PI \r\n out[1] = y * 180.0 / Math.PI\r\n out[2] = z * 180.0 / Math.PI\r\n\r\n return out\r\n}\r\n\r\nquat.fromValues32 = vec4.fromValues32\r\nquat.fromValues64 = vec4.fromValues64\r\nquat.init = quat.identity\r\n\r\n// http://physicsforgames.blogspot.fr/2010/02/quaternions.html\r\n// called quatBlend\r\n//\r\n// NLERP is supposed to be\r\n// - Commutative,\r\n// - NOT Constant velocity\r\n// - Torque minimal\r\n//\r\n// a and be must be normalized\r\n// (otherwise they're not rotation...)\r\n// t must be between 0 and 1\r\nquat.nlerp = function (out, a, b, t) {\r\n var ax = a[0],\r\n ay = a[1],\r\n az = a[2],\r\n aw = a[3],\r\n bx = b[0],\r\n by = b[1],\r\n bz = b[2],\r\n bw = b[3]\r\n var dot = ax * bx + ay * by + az * bz + aw * bw\r\n var at = 1.0 - t\r\n var outx, outy, outz, outw\r\n // shortest path\r\n if (dot < 0.0) {\r\n // negates directly b in the 4 equation\r\n // this.neg( b, r );\r\n outx = ax * at - bx * t\r\n outy = ay * at - by * t\r\n outz = az * at - bz * t\r\n outw = aw * at - bw * t\r\n } else {\r\n outx = ax * at + bx * t\r\n outy = ay * at + by * t\r\n outz = az * at + bz * t\r\n outw = aw * at + bw * t\r\n }\r\n\r\n var invLen = 1.0 / Math.sqrt(outx * outx + outy * outy + outz * outz + outw * outw)\r\n out[0] = outx * invLen\r\n out[1] = outy * invLen\r\n out[2] = outz * invLen\r\n out[3] = outw * invLen\r\n return out\r\n}\r\n\r\n// MUST READ on SLERP, NLERP, LOG-LERP\r\n// http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/\r\n// with a slerp implementation (robust)\r\n//\r\n// MUST READ Howto enhance lerp, slerp and q normalize\r\n// http://number-none.com/product/Hacking%20Quaternions/\r\n//\r\n// MUST READ The book:\r\n// Essential Mathematics for Games and Interactive Applications page\r\n// ( from 10.6.1 Linear Interpolation to 10.6.3 Performance Improvements )\r\n//\r\n// SLERP is:\r\n// - NOT commutative\r\n// - constant velocity\r\n// - torque minimal\r\n//\r\n// so not to be used when blending multiple non ordered rotations\r\n// (as in multiple animation)\r\n//\r\n// slerp see glMatrix implementation\r\n\r\n// mat3 additions\r\nmat3.IDENTITY = mat3.create()\r\nmat3.create32 = function () {\r\n var out = new Float32Array(9)\r\n out[0] = out[4] = out[8] = 1.0\r\n return out\r\n}\r\n\r\nmat3.create64 = function () {\r\n var out = new Float64Array(9)\r\n out[0] = out[4] = out[8] = 1.0\r\n return out\r\n}\r\n\r\n// mat4 additions\r\nmat4.IDENTITY = mat4.create()\r\n\r\nmat4.create32 = function () {\r\n var out = new Float32Array(16)\r\n out[0] = out[5] = out[10] = out[15] = 1.0\r\n return out\r\n}\r\n\r\nmat4.create64 = function () {\r\n var out = new Float64Array(16)\r\n out[0] = out[5] = out[10] = out[15] = 1.0\r\n return out\r\n}\r\n\r\nmat4.setTranslation = function (out, a) {\r\n out[12] = a[0]\r\n out[13] = a[1]\r\n out[14] = a[2]\r\n return out\r\n}\r\n\r\nmat4.getFrustum = function (out, matrix) {\r\n var right = 0.0\r\n var left = 0.0\r\n var top = 0.0\r\n var bottom = 0.0\r\n var zNear, zFar\r\n\r\n if (\r\n matrix[0 * 4 + 3] !== 0.0 ||\r\n matrix[1 * 4 + 3] !== 0.0 ||\r\n matrix[2 * 4 + 3] !== -1.0 ||\r\n matrix[3 * 4 + 3] !== 0.0\r\n ) {\r\n return false\r\n }\r\n\r\n // note: near and far must be used inside this method instead of zNear and zFar\r\n // because zNear and zFar are references and they may point to the same variable.\r\n var tempNear = matrix[3 * 4 + 2] / (matrix[2 * 4 + 2] - 1.0)\r\n var tempFar = matrix[3 * 4 + 2] / (1.0 + matrix[2 * 4 + 2])\r\n\r\n left = (tempNear * (matrix[2 * 4] - 1.0)) / matrix[0]\r\n right = (tempNear * (1.0 + matrix[2 * 4])) / matrix[0]\r\n\r\n top = (tempNear * (1.0 + matrix[2 * 4 + 1])) / matrix[1 * 4 + 1]\r\n bottom = (tempNear * (matrix[2 * 4 + 1] - 1.0)) / matrix[1 * 4 + 1]\r\n\r\n zNear = tempNear\r\n zFar = tempFar\r\n\r\n out.left = left\r\n out.right = right\r\n out.top = top\r\n out.bottom = bottom\r\n out.zNear = zNear\r\n out.zFar = zFar\r\n\r\n return true\r\n}\r\n\r\nmat4.getPerspective = (function () {\r\n var c = {\r\n right: 0,\r\n left: 0,\r\n top: 0,\r\n bottom: 0,\r\n zNear: 0,\r\n zFar: 0\r\n }\r\n return function (out, matrix) {\r\n // get frustum and compute results\r\n var r = mat4.getFrustum(c, matrix)\r\n if (r) {\r\n out.fovy =\r\n (180 / Math.PI) * (Math.atan(c.top / c.zNear) - Math.atan(c.bottom / c.zNear))\r\n out.aspectRatio = (c.right - c.left) / (c.top - c.bottom)\r\n }\r\n out.zNear = c.zNear\r\n out.zFar = c.zFar\r\n return out\r\n }\r\n})()\r\n\r\nmat4.getLookAt = (function () {\r\n var inv = mat4.create()\r\n var v1 = vec3.create()\r\n var v2 = vec3.fromValues(0.0, 1.0, 0.0)\r\n var v3 = vec3.fromValues(0.0, 0.0, -1.0)\r\n\r\n return function (eye, center, up, matrix, distance) {\r\n var d = distance !== undefined ? distance : 1.0\r\n mat4.invert(inv, matrix)\r\n mat4.getTranslation(eye, inv)\r\n vec3.transformMat4Rotate(up, v2, matrix)\r\n vec3.transformMat4Rotate(center, v3, matrix)\r\n vec3.normalize(center, center)\r\n vec3.add(center, vec3.scale(v1, center, d), eye)\r\n }\r\n})()\r\n\r\nmat4.getFrustumPlanes = (function () {\r\n var mvp = mat4.create()\r\n\r\n return function (out, projection, view, withNearFar) {\r\n mat4.mul(mvp, projection, view)\r\n\r\n var computeNearFar = !!withNearFar\r\n\r\n // Right clipping plane.\r\n var right = out[0]\r\n right[0] = mvp[3] - mvp[0]\r\n right[1] = mvp[7] - mvp[4]\r\n right[2] = mvp[11] - mvp[8]\r\n right[3] = mvp[15] - mvp[12]\r\n\r\n // Left clipping plane.\r\n var left = out[1]\r\n left[0] = mvp[3] + mvp[0]\r\n left[1] = mvp[7] + mvp[4]\r\n left[2] = mvp[11] + mvp[8]\r\n left[3] = mvp[15] + mvp[12]\r\n\r\n // Bottom clipping plane.\r\n var bottom = out[2]\r\n bottom[0] = mvp[3] + mvp[1]\r\n bottom[1] = mvp[7] + mvp[5]\r\n bottom[2] = mvp[11] + mvp[9]\r\n bottom[3] = mvp[15] + mvp[13]\r\n\r\n // Top clipping plane.\r\n var top = out[3]\r\n top[0] = mvp[3] - mvp[1]\r\n top[1] = mvp[7] - mvp[5]\r\n top[2] = mvp[11] - mvp[9]\r\n top[3] = mvp[15] - mvp[13]\r\n\r\n var nbPlanes = 4\r\n if (computeNearFar) {\r\n nbPlanes = 6\r\n // Far clipping plane.\r\n var far = out[4]\r\n far[0] = mvp[3] - mvp[2]\r\n far[1] = mvp[7] - mvp[6]\r\n far[2] = mvp[11] - mvp[10]\r\n far[3] = mvp[15] - mvp[14]\r\n\r\n // Near clipping plane.\r\n var near = out[5]\r\n near[0] = mvp[3] + mvp[2]\r\n near[1] = mvp[7] + mvp[6]\r\n near[2] = mvp[11] + mvp[10]\r\n near[3] = mvp[15] + mvp[14]\r\n }\r\n\r\n //Normalize the planes, from osg code\r\n for (var i = 0; i < nbPlanes; i++) {\r\n var p = out[i]\r\n // multiply the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.\r\n var inv = 1.0 / Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2])\r\n p[0] *= inv\r\n p[1] *= inv\r\n p[2] *= inv\r\n p[3] *= inv\r\n }\r\n }\r\n})()\r\n\r\n// better precison\r\n// no far clipping artifacts.\r\n// no reason not to use.\r\n// Tightening the Precision of Perspective Rendering\r\n//http://www.geometry.caltech.edu/pubs/UD12.pdf\r\n// drop-in, just remove the one below, and rename this one\r\nmat4.infiniteFrustum = function (out, left, right, bottom, top, znear) {\r\n var X = (2.0 * znear) / (right - left)\r\n var Y = (2.0 * znear) / (top - bottom)\r\n var A = (right + left) / (right - left)\r\n var B = (top + bottom) / (top - bottom)\r\n var C = -1.0\r\n out[0] = X\r\n out[1] = 0.0\r\n out[2] = 0.0\r\n out[3] = 0.0\r\n\r\n out[4] = 0.0\r\n out[5] = Y\r\n out[6] = 0.0\r\n out[7] = 0.0\r\n\r\n out[8] = A\r\n out[9] = B\r\n out[10] = C\r\n out[11] = -1.0\r\n\r\n out[12] = 0.0\r\n out[13] = 0.0\r\n out[14] = -2.0 * znear\r\n out[15] = 0.0\r\n\r\n return out\r\n}\r\n\r\nmat4.lookAtDirection = (function () {\r\n var s = vec3.create()\r\n var u = vec3.create()\r\n var neg = vec3.create()\r\n\r\n return function (out, eye, eyeDir, up) {\r\n var f = eyeDir\r\n vec3.cross(s, f, up)\r\n vec3.normalize(s, s)\r\n\r\n vec3.cross(u, s, f)\r\n vec3.normalize(u, u)\r\n\r\n // s[0], u[0], -f[0], 0.0,\r\n // s[1], u[1], -f[1], 0.0,\r\n // s[2], u[2], -f[2], 0.0,\r\n // 0, 0, 0, 1.0\r\n\r\n out[0] = s[0]\r\n out[1] = u[0]\r\n out[2] = -f[0]\r\n out[3] = 0.0\r\n out[4] = s[1]\r\n out[5] = u[1]\r\n out[6] = -f[1]\r\n out[7] = 0.0\r\n out[8] = s[2]\r\n out[9] = u[2]\r\n out[10] = -f[2]\r\n out[11] = 0.0\r\n out[12] = 0\r\n out[13] = 0\r\n out[14] = 0\r\n out[15] = 1.0\r\n\r\n return mat4.translate(out, out, vec3.neg(neg, eye))\r\n }\r\n})()\r\n\r\nmat4.getScale = (function () {\r\n var sx = vec3.create()\r\n var sy = vec3.create()\r\n var sz = vec3.create()\r\n return function (out, matrix) {\r\n sx[0] = matrix[0]\r\n sx[1] = matrix[4]\r\n sx[2] = matrix[8]\r\n sy[0] = matrix[1]\r\n sy[1] = matrix[5]\r\n sy[2] = matrix[9]\r\n sz[0] = matrix[2]\r\n sz[1] = matrix[6]\r\n sz[2] = matrix[10]\r\n\r\n out[0] = vec3.length(sx)\r\n out[1] = vec3.length(sy)\r\n out[2] = vec3.length(sz)\r\n return out\r\n }\r\n})()\r\n\r\nmat4.getSqrScale = (function () {\r\n var sx = vec3.create()\r\n var sy = vec3.create()\r\n var sz = vec3.create()\r\n return function (out, matrix) {\r\n sx[0] = matrix[0]\r\n sx[1] = matrix[4]\r\n sx[2] = matrix[8]\r\n sy[0] = matrix[1]\r\n sy[1] = matrix[5]\r\n sy[2] = matrix[9]\r\n sz[0] = matrix[2]\r\n sz[1] = matrix[6]\r\n sz[2] = matrix[10]\r\n\r\n out[0] = vec3.sqrLen(sx)\r\n out[1] = vec3.sqrLen(sy)\r\n out[2] = vec3.sqrLen(sz)\r\n return out\r\n }\r\n})()\r\n\r\nvar glmRotate = mat4.rotate\r\nmat4.rotate = function (out, a, rad, axis) {\r\n return glmRotate(out, a, rad, axis) || mat4.identity(out)\r\n}\r\n\r\nvar glmFromRotate = mat4.fromRotation\r\nmat4.fromRotation = function (out, rad, axis) {\r\n return glmFromRotate(out, rad, axis) || mat4.identity(out)\r\n}\r\n\r\nexport { glm, mat3, mat4, quat, vec2, vec3, vec4 }\r\n","// must be sync wiht Interpolator Type\r\nexport default {\r\n Vec3: 0,\r\n Quat: 1,\r\n Float: 2,\r\n FloatCubicBezier: 3,\r\n Vec3CubicBezier: 4,\r\n QuatSlerp: 5,\r\n Matrix: 6,\r\n Count: 7\r\n};\r\n","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport { mat4 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\n\r\nvar Viewport = function(x, y, w, h) {\r\n StateAttribute.call(this);\r\n\r\n this._x = x !== undefined ? x : 0;\r\n this._y = y !== undefined ? y : 0;\r\n this._width = w !== undefined ? w : 800;\r\n this._height = h !== undefined ? h : 600;\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n Viewport,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Viewport',\r\n\r\n cloneType: function() {\r\n return new Viewport();\r\n },\r\n\r\n setViewport: function(x, y, width, height) {\r\n this._x = x;\r\n this._y = y;\r\n this._width = width;\r\n this._height = height;\r\n },\r\n\r\n x: function() {\r\n return this._x;\r\n },\r\n\r\n y: function() {\r\n return this._y;\r\n },\r\n\r\n width: function() {\r\n return this._width;\r\n },\r\n\r\n height: function() {\r\n return this._height;\r\n },\r\n\r\n computeWindowMatrix: (function() {\r\n var translate = mat4.create();\r\n var scale = mat4.create();\r\n var tmpVec = vec3.create();\r\n\r\n return function(destination) {\r\n // res = Matrix offset * Matrix scale * Matrix translate\r\n mat4.fromTranslation(translate, vec3.ONE);\r\n mat4.fromScaling(scale, [0.5 * this._width, 0.5 * this._height, 0.5]);\r\n var offset = mat4.fromTranslation(\r\n destination,\r\n vec3.set(tmpVec, this._x, this._y, 0.0)\r\n );\r\n\r\n return mat4.mul(offset, offset, mat4.mul(scale, scale, translate));\r\n };\r\n })(),\r\n\r\n apply: function(state) {\r\n state.applyViewport(this);\r\n }\r\n }),\r\n 'osg',\r\n 'Viewport'\r\n);\r\n\r\nexport default Viewport;","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport Geometry from '../osg/Geometry';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport StateSet from '../osg/StateSet';\r\nimport Uniform from '../osg/Uniform';\r\nimport Depth from '../osg/Depth';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport ShaderGenerator from '../osgShader/ShaderGenerator';\r\nimport Compiler from '../osgShader/Compiler';\r\nimport RigGeometry from '../osgAnimation/RigGeometry';\r\nimport MorphGeometry from '../osgAnimation/MorphGeometry';\r\nimport UpdateMorph from '../osgAnimation/UpdateMorph';\r\n\r\n////////////////////////\r\n// COMPILER OFFSET NORMAL\r\n////////////////////////\r\nvar CompilerOffsetNormal = function() {\r\n Compiler.apply(this, arguments);\r\n};\r\n\r\nvar configNormal = Compiler.cloneStateAttributeConfig(Compiler);\r\nconfigNormal.textureAttribute = [];\r\n\r\nCompiler.setStateAttributeConfig(CompilerOffsetNormal, configNormal);\r\n\r\nutils.createPrototypeObject(\r\n CompilerOffsetNormal,\r\n utils.objectInherit(Compiler.prototype, {\r\n getCompilerName: function() {\r\n return 'CompilerOffsetNormal';\r\n },\r\n initTextureAttributes: function() {},\r\n createFragmentShaderGraph: function() {\r\n var frag = this.getNode('glFragColor');\r\n\r\n this.getNode('SetAlpha')\r\n .inputs({\r\n color: this.getOrCreateUniform('vec3', 'uColorDebug'),\r\n alpha: this.createVariable('float').setValue('1.0')\r\n })\r\n .outputs({\r\n result: frag\r\n });\r\n\r\n return [frag];\r\n },\r\n getOffsetDirection: function() {\r\n return this.getOrCreateModelNormal();\r\n },\r\n getOrCreateModelVertex: function() {\r\n var vertexOffset = this.getVariable('vertexOffset');\r\n if (vertexOffset) return vertexOffset;\r\n\r\n vertexOffset = this.createVariable('vec3', 'vertexOffset');\r\n\r\n var str =\r\n '%out = %offset == 1.0 ? %vertex + normalize(%direction.xyz) * %scale: %vertex;';\r\n this.getNode('InlineCode')\r\n .code(str)\r\n .inputs({\r\n offset: this.getOrCreateAttribute('float', 'Offset'),\r\n direction: this.getOffsetDirection(),\r\n vertex: Compiler.prototype.getOrCreateModelVertex.call(this),\r\n scale: this.getOrCreateUniform('float', 'uScale')\r\n })\r\n .outputs({\r\n out: vertexOffset\r\n });\r\n\r\n return vertexOffset;\r\n },\r\n getOrCreateViewVertex: function() {\r\n var out = this._variables.FragEyeVector;\r\n if (out && !out.isEmpty()) return out;\r\n out = this._varyings.FragEyeVector || this.createVariable('vec4', 'FragEyeVector');\r\n\r\n this.getNode('MatrixMultPosition')\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat4', 'uViewMatrix'),\r\n vec: this.getOrCreateModelVertex()\r\n })\r\n .outputs({\r\n vec: out\r\n });\r\n\r\n return out;\r\n }\r\n }),\r\n 'osgUtil',\r\n 'CompilerOffsetNormal'\r\n);\r\n\r\nvar ShaderGeneratorCompilerOffsetNormal = function() {\r\n ShaderGenerator.apply(this, arguments);\r\n this.setShaderCompiler(CompilerOffsetNormal);\r\n};\r\nutils.createPrototypeObject(\r\n ShaderGeneratorCompilerOffsetNormal,\r\n utils.objectInherit(ShaderGenerator.prototype, {}),\r\n 'osgUtil',\r\n 'ShaderGeneratorCompilerOffsetNormal'\r\n);\r\n\r\n////////////////////////\r\n// COMPILER OFFSET TANGENT\r\n////////////////////////\r\nvar CompilerOffsetTangent = function() {\r\n CompilerOffsetNormal.apply(this, arguments);\r\n};\r\n\r\nvar configTangent = configNormal;\r\nCompiler.setStateAttributeConfig(CompilerOffsetTangent, configTangent);\r\n\r\nutils.createPrototypeObject(\r\n CompilerOffsetTangent,\r\n utils.objectInherit(CompilerOffsetNormal.prototype, {\r\n getCompilerName: function() {\r\n return 'CompilerOffsetTangent';\r\n },\r\n getOffsetDirection: function() {\r\n return this.getOrCreateModelTangent();\r\n }\r\n }),\r\n 'osgUtil',\r\n 'CompilerOffsetTangent'\r\n);\r\n\r\nvar ShaderGeneratorCompilerOffsetTangent = function() {\r\n ShaderGenerator.apply(this, arguments);\r\n this.setShaderCompiler(CompilerOffsetTangent);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ShaderGeneratorCompilerOffsetTangent,\r\n utils.objectInherit(ShaderGenerator.prototype, {}),\r\n 'osgUtil',\r\n 'ShaderGeneratorCompilerOffsetTangent'\r\n);\r\n\r\n////////////////////////\r\n// DISPLAY NORMAL VISITOR\r\n////////////////////////\r\n\r\nvar DisplayNormalVisitor = function() {\r\n NodeVisitor.call(this);\r\n\r\n this._unifScale = Uniform.createFloat(1.0, 'uScale');\r\n\r\n var ns = (this._normalStateSet = new StateSet());\r\n ns.addUniform(Uniform.createFloat3(vec3.fromValues(1.0, 0.0, 0.0), 'uColorDebug'));\r\n ns.addUniform(this._unifScale);\r\n ns.setAttributeAndModes(new Depth(Depth.NEVER));\r\n ns.setShaderGeneratorName('debugNormal');\r\n\r\n var ts = (this._tangentStateSet = new StateSet());\r\n ts.addUniform(Uniform.createFloat3(vec3.fromValues(0.0, 1.0, 0.0), 'uColorDebug'));\r\n ts.addUniform(this._unifScale);\r\n ts.setAttributeAndModes(new Depth(Depth.NEVER));\r\n ts.setShaderGeneratorName('debugTangent');\r\n};\r\n\r\nDisplayNormalVisitor.CompilerOffsetNormal = CompilerOffsetNormal;\r\nDisplayNormalVisitor.CompilerOffsetTangent = CompilerOffsetTangent;\r\nDisplayNormalVisitor.ShaderGeneratorCompilerOffsetNormal = ShaderGeneratorCompilerOffsetNormal;\r\nDisplayNormalVisitor.ShaderGeneratorCompilerOffsetTangent = ShaderGeneratorCompilerOffsetTangent;\r\n\r\nutils.createPrototypeObject(\r\n DisplayNormalVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n setScale: function(scale) {\r\n this._unifScale.setFloat(scale);\r\n },\r\n setTangentVisibility: function(bool) {\r\n this._tangentStateSet.setAttributeAndModes(new Depth(bool ? Depth.LESS : Depth.NEVER));\r\n },\r\n setNormalVisibility: function(bool) {\r\n this._normalStateSet.setAttributeAndModes(new Depth(bool ? Depth.LESS : Depth.NEVER));\r\n },\r\n apply: function(node) {\r\n if (node._isVisitedNormalDebug) return;\r\n node._isVisitedNormalDebug = true;\r\n\r\n if (node instanceof Geometry) {\r\n this._createDebugGeom(node, 'Normal', this._normalStateSet);\r\n this._createDebugGeom(node, 'Tangent', this._tangentStateSet);\r\n return;\r\n }\r\n\r\n this.traverse(node);\r\n\r\n var list = node.getUpdateCallbackList();\r\n // reference the new morph geometry on the UpdateMorph callbacks\r\n for (var i = 0, nbCB = list.length; i < nbCB; ++i) {\r\n if (list[i] instanceof UpdateMorph) {\r\n list[i].init(node);\r\n }\r\n }\r\n },\r\n _createDoubleOffsetArray: function(nbVertices) {\r\n // 0 means original vertex pos\r\n // 1 means offseted vertex\r\n var elts = new Float32Array(nbVertices * 2);\r\n for (var i = 0; i < nbVertices; ++i) {\r\n elts[i * 2] = 1.0;\r\n }\r\n return new BufferArray(BufferArray.ARRAY_BUFFER, elts, 1);\r\n },\r\n _createDoubledBufferArray: function(bufferArray) {\r\n // in case of morphs\r\n if (bufferArray.getInitialBufferArray)\r\n bufferArray = bufferArray.getInitialBufferArray();\r\n\r\n var itemSize = bufferArray.getItemSize();\r\n var elements = bufferArray.getElements();\r\n var nbElements = elements.length / itemSize;\r\n\r\n var ctor = elements.constructor;\r\n var elementsDouble = new ctor(elements.length * 2);\r\n for (var i = 0; i < nbElements; ++i) {\r\n var iSize = i * itemSize;\r\n var iSize2 = iSize * 2;\r\n\r\n for (var j = 0; j < itemSize; ++j) {\r\n elementsDouble[iSize2 + j] = elementsDouble[iSize2 + j + itemSize] =\r\n elements[iSize + j];\r\n }\r\n }\r\n\r\n return new BufferArray(BufferArray.ARRAY_BUFFER, elementsDouble, itemSize);\r\n },\r\n _addMorphTargets: function(originMorph, morph, vecName) {\r\n var targets = morph.getMorphTargets();\r\n morph.setName(originMorph.getName()); // for the UpdateMorph\r\n\r\n var originTargets = originMorph.getMorphTargets();\r\n for (var i = 0, nbTarget = originTargets.length; i < nbTarget; ++i) {\r\n var origTarget = originTargets[i];\r\n var origAttrs = origTarget.getVertexAttributeList();\r\n\r\n var newTarget = new Geometry();\r\n newTarget.setName(origTarget.getName()); // for the UpdateMorph\r\n var newAttrs = newTarget.getVertexAttributeList();\r\n\r\n newAttrs.Vertex = this._createDoubledBufferArray(origAttrs.Vertex);\r\n if (origAttrs[vecName])\r\n newAttrs[vecName] = this._createDoubledBufferArray(origAttrs[vecName]);\r\n\r\n targets.push(newTarget);\r\n }\r\n\r\n morph.mergeChildrenVertexAttributeList();\r\n return morph;\r\n },\r\n _createDebugGeom: function(node, vecName, stateSet) {\r\n var attrs = node.getAttributes();\r\n var dispVec = attrs[vecName];\r\n if (!dispVec) return;\r\n\r\n var vertices = attrs.Vertex;\r\n if (!vertices) return;\r\n\r\n var originMorph;\r\n if (node instanceof MorphGeometry) originMorph = node;\r\n else if (node.getSourceGeometry && node.getSourceGeometry() instanceof MorphGeometry)\r\n originMorph = node.getSourceGeometry();\r\n\r\n var nbVertices = vertices.getElements().length / vertices.getItemSize();\r\n\r\n // vertex and normals\r\n var source = originMorph ? new MorphGeometry() : new Geometry();\r\n source.getAttributes().Vertex = this._createDoubledBufferArray(vertices);\r\n source.getAttributes().Offset = this._createDoubleOffsetArray(nbVertices);\r\n source.getAttributes()[vecName] = this._createDoubledBufferArray(dispVec);\r\n\r\n // primitive\r\n source.getPrimitives().push(new DrawArrays(primitiveSet.LINES, 0, nbVertices * 2));\r\n\r\n if (originMorph) this._addMorphTargets(originMorph, source, vecName);\r\n\r\n var geom;\r\n if (node instanceof RigGeometry) {\r\n var rig = new RigGeometry();\r\n rig.setSourceGeometry(source);\r\n\r\n rig.getVertexAttributeList().Bones = this._createDoubledBufferArray(attrs.Bones);\r\n rig.getVertexAttributeList().Weights = this._createDoubledBufferArray(\r\n attrs.Weights\r\n );\r\n\r\n // we can simply share the rig-animated stateSet attributes\r\n // (unlike morph, the stateSet and update animation doesn't operate at per vertex level)\r\n rig._rigTransformImplementation = node._rigTransformImplementation;\r\n rig._stateSetAnimation = node._stateSetAnimation;\r\n\r\n rig.mergeChildrenData();\r\n geom = rig;\r\n } else {\r\n geom = source;\r\n }\r\n\r\n // add geom to the graph\r\n var parents = node.getParents();\r\n var nbParents = parents.length;\r\n geom._isVisitedNormalDebug = true;\r\n geom._isNormalDebug = true;\r\n geom.setStateSet(stateSet);\r\n for (var i = 0; i < nbParents; ++i) parents[i].addChild(geom);\r\n\r\n return geom;\r\n }\r\n }),\r\n 'osgUtil',\r\n 'DisplayNormalVisitor'\r\n);\r\n\r\nexport default DisplayNormalVisitor;","import notify from '../osg/notify';\r\n\r\nvar isBufferGZIP = function(arrayBuffer) {\r\n var typedArray = new Uint8Array(arrayBuffer);\r\n return typedArray[0] === 0x1f && typedArray[1] === 0x8b;\r\n};\r\n\r\nvar gunzip = function(arrayBuffer) {\r\n var typedArray = new Uint8Array(arrayBuffer);\r\n var zlib = require('zlibjs');\r\n\r\n if (!zlib) {\r\n notify.error(\r\n 'osg failed to use a gunzip.min.js to uncompress a gz file.\\n You can add this vendors to enable this feature or get it at https://github.com/imaya/zlib.js/blob/master/bin/gunzip.min.js'\r\n );\r\n }\r\n\r\n var zdec = new zlib.Gunzip(typedArray);\r\n var result = zdec.decompress();\r\n return result.buffer;\r\n};\r\n\r\nexport default {\r\n isGunzipBuffer: isBufferGZIP,\r\n gunzip: gunzip\r\n};","import utils from './utils';\r\nimport Camera from './Camera';\r\nimport FrameBufferObject from './FrameBufferObject';\r\nimport notify from './notify';\r\nimport RenderBin from './RenderBin';\r\nimport { vec4 } from './glMatrix';\r\nimport PooledResource from './PooledResource';\r\n\r\n/**\r\n * From OpenSceneGraph http://www.openscenegraph.org\r\n * RenderStage base class. Used for encapsulate a complete stage in\r\n * rendering - setting up of viewport, the projection and model\r\n * matrices and rendering the RenderBin's enclosed with this RenderStage.\r\n * RenderStage also has a dependency list of other RenderStages, each\r\n * of which must be called before the rendering of this stage. These\r\n * 'pre' rendering stages are used for advanced rendering techniques\r\n * like multistage pixel shading or impostors.\r\n */\r\nvar RenderStage = function() {\r\n RenderBin.call(this);\r\n this._clearColor = vec4.create();\r\n this._clearDepth = undefined;\r\n this._clearMask = undefined;\r\n this._camera = undefined;\r\n this._viewport = undefined;\r\n this._scissor = undefined;\r\n this._preRenderList = [];\r\n this._postRenderList = [];\r\n // calling prototype to make sure\r\n // we call renderstage and not renderbin init\r\n RenderStage.prototype.init.call(this);\r\n};\r\n\r\nvar createRenderStageOrder = function() {\r\n return {\r\n renderStage: null,\r\n order: null\r\n };\r\n};\r\n\r\nvar pooledRenderStageOrder = new PooledResource(createRenderStageOrder);\r\n\r\nutils.createPrototypeObject(\r\n RenderStage,\r\n utils.objectInherit(RenderBin.prototype, {\r\n init: function() {\r\n RenderBin.prototype.init.call(this);\r\n this._clearDepth = 1.0;\r\n vec4.set(this._clearColor, 0.0, 0.0, 0.0, 1.0);\r\n /*jshint bitwise: false */\r\n this._clearMask = Camera.COLOR_BUFFER_BIT | Camera.DEPTH_BUFFER_BIT;\r\n /*jshint bitwise: true */\r\n this._camera = undefined;\r\n this._viewport = undefined;\r\n this._scissor = undefined;\r\n this._renderStage = this;\r\n RenderStage.prototype._initInternal.call(this);\r\n return this;\r\n },\r\n\r\n _initInternal: function() {\r\n this._preRenderList.length = 0;\r\n this._postRenderList.length = 0;\r\n },\r\n\r\n reset: function() {\r\n pooledRenderStageOrder.reset();\r\n RenderBin.prototype.reset.call(this);\r\n RenderStage.prototype._initInternal.call(this);\r\n },\r\n\r\n setClearDepth: function(depth) {\r\n this._clearDepth = depth;\r\n },\r\n\r\n getClearDepth: function() {\r\n return this._clearDepth;\r\n },\r\n\r\n setClearColor: function(color) {\r\n vec4.copy(this._clearColor, color);\r\n },\r\n\r\n getClearColor: function() {\r\n return this._clearColor;\r\n },\r\n\r\n setClearMask: function(mask) {\r\n this._clearMask = mask;\r\n },\r\n\r\n getClearMask: function() {\r\n return this._clearMask;\r\n },\r\n\r\n setViewport: function(vp) {\r\n this._viewport = vp;\r\n },\r\n\r\n getViewport: function() {\r\n return this._viewport;\r\n },\r\n\r\n setScissor: function(scissor) {\r\n this._scissor = scissor;\r\n },\r\n\r\n getScissor: function() {\r\n return this._scissor;\r\n },\r\n\r\n setCamera: function(camera) {\r\n this._camera = camera;\r\n },\r\n\r\n getCamera: function() {\r\n return this._camera;\r\n },\r\n\r\n getPreRenderStageList: function() {\r\n return this._preRenderList;\r\n },\r\n\r\n getPostRenderStageList: function() {\r\n return this._postRenderList;\r\n },\r\n\r\n addPreRenderStage: function(rs, order) {\r\n for (var i = 0, l = this._preRenderList.length; i < l; i++) {\r\n var render = this._preRenderList[i];\r\n if (order < render.order) {\r\n break;\r\n }\r\n }\r\n\r\n var renderStageOrder = pooledRenderStageOrder.getOrCreateObject();\r\n renderStageOrder.order = order;\r\n renderStageOrder.renderStage = rs;\r\n if (i < this._preRenderList.length) {\r\n this._preRenderList.splice(i, 0, renderStageOrder);\r\n } else {\r\n this._preRenderList.push(renderStageOrder);\r\n }\r\n },\r\n\r\n addPostRenderStage: function(rs, order) {\r\n for (var i = 0, l = this._postRenderList.length; i < l; i++) {\r\n var render = this._postRenderList[i];\r\n if (order < render.order) {\r\n break;\r\n }\r\n }\r\n\r\n var renderStageOrder = pooledRenderStageOrder.getOrCreateObject();\r\n renderStageOrder.order = order;\r\n renderStageOrder.renderStage = rs;\r\n if (i < this._postRenderList.length) {\r\n this._postRenderList.splice(i, 0, renderStageOrder);\r\n } else {\r\n this._postRenderList.push(renderStageOrder);\r\n }\r\n },\r\n\r\n drawPreRenderStages: function(state, previousRenderLeaf) {\r\n var previousLeaf = previousRenderLeaf;\r\n for (var i = 0, l = this._preRenderList.length; i < l; ++i) {\r\n var sg = this._preRenderList[i].renderStage;\r\n previousLeaf = sg.draw(state, previousLeaf);\r\n }\r\n return previousLeaf;\r\n },\r\n\r\n draw: function(state, previousRenderLeaf) {\r\n if (this._camera && this._camera.getInitialDrawCallback()) {\r\n // if we have a camera with a final callback invoke it.\r\n this._camera.getInitialDrawCallback()(state);\r\n }\r\n\r\n var previousLeaf = this.drawPreRenderStages(state, previousRenderLeaf);\r\n\r\n previousLeaf = this.drawImplementation(state, previousLeaf);\r\n\r\n previousLeaf = this.drawPostRenderStages(state, previousLeaf);\r\n\r\n if (this._camera && this._camera.getFinalDrawCallback()) {\r\n // if we have a camera with a final callback invoke it.\r\n this._camera.getFinalDrawCallback()(state);\r\n }\r\n\r\n return previousLeaf;\r\n },\r\n\r\n sort: function() {\r\n for (var i = 0, l = this._preRenderList.length; i < l; ++i) {\r\n this._preRenderList[i].renderStage.sort();\r\n }\r\n\r\n RenderBin.prototype.sort.call(this);\r\n\r\n for (var j = 0, k = this._postRenderList.length; j < k; ++j) {\r\n this._postRenderList[j].renderStage.sort();\r\n }\r\n },\r\n\r\n drawPostRenderStages: function(state, previousRenderLeaf) {\r\n var previousLeaf = previousRenderLeaf;\r\n for (var i = 0, l = this._postRenderList.length; i < l; ++i) {\r\n var sg = this._postRenderList[i].renderStage;\r\n previousLeaf = sg.draw(state, previousLeaf);\r\n }\r\n return previousLeaf;\r\n },\r\n\r\n applyCamera: function(state) {\r\n var gl = state.getGraphicContext();\r\n if (this._camera === undefined) {\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n return;\r\n }\r\n var viewport = this._camera.getViewport();\r\n var fbo = this._camera.frameBufferObject;\r\n\r\n if (!fbo) {\r\n fbo = new FrameBufferObject();\r\n this._camera.frameBufferObject = fbo;\r\n }\r\n\r\n if (fbo.isDirty()) {\r\n var attachments = this._camera.getAttachments();\r\n\r\n // framebuffer texture and renderbuffer must be same dimension\r\n // otherwise framebuffer is incomplete\r\n var framebufferWidth, framebufferHeight;\r\n var colorAttachment = attachments[FrameBufferObject.COLOR_ATTACHMENT0];\r\n if (colorAttachment && colorAttachment.texture) {\r\n framebufferWidth = colorAttachment.texture.getWidth();\r\n framebufferHeight = colorAttachment.texture.getHeight();\r\n }\r\n\r\n // we should use a map in camera to avoid to regenerate the keys\r\n // each time. But because we dont have a lot of camera I guess\r\n // it does not change a lot\r\n // texture and renderbuffer must be same size.\r\n for (var keyAttachment in attachments) {\r\n colorAttachment = attachments[keyAttachment];\r\n\r\n var attach = {};\r\n attach.attachment = colorAttachment.attachment;\r\n\r\n if (colorAttachment.texture === undefined) {\r\n //renderbuffer\r\n\r\n attach.format = colorAttachment.format;\r\n attach.width =\r\n framebufferWidth !== undefined ? framebufferWidth : viewport.width();\r\n attach.height =\r\n framebufferHeight !== undefined ? framebufferHeight : viewport.height();\r\n } else {\r\n attach.texture = colorAttachment.texture;\r\n attach.textureTarget = colorAttachment.textureTarget;\r\n\r\n if (colorAttachment.format) {\r\n attach.format = colorAttachment.format;\r\n }\r\n }\r\n\r\n fbo.setAttachment(attach);\r\n }\r\n }\r\n fbo.apply(state);\r\n },\r\n\r\n drawImplementation: function(state, previousRenderLeaf) {\r\n var gl = state.getGraphicContext();\r\n\r\n this.applyCamera(state);\r\n\r\n // projection clipping\r\n if (this._viewport === undefined) {\r\n notify.log('RenderStage does not have a valid viewport');\r\n }\r\n state.applyAttribute(this._viewport);\r\n\r\n if (this._scissor) {\r\n state.applyAttribute(this._scissor);\r\n }\r\n\r\n if (this._clearMask !== 0x0) {\r\n if (this._clearMask & gl.COLOR_BUFFER_BIT) {\r\n state.clearColor(this._clearColor);\r\n }\r\n if (this._clearMask & gl.DEPTH_BUFFER_BIT) {\r\n state.depthMask(true);\r\n state.clearDepth(this._clearDepth);\r\n }\r\n state.clear(this._clearMask);\r\n }\r\n\r\n if (this._positionedAttribute.getLength() !== 0) {\r\n this.applyPositionedAttribute(state, this._positionedAttribute);\r\n }\r\n\r\n var previousLeaf = RenderBin.prototype.drawImplementation.call(\r\n this,\r\n state,\r\n previousRenderLeaf\r\n );\r\n\r\n return previousLeaf;\r\n }\r\n }),\r\n 'osg',\r\n 'RenderStage'\r\n);\r\n\r\nRenderStage.clean = function() {\r\n pooledRenderStageOrder.clean();\r\n};\r\n\r\nexport default RenderStage;","import utils from './utils';\r\n\r\n/**\r\n * Object class\r\n * @class Object\r\n */\r\nvar OSGObject = function() {\r\n this._name = undefined;\r\n this._userdata = undefined;\r\n this._instanceID = OSGObject.getInstanceID();\r\n};\r\n\r\n/** @lends Object.prototype */\r\nutils.createPrototypeObject(\r\n OSGObject, {\r\n // this method works only if constructor is set correctly\r\n // see issue https://github.com/cedricpinson/osgjs/issues/494\r\n cloneType: function() {\r\n var Constructor = this.constructor;\r\n return new Constructor();\r\n },\r\n\r\n getInstanceID: function() {\r\n return this._instanceID;\r\n },\r\n\r\n setName: function(name) {\r\n this._name = name;\r\n },\r\n\r\n getName: function() {\r\n return this._name;\r\n },\r\n\r\n setUserData: function(data) {\r\n this._userdata = data;\r\n },\r\n\r\n getUserData: function() {\r\n return this._userdata;\r\n }\r\n },\r\n 'osg',\r\n 'Object'\r\n);\r\n\r\n// get an instanceID for each object\r\nvar instanceID = 0;\r\nOSGObject.getInstanceID = function() {\r\n instanceID += 1;\r\n return instanceID;\r\n};\r\n\r\nexport default OSGObject;","// prevent crash on old browser\r\nif (window.Set && window.Map && window.Uint8ClampedArray) {\r\n // This file contains needed polyfills mainly for IE11\r\n if (!Math.sign) {\r\n Math.sign = function(a) {\r\n return a > 0.0 ? 1.0 : a < 0.0 ? -1.0 : 0.0;\r\n };\r\n }\r\n\r\n if (!Math.log2) {\r\n Math.log2 = function(x) {\r\n return Math.log(x) * Math.LOG2E;\r\n };\r\n }\r\n\r\n if (!Math.log10) {\r\n Math.log10 = function(x) {\r\n return Math.log(x) * Math.LOG10E;\r\n };\r\n }\r\n\r\n if (!String.prototype.endsWith) {\r\n String.prototype.endsWith = function(str) {\r\n return this.slice(-str.length) === str;\r\n };\r\n }\r\n\r\n if (!String.prototype.startsWith) {\r\n String.prototype.startsWith = function(str) {\r\n return this.slice(0, str.length) === str;\r\n };\r\n }\r\n\r\n if (!Float32Array.prototype.slice) {\r\n var _slicePolyfill = function(start, end) {\r\n return new this.constructor(this.subarray(start, end));\r\n };\r\n\r\n Int8Array.prototype.slice = _slicePolyfill;\r\n Uint8Array.prototype.slice = _slicePolyfill;\r\n Uint8ClampedArray.prototype.slice = _slicePolyfill;\r\n Int16Array.prototype.slice = _slicePolyfill;\r\n Uint16Array.prototype.slice = _slicePolyfill;\r\n Int32Array.prototype.slice = _slicePolyfill;\r\n Uint32Array.prototype.slice = _slicePolyfill;\r\n Float32Array.prototype.slice = _slicePolyfill;\r\n Float64Array.prototype.slice = _slicePolyfill;\r\n }\r\n\r\n // IE11 does not support Set with constructing arguments. May 2017.\r\n var setTest = new window.Set(['test']);\r\n var hasConstructorParameterSupport = setTest.has('test');\r\n if (!hasConstructorParameterSupport) {\r\n var nativeSetConstructor = window.Set;\r\n window.Set = function(init) {\r\n var set = new nativeSetConstructor();\r\n if (init) {\r\n for (var i = 0; i < init.length; ++i) {\r\n set.add(init[i]);\r\n }\r\n }\r\n return set;\r\n };\r\n }\r\n\r\n // IE11 doesn't support Event() constructor\r\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent\r\n // Here we define window.Event instead of window.CustomEvent so that it can be instantiated in the InputManager\r\n if (typeof window.Event === 'object') {\r\n function CustomEvent(event, params) {\r\n params = params || { bubbles: false, cancelable: false, detail: undefined };\r\n var evt = document.createEvent('CustomEvent');\r\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\r\n return evt;\r\n }\r\n\r\n CustomEvent.prototype = window.Event.prototype;\r\n\r\n window.Event = CustomEvent;\r\n }\r\n}\r\n","import utils from './utils';\r\nimport Node from './Node';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport { mat4 } from './glMatrix';\r\nimport { vec2 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\nimport BoundingSphere from './BoundingSphere';\r\n\r\n/**\r\n * Lod that can contains child node\r\n * @class Lod\r\n */\r\nvar Lod = function() {\r\n Node.call(this);\r\n this._radius = -1;\r\n this._range = [];\r\n this._rangeMode = Lod.DISTANCE_FROM_EYE_POINT;\r\n this._userDefinedCenter = [];\r\n this._centerMode = Lod.USE_BOUNDING_SPHERE_CENTER;\r\n};\r\n\r\nLod.DISTANCE_FROM_EYE_POINT = 0;\r\nLod.PIXEL_SIZE_ON_SCREEN = 1;\r\n\r\nLod.USE_BOUNDING_SPHERE_CENTER = 0;\r\nLod.USER_DEFINED_CENTER = 1;\r\nLod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED = 2;\r\n\r\n/** @lends Lod.prototype */\r\nutils.createPrototypeNode(\r\n Lod,\r\n utils.objectInherit(Node.prototype, {\r\n // Functions here\r\n getRadius: function() {\r\n return this._radius;\r\n },\r\n\r\n /** Set the object-space reference radius of the volume enclosed by the LOD.\r\n * Used to determine the bounding sphere of the LOD in the absence of any children.*/\r\n setRadius: function(radius) {\r\n this._radius = radius;\r\n },\r\n\r\n setCenter: function(center) {\r\n if (this._centerMode !== Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED)\r\n this._centerMode = Lod.USER_DEFINED_CENTER;\r\n this._userDefinedCenter = center;\r\n },\r\n\r\n getCenter: function() {\r\n if (\r\n this._centerMode === Lod.USER_DEFINED_CENTER ||\r\n this._centerMode === Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED\r\n )\r\n return this._userDefinedCenter;\r\n else return this.getBound().center();\r\n },\r\n\r\n setCenterMode: function(centerMode) {\r\n this._centerMode = centerMode;\r\n },\r\n\r\n computeBoundingSphere: function(bsphere) {\r\n if (this._centerMode === Lod.USER_DEFINED_CENTER && this._radius >= 0.0) {\r\n bsphere.set(this._userDefinedCenter, this._radius);\r\n return bsphere;\r\n } else if (\r\n this._centerMode === Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED &&\r\n this._radius >= 0.0\r\n ) {\r\n bsphere.set(this._userDefinedCenter, this._radius);\r\n var bs = new BoundingSphere();\r\n bsphere.expandByBoundingSphere(Node.prototype.computeBoundingSphere.call(this, bs));\r\n return bsphere;\r\n } else {\r\n Node.prototype.computeBoundingSphere.call(this, bsphere);\r\n return bsphere;\r\n }\r\n },\r\n\r\n projectBoundingSphere: (function() {\r\n // from http://www.iquilezles.org/www/articles/sphereproj/sphereproj.htm\r\n // Sample code at http://www.shadertoy.com/view/XdBGzd?\r\n var o = vec3.create();\r\n return function(sph, camMatrix, fle) {\r\n vec3.transformMat4(o, sph.center(), camMatrix);\r\n var r2 = sph.radius2();\r\n var z2 = o[2] * o[2];\r\n var l2 = vec3.sqrLen(o);\r\n var area = -Math.PI *\r\n fle *\r\n fle *\r\n r2 *\r\n Math.sqrt(Math.abs((l2 - r2) / (r2 - z2))) /\r\n (r2 - z2);\r\n return area;\r\n };\r\n })(),\r\n\r\n setRangeMode: function(mode) {\r\n //TODO: check if mode is correct\r\n this._rangeMode = mode;\r\n },\r\n\r\n addChildNode: function(node) {\r\n Node.prototype.addChild.call(this, node);\r\n if (this.children.length > this._range.length) {\r\n var r = [];\r\n var max = 0.0;\r\n if (this._range.lenght > 0) max = this._range[this._range.length - 1][1];\r\n r.push(vec2.fromValues(max, max));\r\n this._range.push(r);\r\n }\r\n return true;\r\n },\r\n\r\n addChild: function(node, min, max) {\r\n Node.prototype.addChild.call(this, node);\r\n\r\n if (this.children.length > this._range.length) {\r\n var r = [];\r\n r.push(vec2.fromValues(min, min));\r\n this._range.push(r);\r\n }\r\n this._range[this.children.length - 1][0] = min;\r\n this._range[this.children.length - 1][1] = max;\r\n return true;\r\n },\r\n\r\n traverse: (function() {\r\n // avoid to generate variable on the heap to limit garbage collection\r\n // instead create variable and use the same each time\r\n var zeroVector = vec3.create();\r\n var eye = vec3.create();\r\n var viewModel = mat4.create();\r\n\r\n return function(visitor) {\r\n var traversalMode = visitor.traversalMode;\r\n\r\n switch (traversalMode) {\r\n case NodeVisitor.TRAVERSE_ALL_CHILDREN:\r\n for (var index = 0; index < this.children.length; index++) {\r\n this.children[index].accept(visitor);\r\n }\r\n break;\r\n\r\n case NodeVisitor.TRAVERSE_ACTIVE_CHILDREN:\r\n var requiredRange = 0;\r\n var matrix = visitor.getCurrentModelViewMatrix();\r\n mat4.invert(viewModel, matrix);\r\n // Calculate distance from viewpoint\r\n if (this._rangeMode === Lod.DISTANCE_FROM_EYE_POINT) {\r\n vec3.transformMat4(eye, zeroVector, viewModel);\r\n var d = vec3.distance(this.getBound().center(), eye);\r\n requiredRange = d * visitor.getLODScale();\r\n } else {\r\n // Let's calculate pixels on screen\r\n var projmatrix = visitor.getCurrentProjectionMatrix();\r\n // focal lenght is the value stored in projmatrix[0]\r\n requiredRange = this.projectBoundingSphere(\r\n this.getBound(),\r\n matrix,\r\n projmatrix[0]\r\n );\r\n // Multiply by a factor to get the real area value\r\n requiredRange =\r\n requiredRange *\r\n visitor.getViewport().width() *\r\n visitor.getViewport().width() *\r\n 0.25 /\r\n visitor.getLODScale();\r\n }\r\n\r\n var numChildren = this.children.length;\r\n if (this._range.length < numChildren) numChildren = this._range.length;\r\n\r\n for (var j = 0; j < numChildren; ++j) {\r\n if (\r\n this._range[j][0] <= requiredRange &&\r\n requiredRange < this._range[j][1]\r\n ) {\r\n this.children[j].accept(visitor);\r\n }\r\n }\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'Lod'\r\n);\r\n\r\nexport default Lod;","import notify from './notify';\r\nimport utils from './utils';\r\nimport Object from './Object';\r\n\r\nvar ImageBitmap = window.ImageBitmap || function() {};\r\n\r\nvar ImageObject = function(image) {\r\n Object.call(this);\r\n\r\n this._imageObject = undefined;\r\n this._url = undefined;\r\n this._width = undefined;\r\n this._height = undefined;\r\n this._dirty = true;\r\n this._mipmap = [];\r\n\r\n if (image) {\r\n this.setImage(image);\r\n }\r\n\r\n this._isGreyscale = undefined;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ImageObject,\r\n utils.objectInherit(Object.prototype, {\r\n dirty: function() {\r\n this._isGreyscale = undefined;\r\n this._dirty = true;\r\n },\r\n\r\n isDirty: function() {\r\n return this._dirty;\r\n },\r\n\r\n setDirty: function(bool) {\r\n this._dirty = bool;\r\n },\r\n\r\n getImage: function() {\r\n return this._imageObject instanceof ImageObject ?\r\n this._imageObject.getImage() :\r\n this._imageObject;\r\n },\r\n\r\n getURL: function() {\r\n return this._url;\r\n },\r\n\r\n setURL: function(url) {\r\n this._url = url;\r\n },\r\n\r\n useOrCreateImage: function(img) {\r\n return img instanceof ImageObject === false ? new ImageObject(img) : img;\r\n },\r\n\r\n setImage: function(img) {\r\n if (!this._url && img && (img.src || img.currentSrc)) {\r\n // TODO what is currentSrc ?\r\n this._url = img.src || img.currentSrc;\r\n }\r\n\r\n this._mipmap.length = 0;\r\n\r\n // img can be an image or an array of image if specify the\r\n // all mipmap levels\r\n if (Array.isArray(img)) {\r\n for (var i = 0, nbImg = img.length; i < nbImg; i++) {\r\n this._mipmap.push(this.useOrCreateImage(img[i]));\r\n }\r\n this.setWidth(this._mipmap[0].getWidth());\r\n this.setHeight(this._mipmap[0].getHeight());\r\n } else {\r\n this._mipmap.push(img);\r\n }\r\n\r\n this._imageObject = this._mipmap[0];\r\n this.dirty();\r\n },\r\n\r\n isCanvas: function() {\r\n return this.getImage() instanceof window.HTMLCanvasElement;\r\n },\r\n\r\n isBitmap: function() {\r\n return this.getImage() instanceof ImageBitmap;\r\n },\r\n\r\n isVideo: function() {\r\n return this.getImage() instanceof window.HTMLVideoElement;\r\n },\r\n\r\n isImage: function() {\r\n return this.getImage() instanceof window.Image;\r\n },\r\n\r\n isTypedArray: function() {\r\n var img = this.getImage();\r\n return (\r\n img instanceof Uint8Array ||\r\n img instanceof Float32Array ||\r\n img instanceof Uint16Array\r\n );\r\n },\r\n\r\n setWidth: function(w) {\r\n this._width = w;\r\n },\r\n\r\n setHeight: function(h) {\r\n this._height = h;\r\n },\r\n\r\n getWidth: function() {\r\n var img = this.getImage();\r\n if (this.isImage()) {\r\n return img.naturalWidth;\r\n } else if (this.isVideo()) {\r\n return img.videoWidth;\r\n } else if (this.isCanvas() || this.isBitmap()) {\r\n return img.width;\r\n }\r\n return this._width;\r\n },\r\n\r\n getHeight: function() {\r\n var img = this.getImage();\r\n if (this.isImage()) {\r\n return img.naturalHeight;\r\n } else if (this.isVideo()) {\r\n return img.videoHeight;\r\n } else if (this.isCanvas() || this.isBitmap()) {\r\n return img.height;\r\n }\r\n return this._height;\r\n },\r\n\r\n isGreyscale: function(nbSamples) {\r\n if (this._isGreyscale !== undefined) return this._isGreyscale;\r\n\r\n if (\r\n this._imageObject !== undefined &&\r\n this.isReady() &&\r\n this._isGreyscale === undefined\r\n ) {\r\n var canvas = this._imageObject;\r\n if (!this.isCanvas()) {\r\n canvas = document.createElement('canvas');\r\n }\r\n var ctx = canvas.getContext('2d');\r\n canvas.width = this._imageObject.width;\r\n canvas.height = this._imageObject.height;\r\n ctx.drawImage(this._imageObject, 0, 0);\r\n\r\n var sampleX, sampleY;\r\n // cap sample if needed\r\n if (!nbSamples) {\r\n sampleX = canvas.width;\r\n sampleY = canvas.height;\r\n }\r\n if (nbSamples > 0) {\r\n nbSamples = Math.min(Math.min(canvas.width, canvas.height), nbSamples);\r\n sampleX = sampleY = nbSamples;\r\n }\r\n\r\n var isGreyscale = true;\r\n var xFactor = canvas.width / sampleX;\r\n var yFactor = canvas.height / sampleY;\r\n for (var i = 0; i < sampleX; i++) {\r\n for (var j = 0; j < sampleY; j++) {\r\n var x = Math.floor(xFactor * (i + 0.5)),\r\n y = Math.floor(yFactor * (j + 0.5));\r\n var data = ctx.getImageData(x, y, 1, 1).data;\r\n if (!(data[0] === data[1] && data[0] === data[2])) {\r\n isGreyscale = false;\r\n break;\r\n }\r\n }\r\n }\r\n this._isGreyscale = isGreyscale;\r\n }\r\n\r\n return this._isGreyscale;\r\n },\r\n\r\n isReady: function() {\r\n // image is a osgImage\r\n if (this._imageObject && this._imageObject instanceof ImageObject) {\r\n return this._imageObject.isReady();\r\n }\r\n\r\n // image are ready for static data\r\n if (this.isCanvas() || this.isTypedArray() || this.isBitmap()) {\r\n return true;\r\n }\r\n\r\n if (this.isImage()) {\r\n var image = this.getImage();\r\n if (image.complete) {\r\n if (image.naturalWidth !== undefined && image.naturalWidth === 0) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n }\r\n\r\n if (this.isVideo()) {\r\n if (this.getWidth() !== 0) return true;\r\n }\r\n\r\n // here means we have something but we don't know what\r\n // Check if the object is not a image\r\n // by \"feature\" detect it\r\n var imageTry = this.getImage();\r\n if (imageTry.complete) {\r\n if (imageTry.naturalWidth !== undefined && imageTry.naturalWidth === 0) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n // It's not something we recognise\r\n /*develblock:start*/\r\n notify.warn(\"Warning can't detect image object \");\r\n /*develblock:end*/\r\n return false;\r\n },\r\n\r\n getMipmap: function() {\r\n return this._mipmap;\r\n },\r\n\r\n hasMipmap: function() {\r\n return this._mipmap.length > 1;\r\n },\r\n\r\n release: function() {\r\n this._mipmap.length = 0;\r\n this._imageObject = undefined;\r\n }\r\n }),\r\n 'osg',\r\n 'Image'\r\n);\r\n\r\nexport default ImageObject;","import utils from '../osg/utils';\r\nimport Compiler from '../osgShader/Compiler';\r\n\r\nvar CompilerShadowCast = function() {\r\n Compiler.apply(this, arguments);\r\n};\r\n\r\nvar config = Compiler.cloneStateAttributeConfig(Compiler);\r\nconfig.attribute = ['ShadowCast', 'Morph', 'Skinning', 'PointSize'];\r\n\r\nCompiler.setStateAttributeConfig(CompilerShadowCast, config);\r\n\r\nutils.createPrototypeObject(\r\n CompilerShadowCast,\r\n utils.objectInherit(Compiler.prototype, {\r\n getCompilerName: function() {\r\n return 'ShadowCast';\r\n },\r\n\r\n initAttributes: function() {\r\n var attributes = this._attributes;\r\n\r\n for (var i = 0, l = attributes.length; i < l; i++) {\r\n var type = attributes[i].className();\r\n\r\n if (type === 'ShadowCastAttribute') {\r\n this._shadowCastAttribute = attributes[i];\r\n } else if (type === 'Billboard') {\r\n this._isBillboard = !!attributes[i];\r\n } else if (type === 'SkinningAttribute') {\r\n this._skinningAttribute = attributes[i];\r\n } else if (type === 'MorphAttribute') {\r\n this._morphAttribute = attributes[i];\r\n } else if (type === 'PointSizeAttribute') {\r\n this._pointSizeAttribute = attributes[i];\r\n }\r\n }\r\n },\r\n\r\n registerTextureAttributes: function() {},\r\n\r\n // Depth Shadow Map Casted from Light POV Depth encoded in color buffer\r\n createShadowCastDepth: function(out) {\r\n var defines = this._shadowCastAttribute.getDefines();\r\n\r\n var node = this.getNode('ShadowCast')\r\n .inputs({\r\n shadowDepthRange: this.getOrCreateUniform('vec4', 'uShadowDepthRange'),\r\n fragEye: this.getOrCreateViewVertex()\r\n })\r\n .outputs({ result: out });\r\n\r\n node.getDefines = function() {\r\n return defines;\r\n };\r\n\r\n return out;\r\n },\r\n\r\n // encapsulate for easier overwrite by user defined compiler\r\n // that would inherint from this compiler Do not merge with above method\r\n createFragmentShaderGraph: function() {\r\n var frag = this.getNode('glFragColor');\r\n return [this.createShadowCastDepth(frag)];\r\n }\r\n }),\r\n 'osgShader',\r\n 'CompilerShadowCast'\r\n);\r\n\r\nexport default CompilerShadowCast;","var NodeVisitor = function(traversalMode) {\r\n /*jshint bitwise: false */\r\n this.traversalMask = ~0x0;\r\n /*jshint bitwise: true */\r\n this.nodeMaskOverride = 0;\r\n this.traversalMode = traversalMode;\r\n if (traversalMode === undefined) {\r\n this.traversalMode = NodeVisitor.TRAVERSE_ALL_CHILDREN;\r\n }\r\n this.nodePath = [];\r\n this.visitorType = NodeVisitor.NODE_VISITOR;\r\n this._databaseRequestHandler = undefined;\r\n this._frameStamp = undefined;\r\n\r\n this.traverse = NodeVisitor._traversalFunctions[this.traversalMode];\r\n this.pushOntoNodePath = NodeVisitor._pushOntoNodePath[this.traversalMode];\r\n this.popFromNodePath = NodeVisitor._popFromNodePath[this.traversalMode];\r\n};\r\n\r\n//NodeVisitor.TRAVERSE_NONE = 0;\r\nNodeVisitor.TRAVERSE_PARENTS = 1;\r\nNodeVisitor.TRAVERSE_ALL_CHILDREN = 2;\r\nNodeVisitor.TRAVERSE_ACTIVE_CHILDREN = 3;\r\n\r\nNodeVisitor.NODE_VISITOR = 0;\r\nNodeVisitor.UPDATE_VISITOR = 1;\r\nNodeVisitor.CULL_VISITOR = 2;\r\n\r\n// =================== Traversal functions ===============\r\nvar traverseParents = function traverseParents(node) {\r\n node.ascend(this);\r\n};\r\n\r\nvar traverseChildren = function traverseAllChildren(node) {\r\n node.traverse(this);\r\n};\r\n\r\n// must be sync with TRAVERSE_ENUMS\r\nNodeVisitor._traversalFunctions = [undefined, traverseParents, traverseChildren, traverseChildren];\r\n\r\n// =================== PushOntoNodePath functions ===============\r\nvar pushOntoNodePathParents = function(node) {\r\n this.nodePath.unshift(node);\r\n};\r\n\r\nvar pushOntoNodePathChildren = function(node) {\r\n this.nodePath.push(node);\r\n};\r\n\r\nNodeVisitor._pushOntoNodePath = [\r\n undefined,\r\n pushOntoNodePathParents,\r\n pushOntoNodePathChildren,\r\n pushOntoNodePathChildren\r\n];\r\n\r\n// =================== PopOntoNodePath functions ===============\r\nvar popFromNodePathParents = function() {\r\n return this.nodePath.shift();\r\n};\r\n\r\nvar popFromNodePathChildren = function() {\r\n this.nodePath.pop();\r\n};\r\n\r\nNodeVisitor._popFromNodePath = [\r\n undefined,\r\n popFromNodePathParents,\r\n popFromNodePathChildren,\r\n popFromNodePathChildren\r\n];\r\n\r\nNodeVisitor.prototype = {\r\n reset: function() {\r\n // to be used when you want to re-use a nv\r\n this.nodePath.length = 0;\r\n },\r\n\r\n setFrameStamp: function(frameStamp) {\r\n this._frameStamp = frameStamp;\r\n },\r\n\r\n getFrameStamp: function() {\r\n return this._frameStamp;\r\n },\r\n\r\n setNodeMaskOverride: function(m) {\r\n this.nodeMaskOverride = m;\r\n },\r\n getNodeMaskOverride: function() {\r\n return this.nodeMaskOverride;\r\n },\r\n\r\n setTraversalMask: function(m) {\r\n this.traversalMask = m;\r\n },\r\n getTraversalMask: function() {\r\n return this.traversalMask;\r\n },\r\n\r\n getNodePath: function() {\r\n return this.nodePath;\r\n },\r\n\r\n validNodeMask: function(node) {\r\n var nm = node.getNodeMask();\r\n /*jshint bitwise: false */\r\n return (this.traversalMask & (this.nodeMaskOverride | nm)) !== 0;\r\n /*jshint bitwise: true */\r\n },\r\n apply: function(node) {\r\n this.traverse(node);\r\n },\r\n getVisitorType: function() {\r\n return this.visitorType;\r\n },\r\n setDatabaseRequestHandler: function(dbpager) {\r\n this._databaseRequestHandler = dbpager;\r\n },\r\n getDatabaseRequestHandler: function() {\r\n return this._databaseRequestHandler;\r\n }\r\n};\r\n\r\nexport default NodeVisitor;\r\n","import notify from '../osg/notify';\r\nimport ShaderGenerator from './ShaderGenerator';\r\nimport ShadowCastShaderGenerator from '../osgShadow/ShadowCastShaderGenerator';\r\nimport DisplayNormalVisitor from '../osgUtil/DisplayNormalVisitor';\r\nimport DisplayGeometryVisitor from '../osgUtil/DisplayGeometryVisitor';\r\n\r\nvar ShaderGeneratorProxy = function() {\r\n // object of shader generators\r\n this._generators = {};\r\n this.addShaderGenerator('default', new ShaderGenerator());\r\n this.addShaderGenerator('ShadowCast', new ShadowCastShaderGenerator());\r\n this.addShaderGenerator(\r\n 'debugNormal',\r\n new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetNormal()\r\n );\r\n this.addShaderGenerator(\r\n 'debugTangent',\r\n new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetTangent()\r\n );\r\n this.addShaderGenerator(\r\n 'debugGeometry',\r\n new DisplayGeometryVisitor.ShaderGeneratorCompilerColorGeometry()\r\n );\r\n this.addShaderGenerator(\r\n 'debugSkinning',\r\n new DisplayGeometryVisitor.ShaderGeneratorCompilerColorSkinning()\r\n );\r\n\r\n return this;\r\n};\r\n\r\nShaderGeneratorProxy.prototype = {\r\n getShaderGenerator: function(name) {\r\n if (!name) return this._generators.default;\r\n\r\n var shaderGenerator = this._generators[name];\r\n\r\n if (!shaderGenerator) {\r\n notify.error('ShaderGenerator ' + name + ' does not exist in ShaderGeneratorProxy');\r\n return this._generators.default;\r\n }\r\n\r\n return shaderGenerator;\r\n },\r\n\r\n // user-space facility to provide its own\r\n addShaderGenerator: function(name, sg) {\r\n this._generators[name] = sg;\r\n }\r\n};\r\n\r\nexport default ShaderGeneratorProxy;\r\n","import notify from '../osg/notify';\r\nimport shaderLib from './shaderLib';\r\nimport shadowShaderLib from '../osgShadow/shaderLib';\r\nimport WebglCaps from '../osg/WebGLCaps';\r\n\r\n// webgl2 protected variable names : sample, texture\r\n\r\n// Shader as vert/frag/glsl files Using requirejs text plugin\r\n// Preprocess features like: //\r\n// - Handle (recursive) include, avoiding code repeat and help code factorization\r\n// - Handle per shader and global define/precision\r\n\r\nvar ShaderProcessor = function(createInstance) {\r\n if (!createInstance) {\r\n if (ShaderProcessor.instance) {\r\n return ShaderProcessor.instance;\r\n }\r\n ShaderProcessor.instance = this;\r\n }\r\n\r\n this.addShaders(shaderLib);\r\n this.addShaders(shadowShaderLib);\r\n return this;\r\n};\r\n\r\nShaderProcessor.prototype = {\r\n _shadersText: {},\r\n _shadersList: {},\r\n _globalDefaultprecision:\r\n '#ifdef GL_FRAGMENT_PRECISION_HIGH\\n precision highp float;\\n #else\\n precision mediump float;\\n#endif',\r\n _debugLines: false,\r\n _includeR: /#pragma include \"([^\"]+)\"/g,\r\n _includeCondR: /#pragma include ([\"^+\"]?[\"\\ \"[a-zA-Z_0-9](.*)\"]*?)/g,\r\n _defineR: /\\#define\\s+([a-zA-Z_0-9]+)/,\r\n _precisionR: /precision\\s+(high|low|medium)p\\s+float/,\r\n\r\n // {\r\n // 'functions.glsl': textShaderFunctions,\r\n // 'lights.glsl': textShaderFunctions,\r\n // 'textures.glsl': textShaderFunctions\r\n // };\r\n addShaders: function(shaders) {\r\n for (var key in shaders) {\r\n this._shadersList[key] = key;\r\n this._shadersText[key] = shaders[key];\r\n }\r\n },\r\n\r\n instrumentShaderlines: function(content, sourceID) {\r\n // TODO instrumentShaderlines\r\n // http://immersedcode.org/2012/1/12/random-notes-on-webgl/\r\n // one ID per \"file\"\r\n // Each file has its line number starting at 0\r\n // handle include, the do that numbering also in preprocess...\r\n // Then on shader error using sourceID and line you can point the correct line...\r\n // has to attach that info to osg.shader object.\r\n /*\r\n var allLines = content.split('\\n');\r\n var i = 0;\r\n for (var k = 0; k _< allLines.length; k++) {\r\n if (!this._includeR.test(allLines[k])) {\r\n allLines[k] = \"#line \" + (i++) + \" \" + sourceID + '\\n' + allLines[k] ;\r\n }\r\n }\r\n content = allLines.join('\\n');\r\n */\r\n\r\n // seems just prefixing first line seems ok to help renumbering error mesg\r\n return '\\n#line ' + 0 + ' ' + sourceID + '\\n' + content;\r\n },\r\n\r\n hasShader: function(shaderName) {\r\n // unlike getShaderTextPure, doesn't log an erreur if the shader doesn't exist\r\n return this._shadersText[shaderName] !== undefined;\r\n },\r\n\r\n getShaderTextPure: function(shaderName) {\r\n var preShader = this._shadersText[shaderName];\r\n\r\n if (!preShader) {\r\n notify.error('shader file/text: ' + shaderName + ' not registered');\r\n preShader = '';\r\n }\r\n\r\n return preShader;\r\n },\r\n\r\n getShader: function(shaderName, defines, extensions, type) {\r\n var shader = this.getShaderTextPure(shaderName);\r\n return this.processShader(shader, defines, extensions, type);\r\n },\r\n\r\n // recursively handle #include external glsl\r\n // files (for now in the same folder.)\r\n preprocess: function(content, sourceID, includeList, inputsDefines /*, type */) {\r\n var self = this;\r\n return content.replace(\r\n this._includeCondR,\r\n function(_, strMatch) {\r\n var includeOpt = strMatch.split(' ');\r\n var includeName = includeOpt[0].replace(/\"/g, '');\r\n\r\n // pure include is\r\n // \\#pragma include \"name\";\r\n\r\n // conditionnal include is name included if _PCF defined\r\n // \\#pragma include \"name\" \"_PCF\";\r\n if (includeOpt.length > 1 && inputsDefines) {\r\n // some conditions here.\r\n // if not defined we do not include\r\n var found = false;\r\n var defines = inputsDefines.map(function(defineString) {\r\n // find '#define', remove duplicate whitespace, split on space and return the define Text\r\n return (\r\n self._defineR.test(defineString) &&\r\n defineString.replace(/\\s+/g, ' ').split(' ')[1]\r\n );\r\n });\r\n\r\n for (var i = 1; i < includeOpt.length && !found; i++) {\r\n var key = includeOpt[i].replace(/\"/g, '');\r\n for (var k = 0; k < defines.length && !found; k++) {\r\n if (defines[k] !== false && defines[k] === key) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n }\r\n if (!found) return '';\r\n }\r\n\r\n // already included\r\n if (includeList.indexOf(includeName) !== -1) return '';\r\n // avoid endless loop, not calling the impure\r\n var txt = this.getShaderTextPure(includeName);\r\n // make sure it's not included twice\r\n includeList.push(includeName);\r\n if (this._debugLines) {\r\n txt = this.instrumentShaderlines(txt, sourceID);\r\n }\r\n sourceID++;\r\n // to the infinite and beyond !\r\n txt = this.preprocess(txt, sourceID, includeList, inputsDefines);\r\n return txt;\r\n }.bind(this)\r\n );\r\n },\r\n\r\n _getSortedUnique: (function() {\r\n var filterDuplicate = function(item, pos, self) {\r\n return !pos || item !== self[pos - 1];\r\n };\r\n\r\n return function(array) {\r\n return array && array.sort().filter(filterDuplicate);\r\n };\r\n })(),\r\n\r\n _convertExtensionsToWebGL2: (function() {\r\n var cbRenamer = function(match, extension) {\r\n return 'core_' + extension;\r\n };\r\n\r\n var cbDefiner = function(match, extension) {\r\n return '#define ' + extension;\r\n };\r\n\r\n var extensions =\r\n '(GL_EXT_shader_texture_lod|GL_OES_standard_derivatives|GL_EXT_draw_buffers|GL_EXT_frag_depth)';\r\n var definer = new RegExp('#\\\\s*extension\\\\s+' + extensions + '.*', 'g');\r\n var renamer = new RegExp(extensions, 'g');\r\n\r\n return function(strShader) {\r\n strShader = strShader.replace(definer, cbDefiner); // replace #extension by #define\r\n strShader = strShader.replace(renamer, cbRenamer); // rename extension\r\n return strShader;\r\n };\r\n })(),\r\n\r\n _convertToWebGL2: (function() {\r\n var frags = [];\r\n var replaceMRT = function(match, number) {\r\n var varName = 'glFragData_' + number;\r\n frags[number] = 'layout(location = ' + number + ') out vec4 ' + varName + ';';\r\n return varName;\r\n };\r\n\r\n return function(strShader, isFragment) {\r\n if (!strShader) return strShader;\r\n\r\n strShader = strShader.replace(/attribute\\s+/g, 'in ');\r\n strShader = strShader.replace(/varying\\s+/g, isFragment ? 'in ' : 'out ');\r\n strShader = strShader.replace(/(texture2D|textureCube)\\s*\\(/g, 'texture(');\r\n strShader = strShader.replace(/(textureCubeLodEXT)\\s*\\(/g, 'textureLod(');\r\n\r\n strShader = this._convertExtensionsToWebGL2(strShader);\r\n\r\n if (isFragment) {\r\n frags.length = 0;\r\n strShader = strShader.replace(/gl_FragData\\s*\\[\\s*(\\d+)\\s*\\]/g, replaceMRT);\r\n\r\n if (!frags.length) frags.push('out vec4 glFragColor_0;');\r\n strShader = strShader.replace(/gl_FragColor/g, 'glFragColor_0');\r\n strShader = strShader.replace(\r\n /void\\s+main\\s*\\(/g,\r\n frags.join('\\n') + '\\nvoid main('\r\n );\r\n }\r\n\r\n return strShader;\r\n };\r\n })(),\r\n\r\n _hasVersion: function(shader) {\r\n // match first line starting with #\r\n var version = shader.match(/^#(.*)$/m);\r\n return version && version[0].indexOf('version') !== -1;\r\n },\r\n\r\n // process shader\r\n // - declare version, extensions, precision and defines\r\n // - resolve pragma include\r\n // - Convert webgl1 to webgl2 (glsl 100 to glsl 330 es)\r\n processShader: function(shader, defines, extensions, type) {\r\n // if the shader has #version statement we skip the shader processing\r\n if (this._hasVersion(shader)) {\r\n return shader;\r\n }\r\n\r\n var includeList = [];\r\n var preShader = shader;\r\n var sourceID = 0;\r\n if (this._debugLines) {\r\n preShader = this.instrumentShaderlines(preShader, sourceID);\r\n sourceID++;\r\n }\r\n\r\n // removes duplicates\r\n defines = this._getSortedUnique(defines);\r\n extensions = this._getSortedUnique(extensions);\r\n\r\n var strCore = this.preprocess(preShader, sourceID, includeList, defines, type);\r\n\r\n // avoid warning on unrecognized pragma\r\n strCore = strCore.replace(/#pragma DECLARE_FUNCTION/g, '//#pragma DECLARE_FUNCTION');\r\n\r\n var isFragment = strCore.indexOf('gl_Position') === -1;\r\n var convertToWebGL2 = WebglCaps.instance().isWebGL2();\r\n\r\n var strVersion = convertToWebGL2 ? '#version 300 es' : '#version 100';\r\n strVersion += '\\n';\r\n\r\n var strExtensions = extensions ? extensions.join('\\n') + '\\n' : '';\r\n\r\n var strDefines = defines ? defines.join('\\n') + '\\n' : '';\r\n\r\n if (convertToWebGL2) {\r\n strExtensions = this._convertExtensionsToWebGL2(strExtensions);\r\n strDefines = this._convertToWebGL2(strDefines, isFragment);\r\n strCore = this._convertToWebGL2(strCore, isFragment);\r\n } else {\r\n // support multiline define\r\n strDefines = strDefines.replace(/\\\\\\n/g, '');\r\n strCore = strCore.replace(/\\\\\\n/g, '');\r\n }\r\n\r\n // vertex shader uses highp per default BUT if FS is using mediump then VS should too (conflict with varying/uniform otherwise)\r\n // also make sure precision is not already providen\r\n var strPrecision = '';\r\n if (this._globalDefaultprecision && !this._precisionR.test(strCore)) {\r\n strPrecision = this._globalDefaultprecision + '\\n';\r\n }\r\n\r\n // order is important\r\n // See https://khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf (p14-15: extension before any non-processor token)\r\n return strVersion + strExtensions + strPrecision + strDefines + strCore;\r\n }\r\n};\r\nexport default ShaderProcessor;\r\n","import Compiler from './Compiler';\r\nimport ShaderGenerator from './ShaderGenerator';\r\nimport ShaderGeneratorProxy from './ShaderGeneratorProxy';\r\nimport ShaderProcessor from './ShaderProcessor';\r\nimport NextShaderProcessor from './NextShaderProcessor';\r\nimport nodeFactory from './nodeFactory';\r\nimport Node from './node/Node';\r\nimport utils from './utils';\r\n\r\nvar lib = {};\r\n\r\nlib.Compiler = Compiler;\r\nlib.ShaderGenerator = ShaderGenerator;\r\nlib.ShaderGeneratorProxy = ShaderGeneratorProxy;\r\nlib.NextShaderProcessor = NextShaderProcessor;\r\nlib.ShaderProcessor = ShaderProcessor;\r\nlib.nodeFactory = nodeFactory;\r\nlib.utils = utils;\r\n\r\nlib.node = {};\r\nlib.node.Node = Node; // used for inheritance\r\nnodeFactory._nodes.forEach(function(value, key) {\r\n lib.node[key] = value;\r\n});\r\n\r\n// debug utility: set it to one to have verbose in shaders\r\nlib.debugShaderNode = false;\r\n/*develblock:start*/\r\nlib.debugShaderNode = true;\r\n/*develblock:end*/\r\n\r\nexport default lib;\r\n","import Object from './Object';\r\nimport Plane from './Plane';\r\nimport utils from './utils';\r\nimport { vec4 } from './glMatrix';\r\nimport PooledArray from './PooledArray';\r\n\r\n/*jshint bitwise: false */\r\n/**\r\n * Polytope class for representing convex clipping volumes made up of a set of planes.\r\n * When adding planes, their normals should point inwards (into the volume)\r\n * @class Polytope\r\n */\r\nvar Polytope = function() {\r\n this._clippingMask = 0x0;\r\n\r\n this._planeList = [\r\n Plane.create(),\r\n Plane.create(),\r\n Plane.create(),\r\n Plane.create(),\r\n Plane.create(),\r\n Plane.create()\r\n ];\r\n this._vertexList = [];\r\n\r\n // stack of clipping masks\r\n this._maskStack = new PooledArray();\r\n\r\n // init with a clear mask\r\n this._resultMask = 0;\r\n this._maskStack.push(this._resultMask);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Polytope,\r\n utils.objectInherit(Object.prototype, {\r\n getPlanes: function() {\r\n return this._planeList;\r\n },\r\n\r\n setPlanes: function(pl) {\r\n this._planeList = pl;\r\n this.setupMask();\r\n },\r\n\r\n clear: function() {\r\n this._clippingMask = 0x0;\r\n if (this._planeList) {\r\n for (var i = 0, l = this._planeList.length; i < l; ++i) {\r\n Plane.init(this._planeList[i]);\r\n }\r\n }\r\n this._vertexList = [];\r\n this.setupMask();\r\n },\r\n\r\n /** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/\r\n setToUnitFrustum: function(withNear, withFar) {\r\n if (withNear === undefined) withNear = true;\r\n\r\n if (withFar === undefined) withFar = true;\r\n\r\n this._planeList.length = 0;\r\n this._planeList.push(vec4.set(Plane.create(), 1.0, 0.0, 0.0, 1.0)); // left plane.\r\n this._planeList.push(vec4.set(Plane.create(), -1.0, 0.0, 0.0, 1.0)); // right plane.\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, 1.0, 0.0, 1.0)); // bottom plane.\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, -1.0, 0.0, 1.0)); // top plane.\r\n if (withNear) this._planeList.push(vec4.set(Plane.create(), 0.0, 0.0, 1.0, 1.0)); // near plane\r\n if (withFar) this._planeList.push(vec4.set(Plane.create(), 0.0, 0.0, -1.0, 1.0)); // far plane\r\n this.setupMask();\r\n },\r\n\r\n /** Create a Polytope which is a equivalent to BoundingBox.*/\r\n setToBoundingBox: function(bb) {\r\n this._planeList.length = 0;\r\n this._planeList.push(vec4.set(Plane.create(), 1.0, 0.0, 0.0, -bb.getMin()[0])); // left plane.\r\n this._planeList.push(vec4.set(Plane.create(), -1.0, 0.0, 0.0, bb.getMax()[0])); // right plane.\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, 1.0, 0.0, -bb.getMin()[1])); // bottom plane.\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, -1.0, 0.0, bb.getMax()[1])); // top plane.\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, 0.0, 1.0, -bb.getMin()[2])); // near plane\r\n this._planeList.push(vec4.set(Plane.create(), 0.0, 0.0, -1.0, bb.getMax()[2])); // far plane\r\n this.setupMask();\r\n },\r\n\r\n setAndTransformProvidingInverse: function(pt, matrix) {\r\n this._referenceVertexList = pt._referenceVertexList;\r\n var polytopBackIndex = this._maskStack.getLength() - 1;\r\n var resultMask = pt._maskStack[polytopBackIndex];\r\n if (resultMask === 0) {\r\n this._maskStack.getArray()[polytopBackIndex] = 0;\r\n this._resultMask = 0;\r\n this._planeList.length = 0;\r\n return;\r\n }\r\n var selectorMask = 0x1;\r\n\r\n var numActivePlanes = 0;\r\n // count number of active planes.\r\n var i;\r\n for (i = 0; i !== pt._planeList.length; ++i) {\r\n if (resultMask & selectorMask) ++numActivePlanes;\r\n selectorMask <<= 1;\r\n }\r\n\r\n this._planeList.length = numActivePlanes;\r\n this._resultMask = 0;\r\n selectorMask = 0x1;\r\n var index = 0;\r\n for (i = 0; i !== pt._planeList.length; ++i) {\r\n if (resultMask & selectorMask) {\r\n this._planeList[index] = pt._planeList[i];\r\n Plane.transformProvidingInverse(this._planeList[index++], matrix);\r\n this._resultMask = (this._resultMask << 1) | 1;\r\n }\r\n selectorMask <<= 1;\r\n }\r\n\r\n this._maskStack.getArray()[polytopBackIndex] = this._resultMask;\r\n },\r\n\r\n voidset: function(pl) {\r\n this._planeList = pl;\r\n this.setupMask();\r\n },\r\n\r\n add: function(pl) {\r\n this._planeList.push(pl);\r\n this.setupMask();\r\n },\r\n\r\n empty: function() {\r\n return this._planeList.length === 0;\r\n },\r\n\r\n setReferenceVertexList: function(vertices) {\r\n this._referenceVertexList = vertices;\r\n },\r\n\r\n getReferenceVertexList: function() {\r\n return this._referenceVertexList;\r\n },\r\n\r\n setupMask: function(plength) {\r\n this._resultMask = 0;\r\n var pMasklength = plength !== undefined ? plength : this._planeList.length;\r\n for (var i = 0; i < pMasklength; ++i) {\r\n this._resultMask = (this._resultMask << 1) | 1;\r\n }\r\n this._maskStack.reset();\r\n this._maskStack.push(this._resultMask);\r\n },\r\n\r\n getCurrentMask: function() {\r\n return this._maskStack.back();\r\n },\r\n\r\n setResultMask: function(mask) {\r\n this._resultMask = mask;\r\n },\r\n\r\n getResultMask: function() {\r\n return this._resultMask;\r\n },\r\n\r\n getMaskStack: function() {\r\n return this._maskStack;\r\n },\r\n\r\n // push but keep current mask\r\n pushCurrentMask: function() {\r\n this._maskStack.push(this._resultMask);\r\n },\r\n // pop and restore previous mask\r\n popCurrentMask: function() {\r\n return this._maskStack.pop();\r\n },\r\n\r\n /** Check whether a vertex is contained within clipping set.*/\r\n containsVertex: function(v) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return true;\r\n\r\n var selectorMask = 0x1;\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (\r\n polytopeBack & selectorMask &&\r\n Plane.distanceToPlane(this._planeList[i], v) < 0.0\r\n ) {\r\n return false;\r\n }\r\n selectorMask <<= 1;\r\n }\r\n return true;\r\n },\r\n\r\n /** Check whether any part of vertex list is contained within clipping set.*/\r\n containsVertices: function(vertices) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return true;\r\n\r\n this._resultMask = polytopeBack;\r\n\r\n for (var k = 0; k < vertices.length; ++k) {\r\n var v = vertices[k];\r\n var outside = false;\r\n var selectorMask = 0x1;\r\n for (var i = 0; !outside && i < this._planeList.length; ++i) {\r\n if (\r\n polytopeBack & selectorMask &&\r\n Plane.distanceToPlane(this._planeList[i], v) < 0.0\r\n ) {\r\n outside = true;\r\n }\r\n selectorMask <<= 1;\r\n }\r\n\r\n if (!outside) return true;\r\n }\r\n return false;\r\n },\r\n\r\n /** Check whether any part of a bounding sphere is contained within clipping set.\r\n Using a mask to determine which planes should be used for the check, and\r\n modifying the mask to turn off planes which wouldn't contribute to clipping\r\n of any internal objects. This feature is used in osgUtil::CullVisitor\r\n to prevent redundant plane checking.*/\r\n containsBoundingSphere: function(bs) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack || !bs.valid()) return true;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (this._resultMask & selectorMask) {\r\n var res = Plane.intersectsOrContainsBoundingSphere(this._planeList[i], bs);\r\n if (Plane.OUTSIDE === res) {\r\n // totally outside a clipping set.\r\n return false;\r\n } else if (Plane.INSIDE === res) {\r\n // subsequent checks against this plane not required.\r\n this._resultMask ^= selectorMask;\r\n }\r\n // else if ( Plane.INTERSECT === res ) { // last possible case\r\n // can say nothing.\r\n // subsequent checks against this plane needed.\r\n //}\r\n }\r\n selectorMask <<= 1;\r\n }\r\n return true;\r\n },\r\n\r\n /** Check whether any part of a bounding box is contained within clipping set.\r\n Using a mask to determine which planes should be used for the check, and\r\n modifying the mask to turn off planes which wouldn't contribute to clipping\r\n of any internal objects. This feature is used in osgUtil::CullVisitor\r\n to prevent redundant plane checking.*/\r\n containsBoundingBox: function(bb) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return true;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (this._resultMask & selectorMask) {\r\n var res = Plane.intersectsOrContainsBoundingBox(this._planeList[i], bb);\r\n if (Plane.OUTSIDE === res) return false;\r\n else if (Plane.INSIDE === res)\r\n // outside clipping set.\r\n this._resultMask ^= selectorMask; // subsequent checks against this plane not required.\r\n // else if ( Plane.INTERSECT === res ) the last case need\r\n // no test here but further tests\r\n }\r\n selectorMask <<= 1;\r\n }\r\n // correct frustum culling should double check now for\r\n // http://www.iquilezles.org/www/articles/frustumcorrect/frustumcorrect.htm\r\n // which is inside one \"plane\", but outside the convex plane intersection\r\n return true;\r\n },\r\n\r\n /** Check whether all of vertex list is contained with clipping set.*/\r\n containsAllOfVertices: function(vertices) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return false;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (this._resultMask & selectorMask) {\r\n var res = Plane.intersectsOrContainsVertices(this._planeList[i], vertices);\r\n if (res < 1) return false; // intersects, or is below plane.\r\n this._resultMask ^= selectorMask; // subsequent checks against this plane not required.\r\n }\r\n selectorMask <<= 1;\r\n }\r\n return true;\r\n },\r\n\r\n /** Check whether the entire bounding sphere is contained within clipping set.*/\r\n containsAllOfBoundingSphere: function(bs) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return false;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (this._resultMask & selectorMask) {\r\n var res = Plane.intersectsOrContainsBoundingSphere(this._planeList[i], bs);\r\n if (res < 1) return false; // intersects, or is below plane.\r\n this._resultMask ^= selectorMask; // subsequent checks against this plane not required.\r\n }\r\n selectorMask <<= 1;\r\n }\r\n return true;\r\n },\r\n\r\n /** Check whether the entire bounding box is contained within clipping set.*/\r\n containsAllOfBoundingBox: function(bbox) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return false;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (this._resultMask & selectorMask) {\r\n var res = Plane.intersectsOrContainsBoundingBox(this._planeList[i], bbox);\r\n if (res < 1) return false; // intersects, or is below plane.\r\n this._resultMask ^= selectorMask; // subsequent checks against this plane not required.\r\n }\r\n selectorMask <<= 1;\r\n }\r\n return true;\r\n },\r\n\r\n /** Transform the clipping set by provide a pre inverted matrix.\r\n * see transform for details. */\r\n transformProvidingInverse: function(matrix) {\r\n var polytopeBack = this._maskStack.back();\r\n if (!polytopeBack) return;\r\n\r\n this._resultMask = polytopeBack;\r\n var selectorMask = 0x1;\r\n for (var i = 0; i < this._planeList.length; ++i) {\r\n if (polytopeBack & selectorMask) {\r\n Plane.transformProvidingInverse(this._planeList[i], matrix);\r\n }\r\n selectorMask <<= 1;\r\n }\r\n }\r\n }),\r\n 'osg',\r\n 'Polytope'\r\n);\r\n\r\n/*jshint bitwise: true */\r\n\r\nexport default Polytope;","import { vec3 } from './glMatrix';\r\nimport BufferArray from './BufferArray';\r\nimport Geometry from './Geometry';\r\nimport primitiveSet from './primitiveSet';\r\nimport DrawArrays from './DrawArrays';\r\nimport DrawElements from './DrawElements';\r\nimport Program from './Program';\r\nimport Shader from './Shader';\r\nimport utils from './utils';\r\n\r\n/**\r\n * Create a Textured Box on the given center with given size\r\n * @name createTexturedBox\r\n */\r\nvar createTexturedBoxGeometry = function(cx, cy, cz, sx, sy, sz) {\r\n var centerx = cx !== undefined ? cx : 0.0;\r\n var centery = cy !== undefined ? cy : 0.0;\r\n var centerz = cz !== undefined ? cz : 0.0;\r\n\r\n var sizex = sx !== undefined ? sx : 1.0;\r\n var sizey = sy !== undefined ? sy : 1.0;\r\n var sizez = sz !== undefined ? sz : 1.0;\r\n\r\n var g = new Geometry();\r\n var dx, dy, dz;\r\n dx = sizex / 2.0;\r\n dy = sizey / 2.0;\r\n dz = sizez / 2.0;\r\n\r\n var vertexes = new utils.Float32Array(72);\r\n var uv = new utils.Float32Array(48);\r\n var normal = new utils.Float32Array(72);\r\n\r\n // -ve y plane\r\n vertexes[0] = centerx - dx;\r\n vertexes[1] = centery - dy;\r\n vertexes[2] = centerz + dz;\r\n normal[0] = 0.0;\r\n normal[1] = -1.0;\r\n normal[2] = 0.0;\r\n uv[0] = 0.0;\r\n uv[1] = 1.0;\r\n\r\n vertexes[3] = centerx - dx;\r\n vertexes[4] = centery - dy;\r\n vertexes[5] = centerz - dz;\r\n normal[3] = 0.0;\r\n normal[4] = -1.0;\r\n normal[5] = 0.0;\r\n uv[2] = 0.0;\r\n uv[3] = 0.0;\r\n\r\n vertexes[6] = centerx + dx;\r\n vertexes[7] = centery - dy;\r\n vertexes[8] = centerz - dz;\r\n normal[6] = 0.0;\r\n normal[7] = -1.0;\r\n normal[8] = 0.0;\r\n uv[4] = 1.0;\r\n uv[5] = 0.0;\r\n\r\n vertexes[9] = centerx + dx;\r\n vertexes[10] = centery - dy;\r\n vertexes[11] = centerz + dz;\r\n normal[9] = 0.0;\r\n normal[10] = -1.0;\r\n normal[11] = 0.0;\r\n uv[6] = 1.0;\r\n uv[7] = 1.0;\r\n\r\n // +ve y plane\r\n vertexes[12] = centerx + dx;\r\n vertexes[13] = centery + dy;\r\n vertexes[14] = centerz + dz;\r\n normal[12] = 0.0;\r\n normal[13] = 1.0;\r\n normal[14] = 0.0;\r\n uv[8] = 0.0;\r\n uv[9] = 1.0;\r\n\r\n vertexes[15] = centerx + dx;\r\n vertexes[16] = centery + dy;\r\n vertexes[17] = centerz - dz;\r\n normal[15] = 0.0;\r\n normal[16] = 1.0;\r\n normal[17] = 0.0;\r\n uv[10] = 0.0;\r\n uv[11] = 0.0;\r\n\r\n vertexes[18] = centerx - dx;\r\n vertexes[19] = centery + dy;\r\n vertexes[20] = centerz - dz;\r\n normal[18] = 0.0;\r\n normal[19] = 1.0;\r\n normal[20] = 0.0;\r\n uv[12] = 1.0;\r\n uv[13] = 0.0;\r\n\r\n vertexes[21] = centerx - dx;\r\n vertexes[22] = centery + dy;\r\n vertexes[23] = centerz + dz;\r\n normal[21] = 0.0;\r\n normal[22] = 1.0;\r\n normal[23] = 0.0;\r\n uv[14] = 1.0;\r\n uv[15] = 1.0;\r\n\r\n // +ve x plane\r\n vertexes[24] = centerx + dx;\r\n vertexes[25] = centery - dy;\r\n vertexes[26] = centerz + dz;\r\n normal[24] = 1.0;\r\n normal[25] = 0.0;\r\n normal[26] = 0.0;\r\n uv[16] = 0.0;\r\n uv[17] = 1.0;\r\n\r\n vertexes[27] = centerx + dx;\r\n vertexes[28] = centery - dy;\r\n vertexes[29] = centerz - dz;\r\n normal[27] = 1.0;\r\n normal[28] = 0.0;\r\n normal[29] = 0.0;\r\n uv[18] = 0.0;\r\n uv[19] = 0.0;\r\n\r\n vertexes[30] = centerx + dx;\r\n vertexes[31] = centery + dy;\r\n vertexes[32] = centerz - dz;\r\n normal[30] = 1.0;\r\n normal[31] = 0.0;\r\n normal[32] = 0.0;\r\n uv[20] = 1.0;\r\n uv[21] = 0.0;\r\n\r\n vertexes[33] = centerx + dx;\r\n vertexes[34] = centery + dy;\r\n vertexes[35] = centerz + dz;\r\n normal[33] = 1.0;\r\n normal[34] = 0.0;\r\n normal[35] = 0.0;\r\n uv[22] = 1.0;\r\n uv[23] = 1.0;\r\n\r\n // -ve x plane\r\n vertexes[36] = centerx - dx;\r\n vertexes[37] = centery + dy;\r\n vertexes[38] = centerz + dz;\r\n normal[36] = -1.0;\r\n normal[37] = 0.0;\r\n normal[38] = 0.0;\r\n uv[24] = 0.0;\r\n uv[25] = 1.0;\r\n\r\n vertexes[39] = centerx - dx;\r\n vertexes[40] = centery + dy;\r\n vertexes[41] = centerz - dz;\r\n normal[39] = -1.0;\r\n normal[40] = 0.0;\r\n normal[41] = 0.0;\r\n uv[26] = 0.0;\r\n uv[27] = 0.0;\r\n\r\n vertexes[42] = centerx - dx;\r\n vertexes[43] = centery - dy;\r\n vertexes[44] = centerz - dz;\r\n normal[42] = -1.0;\r\n normal[43] = 0.0;\r\n normal[44] = 0.0;\r\n uv[28] = 1.0;\r\n uv[29] = 0.0;\r\n\r\n vertexes[45] = centerx - dx;\r\n vertexes[46] = centery - dy;\r\n vertexes[47] = centerz + dz;\r\n normal[45] = -1.0;\r\n normal[46] = 0.0;\r\n normal[47] = 0.0;\r\n uv[30] = 1.0;\r\n uv[31] = 1.0;\r\n\r\n // top\r\n // +ve z plane\r\n vertexes[48] = centerx - dx;\r\n vertexes[49] = centery + dy;\r\n vertexes[50] = centerz + dz;\r\n normal[48] = 0.0;\r\n normal[49] = 0.0;\r\n normal[50] = 1.0;\r\n uv[32] = 0.0;\r\n uv[33] = 1.0;\r\n\r\n vertexes[51] = centerx - dx;\r\n vertexes[52] = centery - dy;\r\n vertexes[53] = centerz + dz;\r\n normal[51] = 0.0;\r\n normal[52] = 0.0;\r\n normal[53] = 1.0;\r\n uv[34] = 0.0;\r\n uv[35] = 0.0;\r\n\r\n vertexes[54] = centerx + dx;\r\n vertexes[55] = centery - dy;\r\n vertexes[56] = centerz + dz;\r\n normal[54] = 0.0;\r\n normal[55] = 0.0;\r\n normal[56] = 1.0;\r\n uv[36] = 1.0;\r\n uv[37] = 0.0;\r\n\r\n vertexes[57] = centerx + dx;\r\n vertexes[58] = centery + dy;\r\n vertexes[59] = centerz + dz;\r\n normal[57] = 0.0;\r\n normal[58] = 0.0;\r\n normal[59] = 1.0;\r\n uv[38] = 1.0;\r\n uv[39] = 1.0;\r\n\r\n // bottom\r\n // -ve z plane\r\n vertexes[60] = centerx + dx;\r\n vertexes[61] = centery + dy;\r\n vertexes[62] = centerz - dz;\r\n normal[60] = 0.0;\r\n normal[61] = 0.0;\r\n normal[62] = -1.0;\r\n uv[40] = 0.0;\r\n uv[41] = 1.0;\r\n\r\n vertexes[63] = centerx + dx;\r\n vertexes[64] = centery - dy;\r\n vertexes[65] = centerz - dz;\r\n normal[63] = 0.0;\r\n normal[64] = 0.0;\r\n normal[65] = -1.0;\r\n uv[42] = 0.0;\r\n uv[43] = 0.0;\r\n\r\n vertexes[66] = centerx - dx;\r\n vertexes[67] = centery - dy;\r\n vertexes[68] = centerz - dz;\r\n normal[66] = 0.0;\r\n normal[67] = 0.0;\r\n normal[68] = -1.0;\r\n uv[44] = 1.0;\r\n uv[45] = 0.0;\r\n\r\n vertexes[69] = centerx - dx;\r\n vertexes[70] = centery + dy;\r\n vertexes[71] = centerz - dz;\r\n normal[69] = 0.0;\r\n normal[70] = 0.0;\r\n normal[71] = -1.0;\r\n uv[46] = 1.0;\r\n uv[47] = 1.0;\r\n\r\n var indexes = new utils.Uint16Array(36);\r\n indexes[0] = 0;\r\n indexes[1] = 1;\r\n indexes[2] = 2;\r\n indexes[3] = 0;\r\n indexes[4] = 2;\r\n indexes[5] = 3;\r\n\r\n indexes[6] = 4;\r\n indexes[7] = 5;\r\n indexes[8] = 6;\r\n indexes[9] = 4;\r\n indexes[10] = 6;\r\n indexes[11] = 7;\r\n\r\n indexes[12] = 8;\r\n indexes[13] = 9;\r\n indexes[14] = 10;\r\n indexes[15] = 8;\r\n indexes[16] = 10;\r\n indexes[17] = 11;\r\n\r\n indexes[18] = 12;\r\n indexes[19] = 13;\r\n indexes[20] = 14;\r\n indexes[21] = 12;\r\n indexes[22] = 14;\r\n indexes[23] = 15;\r\n\r\n indexes[24] = 16;\r\n indexes[25] = 17;\r\n indexes[26] = 18;\r\n indexes[27] = 16;\r\n indexes[28] = 18;\r\n indexes[29] = 19;\r\n\r\n indexes[30] = 20;\r\n indexes[31] = 21;\r\n indexes[32] = 22;\r\n indexes[33] = 20;\r\n indexes[34] = 22;\r\n indexes[35] = 23;\r\n\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertexes, 3);\r\n g.getAttributes().Normal = new BufferArray(BufferArray.ARRAY_BUFFER, normal, 3);\r\n g.getAttributes().TexCoord0 = new BufferArray(BufferArray.ARRAY_BUFFER, uv, 2);\r\n\r\n var primitive = new DrawElements(\r\n primitiveSet.TRIANGLES,\r\n new BufferArray(BufferArray.ELEMENT_ARRAY_BUFFER, indexes, 1)\r\n );\r\n g.getPrimitives().push(primitive);\r\n return g;\r\n};\r\n\r\n// better perf\r\n// no more pixel shader hurt for nothing\r\n// http://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/\r\n// It's a Singleton, as it's rendering invariant\r\n// so same remove uneeded state change when same geom\r\nvar createTexturedFullScreenFakeQuadGeometry = (function() {\r\n var scopes = {}\r\n\r\n var newQuad = function() {\r\n var g = new Geometry();\r\n\r\n var vertexes = new utils.Float32Array([4.0, -1.0, -1.0, 4.0, -1.0, -1.0]);\r\n var buffer = new BufferArray(BufferArray.ARRAY_BUFFER, vertexes, 2);\r\n // Further optim: (uv.xy = position.xy in vertex shader)\r\n g.getAttributes().Vertex = buffer;\r\n g.getAttributes().TexCoord0 = buffer;\r\n\r\n var primitive = new DrawArrays(primitiveSet.TRIANGLES, 0, 3);\r\n g.getPrimitives().push(primitive);\r\n return g\r\n }\r\n \r\n\r\n return function(scope) {\r\n if(!scopes[scope]) {\r\n scopes[scope] = newQuad()\r\n }\r\n return scopes[scope]\r\n };\r\n})();\r\n\r\nvar createTexturedQuadGeometry = function(\r\n cornerx,\r\n cornery,\r\n cornerz,\r\n wx,\r\n wy,\r\n wz,\r\n hx,\r\n hy,\r\n hz,\r\n l,\r\n b,\r\n r,\r\n t\r\n) {\r\n if (r === undefined && t === undefined) {\r\n r = l;\r\n t = b;\r\n l = 0.0;\r\n b = 0.0;\r\n }\r\n\r\n var g = new Geometry();\r\n\r\n var vertexes = new utils.Float32Array(12);\r\n vertexes[0] = cornerx + hx;\r\n vertexes[1] = cornery + hy;\r\n vertexes[2] = cornerz + hz;\r\n\r\n vertexes[3] = cornerx;\r\n vertexes[4] = cornery;\r\n vertexes[5] = cornerz;\r\n\r\n vertexes[6] = cornerx + wx;\r\n vertexes[7] = cornery + wy;\r\n vertexes[8] = cornerz + wz;\r\n\r\n vertexes[9] = cornerx + wx + hx;\r\n vertexes[10] = cornery + wy + hy;\r\n vertexes[11] = cornerz + wz + hz;\r\n\r\n if (r === undefined) {\r\n r = 1.0;\r\n }\r\n if (t === undefined) {\r\n t = 1.0;\r\n }\r\n\r\n var uvs = new utils.Float32Array(8);\r\n uvs[0] = l;\r\n uvs[1] = t;\r\n\r\n uvs[2] = l;\r\n uvs[3] = b;\r\n\r\n uvs[4] = r;\r\n uvs[5] = b;\r\n\r\n uvs[6] = r;\r\n uvs[7] = t;\r\n\r\n var n = vec3.fromValues(wx, wy, wz);\r\n vec3.cross(n, n, vec3.fromValues(hx, hy, hz));\r\n vec3.normalize(n, n);\r\n\r\n var normal = new utils.Float32Array(12);\r\n normal[0] = n[0];\r\n normal[1] = n[1];\r\n normal[2] = n[2];\r\n\r\n normal[3] = n[0];\r\n normal[4] = n[1];\r\n normal[5] = n[2];\r\n\r\n normal[6] = n[0];\r\n normal[7] = n[1];\r\n normal[8] = n[2];\r\n\r\n normal[9] = n[0];\r\n normal[10] = n[1];\r\n normal[11] = n[2];\r\n\r\n var indexes = new utils.Uint16Array(6);\r\n indexes[0] = 0;\r\n indexes[1] = 1;\r\n indexes[2] = 2;\r\n indexes[3] = 0;\r\n indexes[4] = 2;\r\n indexes[5] = 3;\r\n\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertexes, 3);\r\n g.getAttributes().Normal = new BufferArray(BufferArray.ARRAY_BUFFER, normal, 3);\r\n g.getAttributes().TexCoord0 = new BufferArray(BufferArray.ARRAY_BUFFER, uvs, 2);\r\n\r\n var primitive = new DrawElements(\r\n primitiveSet.TRIANGLES,\r\n new BufferArray(BufferArray.ELEMENT_ARRAY_BUFFER, indexes, 1)\r\n );\r\n g.getPrimitives().push(primitive);\r\n return g;\r\n};\r\n\r\nvar createAxisGeometry = function(size) {\r\n if (size === undefined) {\r\n size = 1.0;\r\n }\r\n if (createAxisGeometry.getShader === undefined) {\r\n createAxisGeometry.getShader = function() {\r\n if (createAxisGeometry.getShader.program === undefined) {\r\n var vertexshader = [\r\n '#ifdef GL_ES',\r\n 'precision highp float;',\r\n '#endif',\r\n 'attribute vec3 Vertex;',\r\n 'attribute vec4 Color;',\r\n 'uniform mat4 uModelViewMatrix;',\r\n 'uniform mat4 uProjectionMatrix;',\r\n '',\r\n 'varying vec4 vColor;',\r\n '',\r\n 'void main(void) {',\r\n ' gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0));',\r\n ' vColor = Color;',\r\n '}'\r\n ].join('\\n');\r\n\r\n var fragmentshader = [\r\n '#ifdef GL_ES',\r\n 'precision highp float;',\r\n '#endif',\r\n 'varying vec4 vColor;',\r\n\r\n 'void main(void) {',\r\n 'gl_FragColor = vColor;',\r\n '}'\r\n ].join('\\n');\r\n\r\n var program = new Program(\r\n new Shader('VERTEX_SHADER', vertexshader),\r\n new Shader('FRAGMENT_SHADER', fragmentshader)\r\n );\r\n createAxisGeometry.getShader.program = program;\r\n }\r\n return createAxisGeometry.getShader.program;\r\n };\r\n }\r\n\r\n var g = new Geometry();\r\n\r\n var vertexes = new utils.Float32Array(18);\r\n vertexes[3] = size;\r\n vertexes[10] = size;\r\n vertexes[17] = size;\r\n\r\n var colors = new utils.Float32Array(24);\r\n //red color\r\n colors[0] = colors[3] = 1.0;\r\n colors[4] = colors[4 + 3] = 1.0;\r\n //green color\r\n colors[4 * 2 + 1] = colors[4 * 2 + 3] = 1.0;\r\n colors[4 * 3 + 1] = colors[4 * 3 + 3] = 1.0;\r\n //blue color\r\n colors[4 * 4 + 2] = colors[4 * 4 + 3] = 1.0;\r\n colors[4 * 5 + 2] = colors[4 * 5 + 3] = 1.0;\r\n\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertexes, 3);\r\n g.getAttributes().Color = new BufferArray(BufferArray.ARRAY_BUFFER, colors, 4);\r\n\r\n var primitive = new DrawArrays(primitiveSet.LINES, 0, 6);\r\n g.getPrimitives().push(primitive);\r\n g.getOrCreateStateSet().setAttributeAndModes(createAxisGeometry.getShader());\r\n\r\n return g;\r\n};\r\n\r\n/**\r\n * Create a Textured Sphere on the given center with given radius\r\n * @name createTexturedSphere\r\n * @author Darrell Esau\r\n */\r\nvar createTexturedSphere = function(\r\n radius,\r\n widthSegments,\r\n heightSegments,\r\n phiStart,\r\n phiLength,\r\n thetaStart,\r\n thetaLength\r\n) {\r\n radius = radius || 1.0;\r\n\r\n phiStart = phiStart !== undefined ? phiStart : 0.0;\r\n phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;\r\n\r\n thetaStart = thetaStart !== undefined ? thetaStart : 0.0;\r\n thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;\r\n\r\n var segmentsX = Math.max(3, Math.floor(widthSegments) || 8);\r\n var segmentsY = Math.max(2, Math.floor(heightSegments) || 6);\r\n\r\n var useDrawArrays = segmentsX * segmentsY / 3 >= 65536;\r\n var nbPrim = useDrawArrays ? segmentsX * segmentsY * 6 : segmentsX * segmentsY * 4;\r\n var fullVerticesList = new utils.Float32Array(nbPrim * 3);\r\n var fullNormalsList = new utils.Float32Array(nbPrim * 3);\r\n var fullUVList = new utils.Float32Array(nbPrim * 2);\r\n var indexes = !useDrawArrays ? new utils.Uint16Array(segmentsX * segmentsY * 6) : undefined;\r\n var vtxCount = 0;\r\n var triCount = 0;\r\n\r\n var v1 = new utils.Float32Array(3);\r\n var v2 = new utils.Float32Array(3);\r\n var v3 = new utils.Float32Array(3);\r\n var v4 = new utils.Float32Array(3);\r\n var n1 = new utils.Float32Array(3);\r\n var n2 = new utils.Float32Array(3);\r\n var n3 = new utils.Float32Array(3);\r\n var n4 = new utils.Float32Array(3);\r\n var uv1 = new utils.Float32Array(2);\r\n var uv2 = new utils.Float32Array(2);\r\n var uv3 = new utils.Float32Array(2);\r\n var uv4 = new utils.Float32Array(2);\r\n var getCoordAndUvSphere = function(u, v, coord, norm, uv) {\r\n coord[0] = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\r\n coord[1] = radius * Math.cos(thetaStart + v * thetaLength);\r\n coord[2] =\r\n radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\r\n vec3.normalize(norm, coord);\r\n uv[0] = u;\r\n uv[1] = 1 - v;\r\n };\r\n for (var y = 0; y < segmentsY; y++) {\r\n for (var x = 0; x < segmentsX; x++) {\r\n getCoordAndUvSphere((x + 1) / segmentsX, y / segmentsY, v1, n1, uv1);\r\n getCoordAndUvSphere(x / segmentsX, y / segmentsY, v2, n2, uv2);\r\n getCoordAndUvSphere(x / segmentsX, (y + 1) / segmentsY, v3, n3, uv3);\r\n getCoordAndUvSphere((x + 1) / segmentsX, (y + 1) / segmentsY, v4, n4, uv4);\r\n\r\n var idv = vtxCount * 3;\r\n fullVerticesList[idv] = v1[0];\r\n fullVerticesList[idv + 1] = v1[1];\r\n fullVerticesList[idv + 2] = v1[2];\r\n fullVerticesList[idv + 3] = v2[0];\r\n fullVerticesList[idv + 4] = v2[1];\r\n fullVerticesList[idv + 5] = v2[2];\r\n fullVerticesList[idv + 6] = v3[0];\r\n fullVerticesList[idv + 7] = v3[1];\r\n fullVerticesList[idv + 8] = v3[2];\r\n\r\n fullNormalsList[idv] = n1[0];\r\n fullNormalsList[idv + 1] = n1[1];\r\n fullNormalsList[idv + 2] = n1[2];\r\n fullNormalsList[idv + 3] = n2[0];\r\n fullNormalsList[idv + 4] = n2[1];\r\n fullNormalsList[idv + 5] = n2[2];\r\n fullNormalsList[idv + 6] = n3[0];\r\n fullNormalsList[idv + 7] = n3[1];\r\n fullNormalsList[idv + 8] = n3[2];\r\n\r\n var idu = vtxCount * 2;\r\n fullUVList[idu] = uv1[0];\r\n fullUVList[idu + 1] = uv1[1];\r\n fullUVList[idu + 2] = uv2[0];\r\n fullUVList[idu + 3] = uv2[1];\r\n fullUVList[idu + 4] = uv3[0];\r\n fullUVList[idu + 5] = uv3[1];\r\n\r\n vtxCount += 3;\r\n if (useDrawArrays) {\r\n idv = vtxCount * 3;\r\n fullVerticesList[idv] = v1[0];\r\n fullVerticesList[idv + 1] = v1[1];\r\n fullVerticesList[idv + 2] = v1[2];\r\n fullVerticesList[idv + 3] = v3[0];\r\n fullVerticesList[idv + 4] = v3[1];\r\n fullVerticesList[idv + 5] = v3[2];\r\n fullVerticesList[idv + 6] = v4[0];\r\n fullVerticesList[idv + 7] = v4[1];\r\n fullVerticesList[idv + 8] = v4[2];\r\n\r\n fullNormalsList[idv] = n1[0];\r\n fullNormalsList[idv + 1] = n1[1];\r\n fullNormalsList[idv + 2] = n1[2];\r\n fullNormalsList[idv + 3] = n3[0];\r\n fullNormalsList[idv + 4] = n3[1];\r\n fullNormalsList[idv + 5] = n3[2];\r\n fullNormalsList[idv + 6] = n4[0];\r\n fullNormalsList[idv + 7] = n4[1];\r\n fullNormalsList[idv + 8] = n4[2];\r\n\r\n idu = vtxCount * 2;\r\n fullUVList[idu] = uv1[0];\r\n fullUVList[idu + 1] = uv1[1];\r\n fullUVList[idu + 2] = uv3[0];\r\n fullUVList[idu + 3] = uv3[1];\r\n fullUVList[idu + 4] = uv4[0];\r\n fullUVList[idu + 5] = uv4[1];\r\n vtxCount += 3;\r\n } else {\r\n idv = vtxCount * 3;\r\n fullVerticesList[idv] = v4[0];\r\n fullVerticesList[idv + 1] = v4[1];\r\n fullVerticesList[idv + 2] = v4[2];\r\n\r\n fullNormalsList[idv] = n4[0];\r\n fullNormalsList[idv + 1] = n4[1];\r\n fullNormalsList[idv + 2] = n4[2];\r\n\r\n idu = vtxCount * 2;\r\n fullUVList[idu] = uv4[0];\r\n fullUVList[idu + 1] = uv4[1];\r\n\r\n var iStart = triCount * 3;\r\n var tristart = vtxCount - 3;\r\n indexes[iStart] = tristart;\r\n indexes[iStart + 1] = tristart + 1;\r\n indexes[iStart + 2] = tristart + 2;\r\n indexes[iStart + 3] = tristart;\r\n indexes[iStart + 4] = tristart + 2;\r\n indexes[iStart + 5] = tristart + 3;\r\n triCount += 2;\r\n vtxCount += 1;\r\n }\r\n }\r\n }\r\n\r\n var g = new Geometry();\r\n g.getAttributes().Vertex = new BufferArray('ARRAY_BUFFER', fullVerticesList, 3);\r\n g.getAttributes().Normal = new BufferArray('ARRAY_BUFFER', fullNormalsList, 3);\r\n g.getAttributes().TexCoord0 = new BufferArray('ARRAY_BUFFER', fullUVList, 2);\r\n\r\n if (useDrawArrays)\r\n g\r\n .getPrimitives()\r\n .push(new DrawArrays(primitiveSet.TRIANGLES, 0, fullVerticesList.length / 3));\r\n else\r\n g\r\n .getPrimitives()\r\n .push(\r\n new DrawElements(\r\n primitiveSet.TRIANGLES,\r\n new BufferArray('ELEMENT_ARRAY_BUFFER', indexes, 1)\r\n )\r\n );\r\n return g;\r\n};\r\n\r\nvar createGridGeometry = function(cx, cy, cz, wx, wy, wz, hx, hy, hz, res1, res2) {\r\n cx = cx !== undefined ? cx : -0.5;\r\n cy = cy !== undefined ? cy : -0.5;\r\n cz = cz !== undefined ? cz : 0.0;\r\n\r\n wx = wx !== undefined ? wx : 1.0;\r\n wy = wy !== undefined ? wy : 0.0;\r\n wz = wz !== undefined ? wz : 0.0;\r\n\r\n hx = hx !== undefined ? hx : 0.0;\r\n hy = hy !== undefined ? hy : 1.0;\r\n hz = hz !== undefined ? hz : 0.0;\r\n\r\n res1 = res1 !== undefined ? res1 : 5;\r\n res2 = res2 !== undefined ? res2 : res1;\r\n res1 += 2;\r\n res2 += 2;\r\n\r\n var g = new Geometry();\r\n var vertices = new Float32Array((res1 + res2) * 2 * 3);\r\n var i = 0;\r\n var j = 0;\r\n var sx = wx / (res1 - 1);\r\n var sy = wy / (res1 - 1);\r\n var sz = wz / (res1 - 1);\r\n var ux = cx + wx + hx;\r\n var uy = cy + wy + hy;\r\n var uz = cz + wz + hz;\r\n for (i = 0; i < res1; ++i) {\r\n j = i * 6;\r\n vertices[j] = cx + sx * i;\r\n vertices[j + 1] = cy + sy * i;\r\n vertices[j + 2] = cz + sz * i;\r\n vertices[j + 3] = ux - sx * (res1 - i - 1);\r\n vertices[j + 4] = uy - sy * (res1 - i - 1);\r\n vertices[j + 5] = uz - sz * (res1 - i - 1);\r\n }\r\n sx = hx / (res2 - 1);\r\n sy = hy / (res2 - 1);\r\n sz = hz / (res2 - 1);\r\n for (i = 0; i < res2; ++i) {\r\n j = (res1 + i) * 6;\r\n vertices[j] = cx + sx * i;\r\n vertices[j + 1] = cy + sy * i;\r\n vertices[j + 2] = cz + sz * i;\r\n vertices[j + 3] = ux - sx * (res2 - i - 1);\r\n vertices[j + 4] = uy - sy * (res2 - i - 1);\r\n vertices[j + 5] = uz - sz * (res2 - i - 1);\r\n }\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n var primitive = new DrawArrays(primitiveSet.LINES, 0, (res1 + res2) * 2);\r\n g.getPrimitives().push(primitive);\r\n return g;\r\n};\r\n\r\n/*\r\n * debug lines showing bounding box abstraction\r\n * @param col bbox color\r\n */\r\nvar createBoundingBoxGeometry = function(col) {\r\n var g = new Geometry();\r\n //unit cube centered on 0\r\n var vertices = new Float32Array([-0.5, -0.5, -0.5,\r\n 0.5, -0.5, -0.5,\r\n 0.5,\r\n 0.5, -0.5, -0.5,\r\n 0.5, -0.5, -0.5, -0.5,\r\n 0.5,\r\n 0.5, -0.5,\r\n 0.5,\r\n 0.5,\r\n 0.5,\r\n 0.5, -0.5,\r\n 0.5,\r\n 0.5\r\n ]);\r\n g.getAttributes().Vertex = new BufferArray(BufferArray.ARRAY_BUFFER, vertices, 3);\r\n\r\n // use color or red\r\n if (!col) col = [1.0, 0.0, 0.0, 1.0];\r\n var colors = new utils.Float32Array(8 * 4);\r\n for (var i = 0; i < 8; i++) {\r\n for (var k = 0; k < 4; k++) {\r\n colors[i * 3 + k] = col[k];\r\n }\r\n }\r\n\r\n g.getAttributes().Color = new BufferArray(BufferArray.ARRAY_BUFFER, colors, 4);\r\n\r\n var indexes = new utils.Uint16Array([\r\n //up\r\n 0,\r\n 1,\r\n 1,\r\n 2,\r\n 2,\r\n 3,\r\n 3,\r\n 0,\r\n //down\r\n 4,\r\n 5,\r\n 5,\r\n 6,\r\n 6,\r\n 7,\r\n 7,\r\n 4,\r\n // side\r\n 0,\r\n 4,\r\n 1,\r\n 5,\r\n 2,\r\n 6,\r\n 3,\r\n 7\r\n ]);\r\n\r\n g\r\n .getPrimitives()\r\n .push(\r\n new DrawElements(\r\n primitiveSet.LINES,\r\n new BufferArray('ELEMENT_ARRAY_BUFFER', indexes, 1)\r\n )\r\n );\r\n\r\n return g;\r\n};\r\n\r\nexport default {\r\n createTexturedBoxGeometry: createTexturedBoxGeometry,\r\n createTexturedQuadGeometry: createTexturedQuadGeometry,\r\n createTexturedSphereGeometry: createTexturedSphere,\r\n createTexturedFullScreenFakeQuadGeometry: createTexturedFullScreenFakeQuadGeometry,\r\n createAxisGeometry: createAxisGeometry,\r\n createTexturedSphere: createTexturedSphere,\r\n createGridGeometry: createGridGeometry,\r\n createBoundingBoxGeometry: createBoundingBoxGeometry\r\n};","// jshint ignore: start\r\n\r\n/*\r\n * Copyright 2010, Google Inc.\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are\r\n * met:\r\n *\r\n * * Redistributions of source code must retain the above copyright\r\n * notice, this list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above\r\n * copyright notice, this list of conditions and the following disclaimer\r\n * in the documentation and/or other materials provided with the\r\n * distribution.\r\n * * Neither the name of Google Inc. nor the names of its\r\n * contributors may be used to endorse or promote products derived from\r\n * this software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @fileoverview This file contains functions every webgl program will need\r\n * a version of one way or another.\r\n *\r\n * Instead of setting up a context manually it is recommended to\r\n * use. This will check for success or failure. On failure it\r\n * will attempt to present an approriate message to the user.\r\n *\r\n * gl = WebGLUtils.setupWebGL(canvas);\r\n *\r\n * For animated WebGL apps use of setTimeout or setInterval are\r\n * discouraged. It is recommended you structure your rendering\r\n * loop like this.\r\n *\r\n * function render() {\r\n * window.requestAnimationFrame(render, canvas);\r\n *\r\n * // do rendering\r\n * ...\r\n * }\r\n * render();\r\n *\r\n * This will call your rendering function up to the refresh rate\r\n * of your display but will stop rendering if your app is not\r\n * visible.\r\n */\r\n\r\nvar WebGLUtils = (function() {\r\n /**\r\n * Creates the HTLM for a failure message\r\n * @param {string} canvasContainerId id of container of th\r\n * canvas.\r\n * @return {string} The html.\r\n */\r\n var makeFailHTML = function(msg) {\r\n return (\r\n '' +\r\n '<div style=\"margin: auto; width:500px;z-index:10000;margin-top:20em;text-align:center;\">' +\r\n msg +\r\n '</div>'\r\n );\r\n // return '' +\r\n // '<table style=\"background-color: #8CE; width: 100%; height: 100%;\"><tr>' +\r\n // '<td align=\"center\">' +\r\n // '<div style=\"display: table-cell; vertical-align: middle;\">' +\r\n // '<div style=\"\">' + msg + '</div>' +\r\n // '</div>' +\r\n // '</td></tr></table>';\r\n };\r\n\r\n /**\r\n * Mesasge for getting a webgl browser\r\n * @type {string}\r\n */\r\n var GET_A_WEBGL_BROWSER =\r\n '' +\r\n 'This page requires a browser that supports WebGL.<br/>' +\r\n '<a href=\"http://get.webgl.org\">Click here to upgrade your browser.</a>';\r\n\r\n /**\r\n * Mesasge for need better hardware\r\n * @type {string}\r\n */\r\n var OTHER_PROBLEM =\r\n '' +\r\n \"It doesn't appear your computer can support WebGL.<br/>\" +\r\n '<a href=\"http://get.webgl.org\">Click here for more information.</a>';\r\n\r\n /*\r\n * Allows to prevent the global canvas error code on webgl2\r\n * as we still have to check if we can fallback on webgl1\r\n */\r\n var doReportCreationError = true;\r\n /**\r\n * Creates a webgl context. If creation fails it will\r\n * change the contents of the container of the <canvas>\r\n * tag to an error message with the correct links for WebGL.\r\n * @return {WebGLRenderingContext} The created context.\r\n */\r\n var setupWebGL = function(\r\n /** Element */\r\n canvas,\r\n /** WebGLContextCreationAttributes */\r\n opt_attribs,\r\n /** function:(msg) */\r\n opt_onError\r\n ) {\r\n function handleCreationError(msg) {\r\n if (!doReportCreationError) return;\r\n var container = document.getElementsByTagName('body')[0];\r\n //var container = canvas.parentNode;\r\n if (container) {\r\n var str = window.WebGLRenderingContext ? OTHER_PROBLEM : GET_A_WEBGL_BROWSER;\r\n if (msg) {\r\n str += '<br/><br/>Status: ' + msg;\r\n }\r\n container.innerHTML = makeFailHTML(str);\r\n }\r\n }\r\n\r\n opt_onError = opt_onError || handleCreationError;\r\n\r\n if (canvas.addEventListener) {\r\n canvas.addEventListener(\r\n 'webglcontextcreationerror',\r\n function(event) {\r\n opt_onError(event.statusMessage);\r\n },\r\n false\r\n );\r\n }\r\n var context = create3DContext(canvas, opt_attribs);\r\n if (!context) {\r\n //if ( !window.WebGLRenderingContext )\r\n opt_onError('');\r\n }\r\n\r\n return context;\r\n };\r\n\r\n /**\r\n * try to creaate webgl contexts\r\n * @param {Canvas} canvas The canvas tag to get context\r\n * @param {opt_attribs} webgl context options\r\n * @param {names} list of webgl context type to try\r\n * @return {!WebGLContext} The created context.\r\n */\r\n var checkAndCreate3DContext = function(canvas, opt_attribs, names) {\r\n var context = null;\r\n for (var ii = 0; ii < names.length; ++ii) {\r\n try {\r\n context = canvas.getContext(names[ii], opt_attribs);\r\n } catch (e) {}\r\n if (context) {\r\n break;\r\n }\r\n }\r\n return context;\r\n };\r\n\r\n /**\r\n * Creates a webgl context.\r\n * @param !Canvas} canvas The canvas tag to get context\r\n * @param {!opt_attribs} webgl context options\r\n * @return {!WebGLContext} The created context.\r\n */\r\n var create3DContext = function(canvas, opt_attribs) {\r\n var context;\r\n // only try to enable if URl options ?webgl2=1\r\n if (opt_attribs && opt_attribs.webgl2) {\r\n doReportCreationError = false;\r\n context = checkAndCreate3DContext(canvas, opt_attribs, [\r\n 'webgl2',\r\n 'experimental-webgl2'\r\n ]);\r\n if (context) return context;\r\n doReportCreationError = true;\r\n }\r\n return checkAndCreate3DContext(canvas, opt_attribs, [\r\n 'webgl',\r\n 'experimental-webgl',\r\n 'webkit-3d',\r\n 'moz-webgl'\r\n ]);\r\n };\r\n\r\n return {\r\n create3DContext: create3DContext,\r\n setupWebGL: setupWebGL\r\n };\r\n})();\r\n\r\n/**\r\n * Provides requestAnimationFrame in a cross browser\r\n * way.\r\n */\r\nif (!window.requestAnimationFrame) {\r\n window.requestAnimationFrame = (function() {\r\n return (\r\n window.requestAnimationFrame ||\r\n window.webkitRequestAnimationFrame ||\r\n window.mozRequestAnimationFrame ||\r\n window.oRequestAnimationFrame ||\r\n window.msRequestAnimationFrame ||\r\n function(\r\n /* function FrameRequestCallback */ callback,\r\n /* DOMElement Element */ element\r\n ) {\r\n window.setTimeout(callback, 1000 / 60);\r\n }\r\n );\r\n })();\r\n}\r\n\r\nif (!window.cancelRequestAnimFrame) {\r\n window.cancelAnimationFrame = (function() {\r\n return (\r\n window.cancelAnimationFrame ||\r\n window.webkitCancelRequestAnimationFrame ||\r\n window.mozCancelRequestAnimationFrame ||\r\n window.oCancelRequestAnimationFrame ||\r\n window.msCancelRequestAnimationFrame ||\r\n clearTimeout\r\n );\r\n })();\r\n}\r\n\r\nif (!Date.now) {\r\n Date.now = function now() {\r\n return new Date().getTime();\r\n };\r\n}\r\n\r\nexport default WebGLUtils;\r\n","import notify from './notify';\r\nimport WebGLCaps from './WebGLCaps';\r\n\r\n/*\r\nuse EXT_disjoint_timer_queryto time webgl calls GPU side average over multiple frames\r\n\r\nIf timestamp feature is not supported, we virtualize the query by splitting and adding\r\ndummy queries, that way it should handle both nested and interleaved queries.\r\n\r\nAlso, if you time the same queryID multiple time in the same frame, it will sum the different\r\nqueries, that way you can track a particular of gl command for examples\r\n\r\n*/\r\n\r\nvar TimerGPU = function(gl) {\r\n this._enabled = false;\r\n this.reset(gl);\r\n};\r\n\r\nTimerGPU.FRAME_COUNT = 0;\r\n\r\nTimerGPU.instance = function(gl, force) {\r\n if (!TimerGPU._instance) {\r\n TimerGPU._instance = new TimerGPU(gl);\r\n } else if (gl && (TimerGPU._instance.getContext() !== gl || force)) {\r\n TimerGPU._instance.setContext(gl);\r\n TimerGPU._instance.reset(gl);\r\n }\r\n return TimerGPU._instance;\r\n};\r\n\r\nTimerGPU.prototype = {\r\n reset: function(gl) {\r\n if (gl) {\r\n var ext = WebGLCaps.instance(gl).getDisjointTimerQuery();\r\n if (!ext) return this;\r\n\r\n // webgl1 to webgl2\r\n if (!gl.getQueryParameter) gl.getQueryParameter = ext.getQueryObjectEXT.bind(ext);\r\n\r\n // https://github.com/KhronosGroup/WebGL/blob/master/sdk/tests/conformance/extensions/ext-disjoint-timer-query.html#L102\r\n // run the page if strange results\r\n // to validate you gpu/browser has correct gpu queries support\r\n this._hasTimeElapsed =\r\n gl.getQuery(ext.TIME_ELAPSED_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30;\r\n this._hasTimeStamp = gl.getQuery(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT) >= 30;\r\n\r\n if (!this._hasTimeElapsed && !this._hasTimeStamp) {\r\n return this;\r\n }\r\n\r\n // no timestamp means not start/end absolute time\r\n // which means each start must be followed by a end\r\n // BEFORE any other start (of other queryID)\r\n if (!this._hasTimeStamp) notify.debug('Warning: do not use interleaved GPU query');\r\n\r\n this._ext = ext;\r\n this._gl = gl;\r\n this._enabled = true;\r\n }\r\n\r\n this._frameAverageCount = 10;\r\n\r\n this._glQueries = [];\r\n this._queriesByID = {};\r\n this._userQueries = []; // for timestamp, it's the same as _glQueries\r\n\r\n // stuffs used to virtualize query (no timestamp)\r\n this._queryCount = 0;\r\n this._nbOpened = 0;\r\n },\r\n getContext: function() {\r\n return this._gl;\r\n },\r\n setContext: function(gl) {\r\n this._gl = gl;\r\n },\r\n setFrameAverageCount: function(val) {\r\n this._frameAverageCount = val;\r\n },\r\n\r\n clearQueries: function() {\r\n var glQueries = this._glQueries;\r\n for (var i = 0, nbQueries = glQueries.length; i < nbQueries; ++i) {\r\n var query = glQueries[i];\r\n this._gl.deleteQuery(query._pollingStartQuery);\r\n if (query._pollingEndQuery) this._gl.deleteQuery(query);\r\n }\r\n\r\n this._userQueries.length = 0;\r\n this._glQueries.length = 0;\r\n this._queriesByID = {};\r\n },\r\n\r\n supportTimeStamp: function() {\r\n return this._hasTimeStamp;\r\n },\r\n\r\n // many browser doesn't yet have\r\n // the marvellous gpu timers\r\n enable: function() {\r\n // enable only if we have the extension\r\n this._enabled = !!this._ext;\r\n },\r\n\r\n disable: function() {\r\n this._enabled = false;\r\n },\r\n isEnabled: function() {\r\n return this._enabled;\r\n },\r\n\r\n setCallback: function(cb) {\r\n this._callback = cb;\r\n },\r\n\r\n createUserQuery: function(queryID) {\r\n var query;\r\n if (this._hasTimeStamp) {\r\n query = this.createGLQuery();\r\n } else {\r\n query = {\r\n _startIndex: 0,\r\n _endIndex: 0\r\n };\r\n }\r\n\r\n query._id = queryID;\r\n query._frame = TimerGPU.FRAME_COUNT;\r\n query._isOpened = true;\r\n query._siblings = []; // if the query is called multiple time in the same frame\r\n\r\n return query;\r\n },\r\n\r\n createGLQuery: function() {\r\n var query = {};\r\n query._isWaiting = false; // wait typically 1 or 2 frames\r\n query._pollingStartQuery = undefined; // gl query object\r\n query._pollingEndQuery = undefined; // gl query object (timestamp only)\r\n query._averageTimer = 0.0; // cumulative average time\r\n query._resultCount = 0; // cumulative average count\r\n\r\n if (this._hasTimeStamp) query._pollingEndQuery = this._gl.createQuery();\r\n query._pollingStartQuery = this._gl.createQuery();\r\n\r\n this._glQueries.push(query);\r\n\r\n return query;\r\n },\r\n\r\n getOrCreateLastGLQuery: function() {\r\n var query = this._glQueries[this._queryCount - 1];\r\n if (query) return query;\r\n\r\n query = this._glQueries[this._queryCount - 1] = this.createGLQuery();\r\n\r\n return query;\r\n },\r\n\r\n beginCurrentQuery: function() {\r\n if (this._nbOpened === 0) return;\r\n\r\n this._queryCount++;\r\n\r\n var query = this.getOrCreateLastGLQuery();\r\n if (!query._isWaiting) {\r\n this._gl.beginQuery(this._ext.TIME_ELAPSED_EXT, query._pollingStartQuery);\r\n }\r\n },\r\n\r\n endCurrentQuery: function() {\r\n if (this._nbOpened === 0) return;\r\n\r\n if (!this.getOrCreateLastGLQuery()._isWaiting) {\r\n this._gl.endQuery(this._ext.TIME_ELAPSED_EXT);\r\n }\r\n },\r\n\r\n getAvailableQueryByID: function(queryID) {\r\n var query = this._queriesByID[queryID];\r\n if (!query) {\r\n query = this._queriesByID[queryID] = this.createUserQuery(queryID);\r\n this._userQueries.push(query);\r\n return query;\r\n }\r\n\r\n if (query._frame === TimerGPU.FRAME_COUNT) {\r\n if (query._isOpened) return query;\r\n\r\n var siblings = query._siblings;\r\n for (var i = 0, nbSiblings = siblings.length; i < nbSiblings; ++i) {\r\n var qsib = siblings[i];\r\n if (qsib._frame !== TimerGPU.FRAME_COUNT || qsib._isOpened) {\r\n qsib._frame = TimerGPU.FRAME_COUNT;\r\n return qsib;\r\n }\r\n }\r\n\r\n var newQuery = this.createUserQuery();\r\n siblings.push(newQuery);\r\n return newQuery;\r\n }\r\n\r\n query._frame = TimerGPU.FRAME_COUNT;\r\n\r\n return query;\r\n },\r\n\r\n // start recording time if query already exist, don't recreate\r\n start: function(queryID) {\r\n // If timing currently disabled or glTimer does not exist, exit early.\r\n if (!this._enabled) {\r\n return undefined;\r\n }\r\n\r\n var query = this.getAvailableQueryByID(queryID);\r\n query._isOpened = true;\r\n\r\n if (this._hasTimeStamp) {\r\n if (!query._isWaiting)\r\n this._ext.queryCounterEXT(query._pollingStartQuery, this._ext.TIMESTAMP_EXT);\r\n } else {\r\n this.endCurrentQuery();\r\n\r\n this._nbOpened++;\r\n query._startIndex = this._queryCount;\r\n\r\n this.beginCurrentQuery();\r\n }\r\n },\r\n\r\n // stop query recording (if running) polls for results\r\n end: function(queryID) {\r\n if (!this._enabled) {\r\n return;\r\n }\r\n\r\n var query = this.getAvailableQueryByID(queryID);\r\n query._isOpened = false;\r\n\r\n if (this._hasTimeStamp) {\r\n if (!query._isWaiting)\r\n this._ext.queryCounterEXT(query._pollingEndQuery, this._ext.TIMESTAMP_EXT);\r\n } else {\r\n this.endCurrentQuery();\r\n\r\n query._endIndex = this._queryCount;\r\n this._nbOpened--;\r\n\r\n this.beginCurrentQuery();\r\n }\r\n },\r\n\r\n computeQueryAverageTime: function(query) {\r\n var average = 0;\r\n var glQueries = this._glQueries;\r\n\r\n for (var i = query._startIndex; i < query._endIndex; ++i) {\r\n var glAvg = glQueries[i]._averageTimer;\r\n if (glAvg < 0) return -1;\r\n average += glAvg;\r\n }\r\n\r\n return average;\r\n },\r\n\r\n computeFullAverageTime: function(query) {\r\n var average = this.computeQueryAverageTime(query);\r\n\r\n if (average < 0) return -1;\r\n\r\n var siblings = query._siblings;\r\n for (var i = 0, nbSiblings = siblings.length; i < nbSiblings; ++i) {\r\n var qsib = siblings[i];\r\n if (qsib._frame !== TimerGPU.FRAME_COUNT - 1) continue;\r\n\r\n var sibAvg = this.computeQueryAverageTime(qsib);\r\n if (sibAvg < 0) return -1;\r\n average += sibAvg;\r\n }\r\n\r\n return average;\r\n },\r\n\r\n pollQueries: function() {\r\n TimerGPU.FRAME_COUNT++;\r\n this._queryCount = 0;\r\n this._nbOpened = 0;\r\n\r\n if (!this._enabled || !this._callback) {\r\n return;\r\n }\r\n\r\n var glQueries = this._glQueries;\r\n var nbGlQueries = glQueries.length;\r\n var i;\r\n\r\n // all timer are corrupted, clear the queries\r\n var disjoint = this._gl.getParameter(this._ext.GPU_DISJOINT_EXT);\r\n if (disjoint) {\r\n for (i = 0; i < nbGlQueries; ++i) {\r\n glQueries[i]._isWaiting = false;\r\n }\r\n return;\r\n }\r\n\r\n // update average time for each queries\r\n for (i = 0; i < nbGlQueries; ++i) {\r\n this.pollQuery(glQueries[i]);\r\n }\r\n\r\n var userQueries = this._userQueries;\r\n var nbUserQueries = userQueries.length;\r\n\r\n for (i = 0; i < nbUserQueries; ++i) {\r\n var query = userQueries[i];\r\n var average = this.computeFullAverageTime(query);\r\n if (average > 0) {\r\n this._callback(average, query._id);\r\n }\r\n }\r\n },\r\n\r\n pollQuery: function(query) {\r\n query._isWaiting = false;\r\n\r\n // last to be queried\r\n var lastQuery = this._hasTimeStamp ? query._pollingEndQuery : query._pollingStartQuery;\r\n\r\n // wait till results are ready\r\n var available = this._gl.getQueryParameter(lastQuery, this._gl.QUERY_RESULT_AVAILABLE);\r\n if (!available) {\r\n query._isWaiting = true;\r\n return 0;\r\n }\r\n\r\n var timeElapsed;\r\n\r\n if (this._hasTimeStamp) {\r\n var startTime = this._gl.getQueryParameter(\r\n query._pollingStartQuery,\r\n this._gl.QUERY_RESULT\r\n );\r\n var endTime = this._gl.getQueryParameter(lastQuery, this._gl.QUERY_RESULT);\r\n timeElapsed = endTime - startTime;\r\n } else {\r\n timeElapsed = this._gl.getQueryParameter(lastQuery, this._gl.QUERY_RESULT);\r\n }\r\n\r\n query._resultCount++;\r\n\r\n // restart cumulative average every frameAveragecount frames\r\n if (query._resultCount > this._frameAverageCount) {\r\n query._averageTimer = 0.0;\r\n query._resultCount = 1;\r\n }\r\n\r\n // https://en.wikipedia.org/wiki/Moving_average#Cumulative_moving_average\r\n query._averageTimer =\r\n query._averageTimer + (timeElapsed - query._averageTimer) / query._resultCount;\r\n\r\n return query._averageTimer;\r\n }\r\n};\r\n\r\nexport default TimerGPU;","import BufferArray from './BufferArray';\r\n\r\nvar BufferArrayProxy = function(bufferArray) {\r\n this._initialBufferArray = undefined;\r\n this._bufferArray = undefined;\r\n if (bufferArray) {\r\n this.setBufferArray(bufferArray);\r\n this.setInitialBufferArray(bufferArray);\r\n }\r\n};\r\n\r\nvar prototype = {\r\n setInitialBufferArray: function(bufferArray) {\r\n this._initialBufferArray = bufferArray;\r\n },\r\n getInitialBufferArray: function() {\r\n return this._initialBufferArray;\r\n },\r\n setBufferArray: function(bufferArray) {\r\n this._bufferArray = bufferArray.getBufferArray ? bufferArray.getBufferArray() : bufferArray;\r\n },\r\n getBufferArray: function() {\r\n return this._bufferArray;\r\n }\r\n};\r\n\r\n// adds original method of BufferArray prototype for the proxy for convenient usage\r\nvar makeFunc = function(func) {\r\n return function() {\r\n return func.apply(this._bufferArray, arguments);\r\n };\r\n};\r\n\r\nfor (var methodName in BufferArray.prototype) {\r\n prototype[methodName] = makeFunc(BufferArray.prototype[methodName]);\r\n}\r\n\r\nBufferArrayProxy.prototype = prototype;\r\nexport default BufferArrayProxy;","import Polytope from './Polytope';\r\n\r\nvar CullingSet = function() {\r\n this._mask = CullingSet.DEFAULT_CULLING;\r\n this._frustum = new Polytope();\r\n};\r\n\r\nCullingSet.prototype = {\r\n reset: function() {\r\n this._mask = CullingSet.DEFAULT_CULLING;\r\n this._frustum.clear();\r\n },\r\n setCullingMask: function(mask) {\r\n this._mask = mask;\r\n },\r\n getCullingMask: function() {\r\n return this._mask;\r\n },\r\n setFrustum: function(frustum) {\r\n this._frustum = frustum;\r\n },\r\n getFrustum: function() {\r\n return this._frustum;\r\n },\r\n getCurrentResultMask: function() {\r\n return this._frustum.getCurrentMask();\r\n },\r\n pushCurrentMask: function() {\r\n this._frustum.pushCurrentMask();\r\n },\r\n popCurrentMask: function() {\r\n this._frustum.popCurrentMask();\r\n },\r\n resetCullingMask: function() {\r\n this._frustum.setResultMask(this._frustum.getCurrentMask());\r\n },\r\n isBoundingBoxCulled: function(bbox) {\r\n if (this._mask & CullingSet.VIEW_FRUSTUM_CULLING) {\r\n // is it outside the view frustum...\r\n if (!this._frustum.containsBoundingBox(bbox)) return true;\r\n }\r\n return false;\r\n },\r\n isBoundingSphereCulled: function(bs) {\r\n if (this._mask & CullingSet.VIEW_FRUSTUM_CULLING) {\r\n // is it outside the view frustum...\r\n if (!this._frustum.containsBoundingSphere(bs)) return true;\r\n }\r\n return false;\r\n },\r\n isVerticesCulled: function(vertices) {\r\n if (this._mask & CullingSet.VIEW_FRUSTUM_CULLING) {\r\n // is it outside the view frustum...\r\n if (!this._frustum.containsVertices(vertices)) return true;\r\n }\r\n return false;\r\n }\r\n};\r\n\r\nCullingSet.NO_CULLING = 0x0;\r\n\r\nCullingSet.VIEW_FRUSTUM_LEFT_CULLING = 0x1;\r\nCullingSet.VIEW_FRUSTUM_RIGHT_CULLING = 0x2;\r\nCullingSet.VIEW_FRUSTUM_TOP_CULLING = 0x3;\r\nCullingSet.VIEW_FRUSTUM_BOTTOM_CULLING = 0x4;\r\nCullingSet.NEAR_PLANE_CULLING = 0x5;\r\nCullingSet.FAR_PLANE_CULLING = 0x6;\r\n\r\nCullingSet.VIEW_FRUSTUM_SIDES_CULLING =\r\n CullingSet.VIEW_FRUSTUM_LEFT_CULLING |\r\n CullingSet.VIEW_FRUSTUM_RIGHT_CULLING |\r\n CullingSet.VIEW_FRUSTUM_BOTTOM_CULLING |\r\n CullingSet.VIEW_FRUSTUM_TOP_CULLING;\r\n\r\nCullingSet.VIEW_FRUSTUM_CULLING =\r\n CullingSet.VIEW_FRUSTUM_SIDES_CULLING |\r\n CullingSet.NEAR_PLANE_CULLING |\r\n CullingSet.FAR_PLANE_CULLING;\r\n\r\nCullingSet.DEFAULT_CULLING = CullingSet.VIEW_FRUSTUM_SIDES_CULLING;\r\n\r\nCullingSet.ENABLE_ALL_CULLING = CullingSet.VIEW_FRUSTUM_CULLING;\r\n\r\nexport default CullingSet;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport { vec4 } from './glMatrix';\r\n\r\n/**\r\n * Manage BlendColor attribute\r\n * @class\r\n * @memberOf osg\r\n * @extends StateAttribute\r\n */\r\nvar BlendColor = function(color) {\r\n StateAttribute.call(this);\r\n this._constantColor = vec4.create();\r\n vec4.set(this._constantColor, 1.0, 1.0, 1.0, 1.0);\r\n if (color !== undefined) {\r\n this.setConstantColor(color);\r\n }\r\n};\r\n\r\n/**\r\n * @lends BlendColor.prototype\r\n */\r\nutils.createPrototypeStateAttribute(\r\n BlendColor,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'BlendColor',\r\n cloneType: function() {\r\n return new BlendColor();\r\n },\r\n\r\n /**\r\n *\r\n * @param {} color\r\n */\r\n setConstantColor: function(color) {\r\n vec4.copy(this._constantColor, color);\r\n },\r\n getConstantColor: function() {\r\n return this._constantColor;\r\n },\r\n apply: function(state) {\r\n var gl = state.getGraphicContext();\r\n gl.blendColor(\r\n this._constantColor[0],\r\n this._constantColor[1],\r\n this._constantColor[2],\r\n this._constantColor[3]\r\n );\r\n }\r\n }),\r\n 'osg',\r\n 'BlendColor'\r\n);\r\n\r\nexport default BlendColor;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport { vec4 } from './glMatrix';\r\nimport Uniform from './Uniform';\r\n\r\n// Define a material attribute\r\nvar Material = function() {\r\n StateAttribute.call(this);\r\n this._ambient = vec4.fromValues(0.2, 0.2, 0.2, 1.0);\r\n this._diffuse = vec4.fromValues(0.8, 0.8, 0.8, 1.0);\r\n this._specular = vec4.fromValues(0.0, 0.0, 0.0, 1.0);\r\n this._emission = vec4.fromValues(0.0, 0.0, 0.0, 1.0);\r\n this._shininess = 12.5;\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n Material,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Material',\r\n\r\n cloneType: function() {\r\n return new Material();\r\n },\r\n\r\n getParameterName: function(name) {\r\n return 'u' + this.getType() + '_' + name;\r\n },\r\n\r\n getOrCreateUniforms: function() {\r\n var obj = Material;\r\n if (obj.uniforms) return obj.uniforms;\r\n\r\n obj.uniforms = {\r\n ambient: Uniform.createFloat4('uMaterialAmbient'),\r\n diffuse: Uniform.createFloat4('uMaterialDiffuse'),\r\n specular: Uniform.createFloat4('uMaterialSpecular'),\r\n emission: Uniform.createFloat4('uMaterialEmission'),\r\n shininess: Uniform.createFloat1('uMaterialShininess')\r\n };\r\n\r\n return obj.uniforms;\r\n },\r\n\r\n setEmission: function(a) {\r\n vec4.copy(this._emission, a);\r\n },\r\n\r\n getEmission: function() {\r\n return this._emission;\r\n },\r\n\r\n setAmbient: function(a) {\r\n vec4.copy(this._ambient, a);\r\n },\r\n\r\n getAmbient: function() {\r\n return this._ambient;\r\n },\r\n\r\n setSpecular: function(a) {\r\n vec4.copy(this._specular, a);\r\n },\r\n\r\n getSpecular: function() {\r\n return this._specular;\r\n },\r\n\r\n setDiffuse: function(a) {\r\n vec4.copy(this._diffuse, a);\r\n },\r\n\r\n getDiffuse: function() {\r\n return this._diffuse;\r\n },\r\n\r\n setShininess: function(a) {\r\n this._shininess = a;\r\n },\r\n\r\n getShininess: function() {\r\n return this._shininess;\r\n },\r\n\r\n setTransparency: function(a) {\r\n this._diffuse[3] = 1.0 - a;\r\n },\r\n\r\n getTransparency: function() {\r\n return this._diffuse[3];\r\n },\r\n\r\n apply: function() {\r\n var uniforms = this.getOrCreateUniforms();\r\n\r\n uniforms.ambient.setFloat4(this._ambient);\r\n uniforms.diffuse.setFloat4(this._diffuse);\r\n uniforms.specular.setFloat4(this._specular);\r\n uniforms.emission.setFloat4(this._emission);\r\n uniforms.shininess.setFloat(this._shininess);\r\n }\r\n }),\r\n 'osg',\r\n 'Material'\r\n);\r\n\r\nexport default Material;","import notify from '../osg/notify';\r\n\r\n/**\r\n * This is a very simplistic version of the OSG registry, we could\r\n * expand/improve it in the future\r\n */\r\n\r\nconst Registry = {\r\n instance: function() {\r\n if (!Registry._instance) {\r\n Registry._instance = Registry;\r\n Registry._instance.plugins = new window.Map();\r\n }\r\n return Registry._instance;\r\n },\r\n\r\n // We register directly a plugin for a extension.\r\n addReaderWriter: function(extension, plugin) {\r\n if (Registry.instance().plugins.get(extension) !== undefined)\r\n notify.warn(\"the '\" + extension + \"' plugin already exists\");\r\n Registry.instance().plugins.set(extension, plugin);\r\n },\r\n\r\n getReaderWriterForExtension: function(name) {\r\n return Registry.instance().plugins.get(name);\r\n }\r\n};\r\n\r\nexport default Registry;\r\n","import utils from '../osg/utils';\r\nimport notify from '../osg/notify';\r\nimport UpdateMatrixTransform from './UpdateMatrixTransform';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\n\r\n/**\r\n * UpdateBone\r\n * @class UpdateBone\r\n */\r\nvar UpdateBone = function() {\r\n UpdateMatrixTransform.call(this);\r\n};\r\n\r\n/** @lends UpdateBone.prototype */\r\nutils.createPrototypeObject(\r\n UpdateBone,\r\n utils.objectInherit(UpdateMatrixTransform.prototype, {\r\n update: function(node, nv) {\r\n if (nv.getVisitorType() === NodeVisitor.UPDATE_VISITOR) {\r\n if (node.className && node.className() !== 'Bone') {\r\n notify.warn('Warning: UpdateBone set on non-Bone object.');\r\n return false;\r\n }\r\n\r\n var bone = node;\r\n\r\n UpdateMatrixTransform.prototype.update.call(this, node);\r\n bone.setMatrix(bone.getMatrix());\r\n var matrix = bone.getMatrix();\r\n var parent = bone.getBoneParent();\r\n\r\n if (parent) {\r\n mat4.mul(\r\n bone.getMatrixInSkeletonSpace(),\r\n parent.getMatrixInSkeletonSpace(),\r\n matrix\r\n );\r\n } else {\r\n bone.setMatrixInSkeletonSpace(matrix);\r\n }\r\n }\r\n return true;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'UpdateBone'\r\n);\r\n\r\nexport default UpdateBone;\r\n","import notify from './notify';\r\nimport utils from './utils';\r\nimport Transform from './Transform';\r\nimport { vec3, vec4, quat, mat4 } from './glMatrix';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport TransformEnums from './transformEnums';\r\nimport Node from './Node';\r\n\r\n/** AutoTransform is a derived form of Transform that automatically\r\n * scales or rotates to keep its children aligned with screen coordinates.\r\n * W.r.t. AutorotateModes only rotate to screen is supported right now.\r\n * More AutorotateModes modes should be addressed in the future.\r\n * @class AutoTransform\r\n */\r\n\r\nvar AutoTransform = function() {\r\n Transform.call(this);\r\n this._matrix = mat4.create();\r\n this._position = vec3.create();\r\n this._matrixDirty = true;\r\n this._scale = vec3.fromValues(1.0, 1.0, 1.0);\r\n this._minimumScale = 0;\r\n this._maximumScale = Number.MAX_VALUE;\r\n this._rotation = quat.create();\r\n this._pivotPoint = vec3.create();\r\n this._autoScaleToScreen = false;\r\n this._autoRotateToScreen = false;\r\n this._cachedMatrix = mat4.create();\r\n this._firstTimeToInitEyePoint = true;\r\n this._autoScaleTransitionWidthRatio = 0.25;\r\n this._billboardAttribute = undefined;\r\n this._previousWidth = 0.0;\r\n this._previousHeight = 0.0;\r\n this._previousProjection = mat4.create();\r\n this._previousModelView = mat4.create();\r\n this._previousPosition = vec3.create();\r\n};\r\n\r\n/** @lends Autotransform.prototype */\r\nutils.createPrototypeNode(\r\n AutoTransform,\r\n utils.objectInherit(Transform.prototype, {\r\n getMatrix: function() {\r\n return this._matrix;\r\n },\r\n\r\n setMatrix: function(m) {\r\n this._matrix = m;\r\n this.dirtyBound();\r\n },\r\n\r\n setPosition: function(pos) {\r\n this._position = pos;\r\n this._matrixDirty = true;\r\n this.dirtyBound();\r\n },\r\n getPosition: function() {\r\n return this._position;\r\n },\r\n\r\n setRotation: function(q) {\r\n this._rotation = q;\r\n this._matrixDirty = true;\r\n this.dirtyBound();\r\n },\r\n\r\n getRotation: function() {\r\n return this._rotation;\r\n },\r\n\r\n setScale: function(scale) {\r\n this.setScaleFromVec3(vec3.fromValues(scale, scale, scale));\r\n },\r\n\r\n setScaleFromvec3: function(scaleVec) {\r\n notify.warn('deprecated, use setScaleFromVec3');\r\n this.setScaleFromVec3(scaleVec);\r\n },\r\n\r\n setScaleFromVec3: function(scaleVec) {\r\n this._scale = scaleVec;\r\n this._matrixDirty = true;\r\n this.dirtyBound();\r\n },\r\n\r\n getScale: function() {\r\n return this._scale;\r\n },\r\n\r\n setMinimumScale: function(minimumScale) {\r\n this._minimumScale = minimumScale;\r\n },\r\n\r\n getMinimumScale: function() {\r\n return this._minimumScale;\r\n },\r\n\r\n setMaximumScale: function(maximumScale) {\r\n this._maximumScale = maximumScale;\r\n },\r\n\r\n getMaximumScale: function() {\r\n return this._maximumScale;\r\n },\r\n\r\n setAutoScaleToScreen: function(autoScaleToScreen) {\r\n this._autoScaleToScreen = autoScaleToScreen;\r\n this._matrixDirty = true;\r\n },\r\n\r\n getAutoScaleToScreen: function() {\r\n return this._autoScaleToScreen;\r\n },\r\n\r\n setAutoRotateToScreen: function(value) {\r\n this._autoRotateToScreen = value;\r\n },\r\n\r\n getAutoRotateToScreen: function() {\r\n return this._autoRotateToScreen;\r\n },\r\n\r\n setAutoScaleTransitionWidthRatio: function(autoScaleTransitionWidthRatio) {\r\n this._autoScaleTransitionWidthRatio = autoScaleTransitionWidthRatio;\r\n },\r\n\r\n getAutoScaleTransitionWidthRatio: function() {\r\n return this._autoScaleTransitionWidthRatio;\r\n },\r\n\r\n // local to \"local world\" (not Global World)\r\n computeLocalToWorldMatrix: function(matrix /*, nodeVisitor */ ) {\r\n if (this._matrixDirty) this.computeMatrix();\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.mul(matrix, matrix, this._matrix);\r\n } else {\r\n mat4.copy(matrix, this._matrix);\r\n }\r\n },\r\n\r\n computeMatrix: (function() {\r\n var neg = vec3.create();\r\n var tmpMat = mat4.create();\r\n return function() {\r\n if (!this._matrixDirty) return;\r\n mat4.fromQuat(this._matrix, this._rotation);\r\n\r\n mat4.fromTranslation(tmpMat, this._position);\r\n mat4.mul(this._matrix, tmpMat, this._matrix);\r\n mat4.scale(this._matrix, this._matrix, this._scale);\r\n mat4.translate(this._matrix, this._matrix, vec3.neg(neg, this._pivotPoint));\r\n this._matrixDirty = false;\r\n };\r\n })(),\r\n\r\n computeWorldToLocalMatrix: (function() {\r\n var neg = vec3.create();\r\n var rotInverse = quat.create();\r\n var scaleInverse = vec3.create();\r\n var tmpMat = mat4.create();\r\n\r\n return function(matrix /*, nodeVisitor */ ) {\r\n if (this.scale[0] === 0.0 && this.scale[1] === 0.0 && this.scale[2] === 0.0) {\r\n return false;\r\n }\r\n scaleInverse[0] = 1.0 / this._scale[0];\r\n scaleInverse[1] = 1.0 / this._scale[1];\r\n scaleInverse[2] = 1.0 / this._scale[2];\r\n if (this.referenceFrame === TransformEnums.RELATIVE_RF) {\r\n mat4.fromTranslation(tmpMat, vec3.neg(neg, this._position));\r\n mat4.mul(matrix, tmpMat, matrix);\r\n\r\n if (!quat.zeroRotation(this._rotation)) {\r\n mat4.fromQuat(tmpMat, quat.invert(rotInverse, this._rotation));\r\n mat4.mul(matrix, tmpMat, matrix);\r\n }\r\n mat4.fromScaling(tmpMat, scaleInverse);\r\n mat4.mul(matrix, tmpMat, matrix);\r\n\r\n mat4.fromTranslation(tmpMat, this._pivotPoint);\r\n mat4.mul(matrix, tmpMat, matrix);\r\n } else {\r\n // absolute\r\n mat4.fromQuat(this._matrix, quat.invert(rotInverse, this._rotation));\r\n mat4.translate(matrix, matrix, vec3.neg(neg, this._position));\r\n\r\n mat4.fromScaling(tmpMat, scaleInverse);\r\n mat4.mul(matrix, tmpMat, matrix);\r\n\r\n mat4.fromTranslation(tmpMat, this._pivotPoint);\r\n mat4.mul(matrix, tmpMat, matrix);\r\n }\r\n return true;\r\n };\r\n })(),\r\n\r\n computeBound: (function() {\r\n var matrix = mat4.create();\r\n return function(bSphere) {\r\n if (this._autoScaleToScreen && this._firstTimeToInitEyePoint) return bSphere;\r\n Node.prototype.computeBound.call(this, bSphere);\r\n if (!bSphere.valid()) {\r\n return bSphere;\r\n }\r\n mat4.identity(matrix);\r\n // local to local world (not Global World)\r\n this.computeLocalToWorldMatrix(matrix);\r\n //Matrix.transformBoundingSphere( matrix, bSphere, bSphere );\r\n bSphere.transformMat4(bSphere, matrix);\r\n return bSphere;\r\n };\r\n })(),\r\n\r\n accept: (function() {\r\n return function(visitor) {\r\n if (visitor.getVisitorType() === NodeVisitor.CULL_VISITOR) {\r\n var width = visitor.getViewport().width();\r\n var height = visitor.getViewport().height();\r\n var projMat = visitor.getCurrentProjectionMatrix();\r\n var modelViewMat = visitor.getCurrentModelViewMatrix();\r\n var position = this._position;\r\n var doUpdate = this._firstTimeToInitEyePoint;\r\n if (!this._firstTimeToInitEyePoint) {\r\n if (width !== this._previousWidth || height !== this._previousHeight) {\r\n doUpdate = true;\r\n } else if (!mat4.exactEquals(projMat, this._previousProjection)) {\r\n doUpdate = true;\r\n } else if (!mat4.exactEquals(modelViewMat, this._previousModelView)) {\r\n doUpdate = true;\r\n } else if (!vec3.exactEquals(position, this._previousPosition)) {\r\n doUpdate = true;\r\n }\r\n }\r\n this._firstTimeToInitEyePoint = false;\r\n if (doUpdate) {\r\n if (this._autoScaleToScreen) {\r\n var viewport = visitor.getViewport();\r\n var psvector = this.computePixelSizeVector(\r\n viewport,\r\n projMat,\r\n modelViewMat\r\n );\r\n var v = vec4.fromValues(\r\n this._position[0],\r\n this._position[1],\r\n this._position[2],\r\n 1.0\r\n );\r\n var pixelSize = vec4.dot(v, psvector);\r\n pixelSize = 0.48 / pixelSize;\r\n var size = 1.0 / pixelSize;\r\n if (this._autoScaleTransitionWidthRatio > 0.0) {\r\n var c, b, a;\r\n if (this._minimumScale > 0.0) {\r\n var j = this._minimumScale;\r\n var i =\r\n this._maximumScale < Number.MAX_VALUE ?\r\n this._minimumScale +\r\n (this._maximumScale - this._minimumScale) *\r\n this._autoScaleTransitionWidthRatio :\r\n this._minimumScale *\r\n (1.0 + this._autoScaleTransitionWidthRatio);\r\n c = 1.0 / (4.0 * (i - j));\r\n b = 1.0 - 2.0 * c * i;\r\n a = j + b * b / (4.0 * c);\r\n var k = -b / (2.0 * c);\r\n if (size < k) size = this._minimumScale;\r\n else if (size < i) size = a + b * size + c * (size * size);\r\n }\r\n if (this._maximumScale < Number.MAX_VALUE) {\r\n var n = this._maximumScale;\r\n var m =\r\n this._minimumScale > 0.0 ?\r\n this._maximumScale +\r\n (this._minimumScale - this._maximumScale) *\r\n this._autoScaleTransitionWidthRatio :\r\n this._maximumScale *\r\n (1.0 - this._autoScaleTransitionWidthRatio);\r\n c = 1.0 / (4.0 * (m - n));\r\n b = 1.0 - 2.0 * c * m;\r\n a = n + b * b / (4.0 * c);\r\n var p = -b / (2.0 * c);\r\n\r\n if (size > p) size = this._maximumScale;\r\n else if (size > m) size = a + b * size + c * (size * size);\r\n }\r\n }\r\n this.setScale(size);\r\n }\r\n if (this._autoRotateToScreen) {\r\n var rotation = quat.create();\r\n mat4.getRotation(rotation, modelViewMat);\r\n this.setRotation(quat.invert(rotation, rotation));\r\n }\r\n this._previousWidth = width;\r\n this._previousHeight = height;\r\n vec3.copy(this._previousPosition, position);\r\n mat4.copy(this._previousProjection, projMat);\r\n mat4.copy(this._previousModelView, modelViewMat);\r\n }\r\n }\r\n\r\n Node.prototype.accept.call(this, visitor);\r\n };\r\n })(),\r\n\r\n computePixelSizeVector: (function() {\r\n var scale00 = vec3.create();\r\n var scale10 = vec3.create();\r\n return function(W, P, M) {\r\n // Where W = viewport, P = ProjectionMatrix, M = ModelViewMatrix\r\n // Comment from OSG:\r\n // pre adjust P00,P20,P23,P33 by multiplying them by the viewport window matrix.\r\n // here we do it in short hand with the knowledge of how the window matrix is formed\r\n // note P23,P33 are multiplied by an implicit 1 which would come from the window matrix.\r\n\r\n // scaling for horizontal pixels\r\n var P00 = P[0] * W.width() * 0.5;\r\n var P20_00 = P[8] * W.width() * 0.5 + P[11] * W.width() * 0.5;\r\n vec3.set(\r\n scale00,\r\n M[0] * P00 + M[2] * P20_00,\r\n M[4] * P00 + M[6] * P20_00,\r\n M[8] * P00 + M[10] * P20_00\r\n );\r\n\r\n // scaling for vertical pixels\r\n var P10 = P[5] * W.height() * 0.5;\r\n var P20_10 = P[9] * W.height() * 0.5 + P[11] * W.height() * 0.5;\r\n vec3.set(\r\n scale10,\r\n M[1] * P10 + M[2] * P20_10,\r\n M[5] * P10 + M[6] * P20_10,\r\n M[9] * P10 + M[10] * P20_10\r\n );\r\n\r\n var P23 = P[11];\r\n var P33 = P[15];\r\n var pixelSizeVector = vec4.fromValues(\r\n M[2] * P23,\r\n M[6] * P23,\r\n M[10] * P23,\r\n M[14] * P23 + M[15] * P33\r\n );\r\n\r\n var scaleRatio =\r\n 0.7071067811 / Math.sqrt(vec3.sqrLen(scale00) + vec3.sqrLen(scale10));\r\n vec4.scale(pixelSizeVector, pixelSizeVector, scaleRatio);\r\n return pixelSizeVector;\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'AutoTransform'\r\n);\r\n\r\nexport default AutoTransform;","import primitiveSet from './primitiveSet';\r\n\r\n/**\r\n * DrawArrays manage rendering primitives\r\n * @class DrawArrays\r\n */\r\nvar DrawArrays = function(mode, first, count) {\r\n this.mode = mode;\r\n if (mode !== undefined) {\r\n if (typeof mode === 'string') {\r\n mode = primitiveSet[mode];\r\n }\r\n this.mode = mode;\r\n }\r\n this.first = first;\r\n this.count = count;\r\n};\r\n\r\n/** @lends DrawArrays.prototype */\r\nDrawArrays.prototype = {\r\n draw: function(state) {\r\n if (this.count === 0) return;\r\n var gl = state.getGraphicContext();\r\n gl.drawArrays(this.mode, this.first, this.count);\r\n },\r\n getMode: function() {\r\n return this.mode;\r\n },\r\n setCount: function(count) {\r\n this.count = count;\r\n },\r\n getCount: function() {\r\n return this.count;\r\n },\r\n setFirst: function(first) {\r\n this.first = first;\r\n },\r\n getFirst: function() {\r\n return this.first;\r\n },\r\n getNumIndices: function() {\r\n return this.count;\r\n },\r\n index: function(i) {\r\n return this.first + i;\r\n }\r\n};\r\n\r\nexport default DrawArrays;\r\n","import notify from '../osg/notify';\r\nimport utils from '../osg/utils';\r\nimport Uniform from '../osg/Uniform';\r\nimport BlendFunc from '../osg/BlendFunc';\r\nimport Geometry from '../osg/Geometry';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport primitiveSet from '../osg/primitiveSet';\r\nimport DrawArrays from '../osg/DrawArrays';\r\nimport DrawElements from '../osg/DrawElements';\r\nimport StateSet from '../osg/StateSet';\r\nimport Node from '../osg/Node';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport Projection from '../osg/Projection';\r\nimport Registry from './Registry';\r\nimport Input from './Input';\r\nimport Texture from \"../osg/Texture\";\r\nimport Material from '../osg/Material';\r\n\r\nconst ReaderParser = {};\r\n\r\nReaderParser.ObjectWrapper = {};\r\nReaderParser.ObjectWrapper.serializers = {};\r\n\r\nReaderParser.readImage = function(url, options) {\r\n return ReaderParser.registry().readImageURL(url, options);\r\n};\r\nReaderParser.readImageURL = ReaderParser.readImage; // alias\r\n\r\nReaderParser.readBinaryArrayURL = function(url, options) {\r\n return ReaderParser.registry().readBinaryArrayURL(url, options);\r\n};\r\n\r\nReaderParser.readNodeURL = function(url, options) {\r\n var extension = url.substr(url.lastIndexOf('.') + 1);\r\n var readerWriter = Registry.instance().getReaderWriterForExtension(extension);\r\n if (readerWriter !== undefined) return readerWriter.readNodeURL(url, options);\r\n // If we don't have a registered plugin go through the osgjs\r\n // FIXME: we should have osgjs also as a plugin in the future\r\n return ReaderParser.registry().readNodeURL(url, options);\r\n};\r\n\r\nReaderParser.registry = function() {\r\n if (ReaderParser.registry._input === undefined) {\r\n ReaderParser.registry._input = new Input();\r\n }\r\n return ReaderParser.registry._input;\r\n};\r\n\r\nReaderParser.parseSceneGraph = function(node, options) {\r\n if (node.Version !== undefined && node.Version > 0) {\r\n utils.time('osgjs.metric:ReaderParser.parseSceneGraph', notify.INFO);\r\n\r\n var key;\r\n for (var prop in node) {\r\n if (prop !== 'Generator' && prop !== 'Version') {\r\n key = prop;\r\n break;\r\n }\r\n }\r\n\r\n if (key) {\r\n var obj = {};\r\n obj[key] = node[key];\r\n var input = ReaderParser.registry().clone();\r\n input.setJSON(obj);\r\n\r\n // copy global options and override with user options\r\n var opt = utils.objectMix(\r\n utils.objectMix({}, ReaderParser.registry().getOptions()),\r\n options || {}\r\n );\r\n input.setOptions(opt);\r\n var object = input.readObject();\r\n utils.timeEnd('osgjs.metric:ReaderParser.parseSceneGraph', notify.INFO);\r\n return object;\r\n } else {\r\n notify.log(\"can't parse scenegraph \" + node, notify.INFO);\r\n }\r\n } else {\r\n utils.time('osgjs.metric:ReaderParser.parseSceneGraphDeprecated', notify.INFO);\r\n var nodeOld = ReaderParser.parseSceneGraphDeprecated(node);\r\n utils.timeEnd('osgjs.metric:ReaderParser.parseSceneGraphDeprecated', notify.INFO);\r\n return nodeOld;\r\n }\r\n return undefined;\r\n};\r\n\r\nReaderParser.parseSceneGraphDeprecated = function(node) {\r\n var getFieldBackwardCompatible = function(field, json) {\r\n var value = json[field];\r\n if (value === undefined) {\r\n value = json[field.toLowerCase()];\r\n }\r\n return value;\r\n };\r\n var setName = function(osgjs, json) {\r\n var name = getFieldBackwardCompatible('Name', json);\r\n if (name && osgjs.setName !== undefined) {\r\n osgjs.setName(name);\r\n }\r\n };\r\n\r\n var setMaterial = function(osgjs, json) {\r\n setName(osgjs, json);\r\n osgjs.setAmbient(getFieldBackwardCompatible('Ambient', json));\r\n osgjs.setDiffuse(getFieldBackwardCompatible('Diffuse', json));\r\n osgjs.setEmission(getFieldBackwardCompatible('Emission', json));\r\n osgjs.setSpecular(getFieldBackwardCompatible('Specular', json));\r\n osgjs.setShininess(getFieldBackwardCompatible('Shininess', json));\r\n };\r\n\r\n var setBlendFunc = function(osgjs, json) {\r\n setName(osgjs, json);\r\n osgjs.setSourceRGB(json.SourceRGB);\r\n osgjs.setSourceAlpha(json.SourceAlpha);\r\n osgjs.setDestinationRGB(json.DestinationRGB);\r\n osgjs.setDestinationAlpha(json.DestinationAlpha);\r\n };\r\n\r\n var setTexture = function(osgjs, json) {\r\n var magFilter = json.MagFilter || json['mag_filter'] || undefined;\r\n if (magFilter) {\r\n osgjs.setMagFilter(magFilter);\r\n }\r\n var minFilter = json.MinFilter || json['min_filter'] || undefined;\r\n if (minFilter) {\r\n osgjs.setMinFilter(minFilter);\r\n }\r\n var wrapT = json.WrapT || json['wrap_t'] || undefined;\r\n if (wrapT) {\r\n osgjs.setWrapT(wrapT);\r\n }\r\n var wrapS = json.WrapS || json['wrap_s'] || undefined;\r\n if (wrapS) {\r\n osgjs.setWrapS(wrapS);\r\n }\r\n var file = getFieldBackwardCompatible('File', json);\r\n ReaderParser.readImage(file)\r\n .then(function(img) {\r\n osgjs.setImage(img);\r\n })\r\n .catch(function() {\r\n notify.log(\"Can't read image\");\r\n });\r\n };\r\n\r\n var setStateSet = function(osgjs, json) {\r\n setName(osgjs, json);\r\n var textures =\r\n getFieldBackwardCompatible('Textures', json) ||\r\n getFieldBackwardCompatible('TextureAttributeList', json) ||\r\n undefined;\r\n if (textures) {\r\n for (var t = 0, tl = textures.length; t < tl; t++) {\r\n var file = getFieldBackwardCompatible('File', textures[t]);\r\n if (!file) {\r\n notify.log('no texture on unit ' + t + ' skip it');\r\n continue;\r\n }\r\n \r\n var tex = new Texture();\r\n setTexture(tex, textures[t]);\r\n\r\n osgjs.setTextureAttributeAndModes(t, tex);\r\n osgjs.addUniform(Uniform.createInt1(t, 'Texture' + t));\r\n }\r\n }\r\n\r\n var blendfunc = getFieldBackwardCompatible('BlendFunc', json);\r\n if (blendfunc) {\r\n var newblendfunc = new BlendFunc();\r\n setBlendFunc(newblendfunc, blendfunc);\r\n osgjs.setAttributeAndModes(newblendfunc);\r\n }\r\n\r\n var material = getFieldBackwardCompatible('Material', json);\r\n if (material) {\r\n var newmaterial = new Material();\r\n setMaterial(newmaterial, material);\r\n osgjs.setAttributeAndModes(newmaterial);\r\n }\r\n };\r\n\r\n var newnode;\r\n var children = node.children;\r\n var primitives = node._primitives || node.primitives || node.Primitives || undefined;\r\n var attributes = node._attributes || node.attributes || node.Attributes || undefined;\r\n if (primitives || attributes) {\r\n var geom = new Geometry();\r\n setName(geom, node);\r\n geom.stateset = node.stateset;\r\n node = geom;\r\n\r\n for (var p = 0, lp = primitives.length; p < lp; p++) {\r\n var mode = primitives[p].mode;\r\n if (primitives[p].indices) {\r\n var array = primitives[p].indices;\r\n array = new BufferArray(BufferArray[array.type], array.elements, array.itemSize);\r\n if (!mode) {\r\n mode = 'TRIANGLES';\r\n } else {\r\n mode = primitiveSet[mode];\r\n }\r\n geom.getPrimitiveSetList().push(new DrawElements(mode, array));\r\n } else {\r\n mode = primitiveSet[mode];\r\n var first = primitives[p].first;\r\n var count = primitives[p].count;\r\n\r\n geom.getPrimitiveSetList().push(new DrawArrays(mode, first, count));\r\n }\r\n }\r\n\r\n for (var attr in attributes) {\r\n var attributeArray = attributes[attr];\r\n geom.getVertexAttributeList()[attr] = new BufferArray(\r\n attributeArray.type,\r\n attributeArray.elements,\r\n attributeArray.itemSize\r\n );\r\n }\r\n }\r\n\r\n var stateset = getFieldBackwardCompatible('StateSet', node);\r\n if (stateset) {\r\n var newstateset = new StateSet();\r\n setStateSet(newstateset, stateset);\r\n node.stateset = newstateset;\r\n }\r\n\r\n var matrix = node.matrix || node.Matrix || undefined;\r\n if (matrix) {\r\n newnode = new MatrixTransform();\r\n setName(newnode, node);\r\n\r\n utils.extend(newnode, node);\r\n mat4.copy(newnode.getMatrix(), matrix);\r\n node = newnode;\r\n }\r\n\r\n var projection = node.projection || node.Projection || undefined;\r\n if (projection) {\r\n newnode = new Projection();\r\n setName(newnode, node);\r\n utils.extend(newnode, node);\r\n mat4.copy(newnode.setProjectionMatrix(), projection);\r\n node = newnode;\r\n }\r\n\r\n // default type\r\n if (node.typeID === undefined) {\r\n newnode = new Node();\r\n setName(newnode, node);\r\n utils.extend(newnode, node);\r\n node = newnode;\r\n }\r\n\r\n if (children) {\r\n // disable children, it will be processed in the end\r\n node.children = [];\r\n\r\n for (var child = 0, childLength = children.length; child < childLength; child++) {\r\n node.addChild(ReaderParser.parseSceneGraphDeprecated(children[child]));\r\n }\r\n }\r\n\r\n return node;\r\n};\r\n\r\nexport default ReaderParser;\r\n","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar FrontFace = function(mode) {\r\n StateAttribute.call(this);\r\n this.setMode(mode !== undefined ? mode : FrontFace.CCW);\r\n};\r\n\r\nFrontFace.CW = 0x900;\r\nFrontFace.CCW = 0x901;\r\n\r\nutils.createPrototypeStateAttribute(\r\n FrontFace,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'FrontFace',\r\n\r\n cloneType: function() {\r\n return new FrontFace();\r\n },\r\n\r\n setMode: function(mode) {\r\n var value = mode;\r\n if (typeof value === 'string') value = FrontFace[value];\r\n this._mode = value;\r\n },\r\n\r\n getMode: function() {\r\n return this._mode;\r\n },\r\n\r\n apply: function(state) {\r\n state.applyFrontFace(this);\r\n }\r\n }),\r\n 'osg',\r\n 'FrontFace'\r\n);\r\n\r\nexport default FrontFace;","import { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport primitiveIndexFunctor from '../osg/primitiveIndexFunctor';\r\nimport intersectionEnums from '../osgUtil/intersectionEnums';\r\n\r\nvar IntersectFunctor = function() {\r\n this._hit = false;\r\n\r\n // geom info\r\n this._primitiveIndex = 0;\r\n this._vertices = undefined;\r\n this._geometry = undefined;\r\n\r\n // intersection visitor (nodepath, etc...)\r\n this._intersectionVisitor = undefined;\r\n\r\n // intersector stuffs\r\n this._intersector = undefined;\r\n this._limitOneIntersection = false;\r\n this._primitiveMask = intersectionEnums.ALL_PRIMITIVES;\r\n};\r\n\r\n// minimal \"interface\" for intersection type\r\nIntersectFunctor.Intersection = function() {\r\n this._nodePath = undefined;\r\n this._drawable = undefined;\r\n this._matrix = undefined;\r\n this._primitiveIndex = undefined;\r\n\r\n this._ratio = 0.0;\r\n this._backface = false;\r\n this._localIntersectionPoint = vec3.create();\r\n};\r\n\r\nIntersectFunctor.prototype = {\r\n reset: function() {\r\n this._hit = false;\r\n this._vertices = undefined;\r\n this._primitiveIndex = 0;\r\n },\r\n\r\n setPrimitiveIndex: function(primitiveIndex) {\r\n this._primitiveIndex = primitiveIndex;\r\n },\r\n setGeometry: function(geometry) {\r\n this._geometry = geometry;\r\n this._primitiveIndex = 0;\r\n this._vertices = geometry.getAttributes().Vertex.getElements();\r\n },\r\n setVertices: function(vertices) {\r\n this._vertices = vertices;\r\n },\r\n\r\n setIntersectionVisitor: function(intersectionVisitor) {\r\n this._intersectionVisitor = intersectionVisitor;\r\n },\r\n setIntersector: function(intersector) {\r\n this._intersector = intersector;\r\n this._primitiveMask = intersector.getPrimitiveMask();\r\n\r\n var limit = intersector.getIntersectionLimit();\r\n this._limitOneIntersection =\r\n limit === intersectionEnums.LIMIT_ONE_PER_DRAWABLE ||\r\n limit === intersectionEnums.LIMIT_ONE;\r\n },\r\n\r\n setLimitOneIntersection: function(limitOneIntersection) {\r\n this._limitOneIntersection = limitOneIntersection;\r\n },\r\n\r\n leave: function() {},\r\n\r\n enter: function(/*bbox*/) {},\r\n\r\n initIntersection: function(intersection) {\r\n intersection._matrix = mat4.clone(this._intersectionVisitor.getModelMatrix());\r\n intersection._nodePath = this._intersectionVisitor.getNodePath().slice();\r\n intersection._primitiveIndex = this._primitiveIndex;\r\n intersection._drawable = this._geometry;\r\n this._intersector.getIntersections().push(intersection);\r\n this._hit = true;\r\n return intersection;\r\n },\r\n\r\n intersectPoint: function(/*v0, p0*/) {},\r\n intersectLine: function(/*v0, v1, p0, p1*/) {},\r\n intersectTriangle: function(/*v0, v1, v2, p0, p1, p2*/) {},\r\n\r\n operatorPoint: (function() {\r\n var v0 = vec3.create();\r\n\r\n return function(p0) {\r\n if (this._limitOneIntersection && this._hit) return;\r\n if ((this._primitiveMask & intersectionEnums.POINT_PRIMITIVES) === 0) return;\r\n\r\n var vertices = this._vertices;\r\n vec3.set(v0, vertices[3 * p0], vertices[3 * p0 + 1], vertices[3 * p0 + 2]);\r\n\r\n this.intersectPoint(v0, p0);\r\n this._primitiveIndex++;\r\n };\r\n })(),\r\n\r\n operatorLine: (function() {\r\n var v0 = vec3.create();\r\n var v1 = vec3.create();\r\n\r\n return function(p0, p1) {\r\n if (this._limitOneIntersection && this._hit) return;\r\n if ((this._primitiveMask & intersectionEnums.LINE_PRIMITIVES) === 0) return;\r\n\r\n var vertices = this._vertices;\r\n vec3.set(v0, vertices[3 * p0], vertices[3 * p0 + 1], vertices[3 * p0 + 2]);\r\n vec3.set(v1, vertices[3 * p1], vertices[3 * p1 + 1], vertices[3 * p1 + 2]);\r\n\r\n this.intersectLine(v0, v1, p0, p1);\r\n this._primitiveIndex++;\r\n };\r\n })(),\r\n\r\n operatorTriangle: (function() {\r\n var v0 = vec3.create();\r\n var v1 = vec3.create();\r\n var v2 = vec3.create();\r\n\r\n return function(p0, p1, p2) {\r\n if (this._limitOneIntersection && this._hit) return;\r\n if ((this._primitiveMask & intersectionEnums.TRIANGLE_PRIMITIVES) === 0) return;\r\n\r\n var vertices = this._vertices;\r\n vec3.set(v0, vertices[3 * p0], vertices[3 * p0 + 1], vertices[3 * p0 + 2]);\r\n vec3.set(v1, vertices[3 * p1], vertices[3 * p1 + 1], vertices[3 * p1 + 2]);\r\n vec3.set(v2, vertices[3 * p2], vertices[3 * p2 + 1], vertices[3 * p2 + 2]);\r\n\r\n this.intersectTriangle(v0, v1, v2, p0, p1, p2);\r\n this._primitiveIndex++;\r\n };\r\n })(),\r\n\r\n apply: function(node) {\r\n if (!node.getAttributes().Vertex) return;\r\n primitiveIndexFunctor(node, this);\r\n }\r\n};\r\n\r\nexport default IntersectFunctor;\r\n","import notify from './notify';\r\nimport Timer from './Timer';\r\n\r\nvar TextureProfile = function(target, internalFormat, width, height) {\r\n this._target = target;\r\n this._internalFormat = internalFormat;\r\n this._width = width;\r\n this._height = height;\r\n this._size = 0;\r\n this.computeSize();\r\n};\r\n\r\nTextureProfile.prototype = {\r\n match: function(textureProfile) {\r\n return (\r\n textureProfile._target === this._target &&\r\n textureProfile._internalFormat === this._internalFormat &&\r\n textureProfile._width === this._width &&\r\n textureProfile._height === this._height\r\n );\r\n },\r\n computeSize: function() {\r\n var Texture = require('./Texture').default;\r\n\r\n var numBitsPerTexel = 0;\r\n switch (this._internalFormat) {\r\n case 1:\r\n numBitsPerTexel = 8;\r\n break;\r\n case Texture.ALPHA:\r\n numBitsPerTexel = 8;\r\n break;\r\n case Texture.LUMINANCE:\r\n numBitsPerTexel = 8;\r\n break;\r\n\r\n case Texture.LUMINANCE_ALPHA:\r\n numBitsPerTexel = 16;\r\n break;\r\n case 2:\r\n numBitsPerTexel = 16;\r\n break;\r\n\r\n case Texture.RGB:\r\n numBitsPerTexel = 24;\r\n break;\r\n case 3:\r\n numBitsPerTexel = 24;\r\n break;\r\n\r\n case Texture.RGBA:\r\n numBitsPerTexel = 32;\r\n break;\r\n case 4:\r\n numBitsPerTexel = 32;\r\n break;\r\n }\r\n var size = Math.ceil(this._width * this._height * numBitsPerTexel) / 8.0;\r\n\r\n if (this._target === Texture.TEXTURE_CUBE_MAP) size *= 6.0;\r\n\r\n // add the mipmap overhead size even if not used\r\n size += size / 3.0;\r\n\r\n this._size = size;\r\n },\r\n\r\n getSize: function() {\r\n return this._size;\r\n }\r\n};\r\nTextureProfile.getHash = function() {\r\n var array = Array.prototype.slice.call(arguments);\r\n var hash = '';\r\n array.forEach(function(element) {\r\n hash += element;\r\n });\r\n return hash;\r\n};\r\n\r\nvar TextureObject = function(texture, id, textureSet) {\r\n this._texture = texture;\r\n this._id = id;\r\n this._textureSet = textureSet;\r\n};\r\n\r\nTextureObject.prototype = {\r\n target: function() {\r\n return this._textureSet._profile._target;\r\n },\r\n id: function() {\r\n return this._id;\r\n },\r\n getTextureSet: function() {\r\n return this._textureSet;\r\n },\r\n reset: function() {\r\n this._textureObject = null;\r\n this._texture = undefined;\r\n },\r\n bind: function(gl) {\r\n gl.bindTexture(this.target(), this._id);\r\n }\r\n};\r\n\r\nvar TextureObjectSet = function(profile) {\r\n this._profile = profile;\r\n this._usedTextureObjects = [];\r\n this._orphanedTextureObjects = [];\r\n};\r\n\r\nTextureObjectSet.prototype = {\r\n getProfile: function() {\r\n return this._profile;\r\n },\r\n getUsedTextureObjects: function() {\r\n return this._usedTextureObjects;\r\n },\r\n getOrphanedTextureObjects: function() {\r\n return this._orphanedTextureObjects;\r\n },\r\n\r\n takeOrGenerate: function(gl, texture) {\r\n var textureObject;\r\n if (this._orphanedTextureObjects.length > 0) {\r\n textureObject = this.takeFromOrphans();\r\n textureObject._texture = texture;\r\n this._usedTextureObjects.push(textureObject);\r\n return textureObject;\r\n }\r\n\r\n var textureID = gl.createTexture();\r\n textureObject = new TextureObject(texture, textureID, this);\r\n this._usedTextureObjects.push(textureObject);\r\n\r\n return textureObject;\r\n },\r\n\r\n // get texture object from pool\r\n takeFromOrphans: function() {\r\n if (this._orphanedTextureObjects.length) return this._orphanedTextureObjects.pop();\r\n\r\n return undefined;\r\n },\r\n\r\n // release texture object\r\n orphan: function(textureObject) {\r\n var index = this._usedTextureObjects.indexOf(textureObject);\r\n if (index !== -1) {\r\n this._orphanedTextureObjects.push(this._usedTextureObjects[index]);\r\n this._usedTextureObjects.splice(index, 1);\r\n }\r\n },\r\n\r\n flushDeletedTextureObjects: function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n var nbTextures = this._orphanedTextureObjects.length;\r\n // Should we use a maxSizeTexturePool value?\r\n //var size = this.getProfile().getSize();\r\n // We need to test if we have time to flush\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var i;\r\n for (i = 0; i < nbTextures && elapsedTime < availableTime; i++) {\r\n gl.deleteTexture(this._orphanedTextureObjects[i].id());\r\n this._orphanedTextureObjects[i].reset();\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n this._orphanedTextureObjects.splice(0, i);\r\n return availableTime - elapsedTime;\r\n },\r\n\r\n flushAllDeletedTextureObjects: function(gl) {\r\n var nbTextures = this._orphanedTextureObjects.length;\r\n var size = this.getProfile().getSize();\r\n for (var i = 0, j = nbTextures; i < j; ++i) {\r\n gl.deleteTexture(this._orphanedTextureObjects[i].id());\r\n this._orphanedTextureObjects[i].reset();\r\n }\r\n this._orphanedTextureObjects.length = 0;\r\n notify.info(\r\n 'TextureManager: released ' +\r\n nbTextures +\r\n ' with ' +\r\n nbTextures * size / (1024 * 1024) +\r\n ' MB'\r\n );\r\n },\r\n\r\n onLostContext: function() {\r\n var i, nbTextures;\r\n\r\n nbTextures = this._orphanedTextureObjects.length;\r\n for (i = 0; i < nbTextures; ++i) {\r\n this._orphanedTextureObjects[i].reset();\r\n }\r\n this._orphanedTextureObjects.length = 0;\r\n\r\n nbTextures = this._usedTextureObjects.length;\r\n for (i = 0; i < nbTextures; ++i) {\r\n this._usedTextureObjects[i].reset();\r\n }\r\n this._usedTextureObjects.length = 0;\r\n }\r\n};\r\n\r\nvar TextureManager = function() {\r\n this._textureSetMap = {};\r\n};\r\n\r\nTextureManager.prototype = {\r\n generateTextureObject: function(gl, texture, target, internalFormat, width, height) {\r\n var hash = TextureProfile.getHash(target, internalFormat, width, height);\r\n\r\n if (this._textureSetMap[hash] === undefined) {\r\n this._textureSetMap[hash] = new TextureObjectSet(\r\n new TextureProfile(target, internalFormat, width, height)\r\n );\r\n }\r\n\r\n var textureSet = this._textureSetMap[hash];\r\n var textureObject = textureSet.takeOrGenerate(gl, texture);\r\n return textureObject;\r\n },\r\n\r\n updateStats: function(frameNumber, stats) {\r\n var totalUsed = 0;\r\n var totalUnused = 0;\r\n for (var keyTexture in this._textureSetMap) {\r\n var profile = this._textureSetMap[keyTexture].getProfile();\r\n var size = profile.getSize();\r\n var nbUsed = this._textureSetMap[keyTexture].getUsedTextureObjects().length;\r\n var nbUnused = this._textureSetMap[keyTexture].getOrphanedTextureObjects().length;\r\n totalUsed += nbUsed * size;\r\n totalUnused += nbUnused * size;\r\n }\r\n\r\n var MB = 1024 * 1024;\r\n stats.getCounter('textureused').set(totalUsed / MB);\r\n stats.getCounter('texturereserved').set(totalUnused / MB);\r\n stats.getCounter('texturetotal').set((totalUsed + totalUnused) / MB);\r\n },\r\n\r\n reportStats: function() {\r\n var total = 0;\r\n for (var keyTexture in this._textureSetMap) {\r\n var profile = this._textureSetMap[keyTexture].getProfile();\r\n var size = profile.getSize() / (1024 * 1024);\r\n var nb = this._textureSetMap[keyTexture].getUsedTextureObjects().length;\r\n size *= nb;\r\n total += size;\r\n notify.notice(\r\n String(size) +\r\n ' MB with ' +\r\n nb +\r\n ' texture of ' +\r\n profile._width +\r\n 'x' +\r\n profile._height +\r\n ' ' +\r\n profile._internalFormat\r\n );\r\n }\r\n\r\n notify.notice(String(total) + ' MB in total');\r\n },\r\n\r\n flushAllDeletedTextureObjects: function(gl) {\r\n for (var keyTexture in this._textureSetMap) {\r\n this._textureSetMap[keyTexture].flushAllDeletedTextureObjects(gl);\r\n }\r\n },\r\n\r\n onLostContext: function(gl) {\r\n for (var keyTexture in this._textureSetMap) {\r\n this._textureSetMap[keyTexture].onLostContext(gl);\r\n }\r\n },\r\n\r\n flushDeletedTextureObjects: function(gl, availableTimeArg) {\r\n var availableTime = availableTimeArg;\r\n for (var keyTexture in this._textureSetMap) {\r\n availableTime = this._textureSetMap[keyTexture].flushDeletedTextureObjects(\r\n gl,\r\n availableTime\r\n );\r\n if (availableTime <= 0.0) break;\r\n }\r\n return availableTime;\r\n },\r\n\r\n releaseTextureObject: function(textureObject) {\r\n if (textureObject) {\r\n var ts = textureObject.getTextureSet();\r\n ts.orphan(textureObject);\r\n }\r\n }\r\n};\r\n\r\nexport default TextureManager;","import notify from './notify';\r\nimport utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport Uniform from './Uniform';\r\nimport Image from './Image';\r\nimport GLObject from './GLObject';\r\n\r\nimport TextureManager from './TextureManager';\r\nimport WebglCaps from './WebGLCaps';\r\n\r\nvar ImageBitmap = window.ImageBitmap || function() {};\r\n\r\n// helper\r\nvar isPowerOf2 = function(x) {\r\n /*jshint bitwise: false */\r\n return x !== 0 && (x & (~x + 1)) === x;\r\n /*jshint bitwise: true */\r\n};\r\n\r\n/**\r\n * Texture encapsulate webgl texture object\r\n * @class Texture\r\n * Not that dirty here is mainly for texture binding\r\n * any dirty will cause re-bind\r\n * hint: don't dirty a texture attached to a camera/framebuffer\r\n * it will end blank\r\n * @inherits StateAttribute\r\n */\r\nvar Texture = function() {\r\n StateAttribute.call(this);\r\n GLObject.call(this);\r\n this.setDefaultParameters();\r\n this._dirty = true;\r\n this._dirtyMipmap = true;\r\n this._applyTexImage2DCallbacks = [];\r\n this._textureObject = undefined;\r\n\r\n this._textureNull = true;\r\n};\r\n\r\nvar checkAndFixEnum = function(mode, fallback) {\r\n var value = Texture[mode];\r\n\r\n if (value === undefined) {\r\n notify.warn('bad Texture enum argument ' + mode + '\\n' + 'fallback to ' + fallback);\r\n return fallback;\r\n }\r\n\r\n return value;\r\n};\r\n\r\nTexture.UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;\r\nTexture.UNPACK_FLIP_Y_WEBGL = 0x9240;\r\nTexture.BROWSER_DEFAULT_WEBGL = 0x9244;\r\nTexture.NONE = 0x0;\r\n\r\nTexture.DEPTH_COMPONENT = 0x1902;\r\nTexture.DEPTH_COMPONENT16 = 0x81a5;\r\nTexture.DEPTH_STENCIL = 0x84f9;\r\n// gl2\r\nTexture.DEPTH24_STENCIL8 = 0x88f0;\r\nTexture.DEPTH_COMPONENT24 = 0x81a6;\r\nTexture.DEPTH_COMPONENT32F = 0x8cac;\r\n\r\n// DXT formats, from:\r\n// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/\r\nTexture.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0;\r\nTexture.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1;\r\nTexture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83f2;\r\nTexture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83f3;\r\n\r\n// ATC formats, from:\r\n// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_atc/\r\nTexture.COMPRESSED_RGB_ATC_WEBGL = 0x8c92;\r\nTexture.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8c93;\r\nTexture.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87ee;\r\n\r\n// PVR formats, from:\r\n// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/\r\nTexture.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00;\r\nTexture.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01;\r\nTexture.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02;\r\nTexture.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03;\r\n\r\n// ETC1 format, from:\r\n// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/\r\nTexture.COMPRESSED_RGB_ETC1_WEBGL = 0x8d64;\r\n\r\n// filter mode\r\nTexture.LINEAR = 0x2601;\r\nTexture.NEAREST = 0x2600;\r\nTexture.NEAREST_MIPMAP_NEAREST = 0x2700;\r\nTexture.LINEAR_MIPMAP_NEAREST = 0x2701;\r\nTexture.NEAREST_MIPMAP_LINEAR = 0x2702;\r\nTexture.LINEAR_MIPMAP_LINEAR = 0x2703;\r\n// filter anisotropy\r\nTexture.TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe;\r\nTexture.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff;\r\n\r\n// wrap mode\r\nTexture.CLAMP_TO_EDGE = 0x812f;\r\nTexture.REPEAT = 0x2901;\r\nTexture.MIRRORED_REPEAT = 0x8370;\r\n\r\n// target\r\nTexture.TEXTURE_2D = 0x0de1;\r\nTexture.TEXTURE_CUBE_MAP = 0x8513;\r\nTexture.TEXTURE_BINDING_CUBE_MAP = 0x8514;\r\nTexture.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;\r\nTexture.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;\r\nTexture.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;\r\nTexture.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;\r\nTexture.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;\r\nTexture.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a;\r\nTexture.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c;\r\n\r\n// https: //www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.6\r\n///////////\r\n// TYPE GL1\r\n///////////\r\nTexture.UNSIGNED_BYTE = 0x1401;\r\nTexture.UNSIGNED_SHORT = 0x1403;\r\nTexture.UNSIGNED_SHORT_4_4_4_4 = 0x8033;\r\nTexture.UNSIGNED_SHORT_5_5_5_1 = 0x8034;\r\nTexture.UNSIGNED_SHORT_5_6_5 = 0x8363;\r\nTexture.FLOAT = 0x1406;\r\nTexture.HALF_FLOAT_OES = 0x8d61;\r\n// TYPE GL2\r\nTexture.HALF_FLOAT = 0x140b;\r\nTexture.UNSIGNED_INT_10F_11F_11F_REV = 0x8c3b;\r\nTexture.UNSIGNED_INT_24_8 = 0x84fa;\r\n\r\n/////////////\r\n// FORMAT GL1\r\n/////////////\r\nTexture.ALPHA = 0x1906;\r\nTexture.RGB = 0x1907;\r\nTexture.RGBA = 0x1908;\r\nTexture.LUMINANCE = 0x1909;\r\nTexture.LUMINANCE_ALPHA = 0x190a;\r\n// format gl2\r\nTexture.RED_INTEGER = 0x8d94;\r\nTexture.RGB_INTEGER = 0x8d98;\r\nTexture.RGBA_INTEGER = 0x8d99;\r\nTexture.RG_INTEGER = 0x8228;\r\nTexture.RED = 0x1903;\r\n\r\n//////////////////////\r\n// INTERNAL FORMAT GL2\r\n//////////////////////\r\nTexture.R8 = 0x8229;\r\nTexture.R8UI = 0x8232;\r\nTexture.RG8 = 0x822b;\r\nTexture.RG8UI = 0x8238;\r\nTexture.RGB8 = 0x8f96;\r\nTexture.RGB565 = 0x8d62;\r\nTexture.RGB9_E5 = 0x8c3d;\r\nTexture.RGB8UI = 0x8d7d;\r\nTexture.RGBA8 = 0x8058;\r\nTexture.RGB5_A1 = 0x8057;\r\nTexture.RGBA4 = 0x8056;\r\nTexture.RGBA8UI = 0x8d7c;\r\nTexture.SRGB8_ALPHA8 = 0x8c43;\r\nTexture.SRGB8 = 0x8c41;\r\n\r\n// HALF FLOAT - FLOAT\r\nTexture.R16F = 0x822d;\r\nTexture.RG16F = 0x822f;\r\nTexture.RGB16F = 0x881b;\r\nTexture.RGBA16F = 0x881a;\r\nTexture.R11F_G11F_B10F = 0x8c3a; // and UNSIGNED_INT_10F_11F_11F_REV\r\n// FLOAT\r\nTexture.R32F = 0x822e;\r\nTexture.RG32F = 0x8230;\r\nTexture.RGB32F = 0x8815;\r\nTexture.RGBA32F = 0x8814;\r\n\r\nvar createMapGl2ToGl1 = function() {\r\n var map = {};\r\n\r\n map[Texture.R8] = Texture.LUMINANCE;\r\n map[Texture.R8UI] = Texture.LUMINANCE;\r\n map[Texture.R16F] = Texture.LUMINANCE;\r\n map[Texture.R32F] = Texture.LUMINANCE;\r\n map[Texture.SRGB8] = Texture.LUMINANCE;\r\n map[Texture.RG8] = Texture.RGB;\r\n map[Texture.RG8UI] = Texture.RGB;\r\n map[Texture.RG16F] = Texture.RGB;\r\n map[Texture.RG32F] = Texture.RGB;\r\n map[Texture.RGB8] = Texture.RGB;\r\n map[Texture.RGB565] = Texture.RGB;\r\n map[Texture.RGB9_E5] = Texture.RGB;\r\n map[Texture.RGB8UI] = Texture.RGB;\r\n map[Texture.RGB5_A1] = Texture.RGB;\r\n map[Texture.RGB16F] = Texture.RGB;\r\n map[Texture.RGB32F] = Texture.RGB;\r\n map[Texture.RGBA8] = Texture.RGBA;\r\n map[Texture.R11F_G11F_B10F] = Texture.RGBA;\r\n map[Texture.RGBA16F] = Texture.RGBA;\r\n map[Texture.RGBA32F] = Texture.RGBA;\r\n map[Texture.SRGB8_ALPHA8] = Texture.RGBA;\r\n\r\n return map;\r\n};\r\n\r\nvar createMapGl1ToGl2 = function() {\r\n var map = {};\r\n\r\n var float = {};\r\n var halfFloat = {};\r\n var ushort = {};\r\n var uint = {};\r\n var uin24 = {};\r\n\r\n map[Texture.FLOAT] = float;\r\n map[Texture.HALF_FLOAT] = map[Texture.HALF_FLOAT_OES] = halfFloat;\r\n map[Texture.UNSIGNED_SHORT] = ushort;\r\n map[Texture.UNSIGNED_INT] = uint;\r\n map[Texture.UNSIGNED_INT_24_8] = uin24;\r\n\r\n halfFloat[Texture.LUMINANCE] = Texture.R16F;\r\n halfFloat[Texture.RGB] = Texture.RGB16F;\r\n halfFloat[Texture.RGBA] = Texture.RGBA16F;\r\n\r\n float[Texture.LUMINANCE] = Texture.R32F;\r\n float[Texture.RGB] = Texture.RGB32F;\r\n float[Texture.RGBA] = Texture.RGBA32F;\r\n\r\n ushort[Texture.DEPTH_COMPONENT] = Texture.DEPTH_COMPONENT16;\r\n uint[Texture.DEPTH_COMPONENT] = Texture.DEPTH_COMPONENT32F;\r\n uin24[Texture.DEPTH_STENCIL] = Texture.DEPTH24_STENCIL8;\r\n\r\n return map;\r\n};\r\n\r\nvar internalFormatGl2ToGl1 = createMapGl2ToGl1();\r\nvar internalFormatGl1ToGl2 = createMapGl1ToGl2();\r\n\r\nTexture._sTextureManager = new window.Map();\r\n\r\n// Getter for textureManager\r\nTexture.getTextureManager = function(gl) {\r\n if (!Texture._sTextureManager.has(gl)) Texture._sTextureManager.set(gl, new TextureManager());\r\n\r\n return Texture._sTextureManager.get(gl);\r\n};\r\n\r\nTexture.getEnumFromString = function(v) {\r\n var value = v;\r\n\r\n if (typeof value === 'string') value = checkAndFixEnum(value, v);\r\n\r\n return value;\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n Texture,\r\n utils.objectInherit(\r\n GLObject.prototype,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Texture',\r\n\r\n cloneType: function() {\r\n return new Texture();\r\n },\r\n\r\n invalidate: function() {\r\n this._textureObject = undefined;\r\n this._gl = undefined\r\n this.dirty();\r\n },\r\n\r\n dirty: function() {\r\n this._dirty = true;\r\n },\r\n\r\n isDirty: function() {\r\n return this._dirty;\r\n },\r\n\r\n isTextureNull: function() {\r\n return this._textureNull;\r\n },\r\n\r\n getOrCreateUniforms: function(unit) {\r\n if (Texture.uniforms === undefined) {\r\n Texture.uniforms = [];\r\n }\r\n if (Texture.uniforms[unit] === undefined) {\r\n var name = this.getType() + unit;\r\n Texture.uniforms[unit] = {\r\n texture: Uniform.createInt1(unit, name)\r\n };\r\n }\r\n\r\n // uniform for an texture attribute should directly in Texture.uniforms[unit]\r\n // and not in Texture.uniforms[unit][Texture0]\r\n\r\n // Why it's in Texture.uniforms[unit]['texture'] :\r\n // a 'texture' is a texture attribute but you also have old texenv\r\n // that are texture attribute because they are applied on a texture unit.\r\n // I admit that currently we dont have this or we used to but we dont have it anymore.\r\n // It's the same design than osg.\r\n // We could imagine for example a TextureGreyScale texture attributes,\r\n // that would transform the input texture\r\n // on unit X into greyscale used in the shader.\r\n\r\n return Texture.uniforms[unit];\r\n },\r\n\r\n setDefaultParameters: function() {\r\n this._image = undefined;\r\n this._magFilter = Texture.LINEAR;\r\n this._minFilter = Texture.LINEAR;\r\n this._maxAnisotropy = 1.0;\r\n this._wrapS = Texture.REPEAT;\r\n this._wrapT = Texture.REPEAT;\r\n this._textureWidth = 0;\r\n this._textureHeight = 0;\r\n this._unrefImageDataAfterApply = false;\r\n this._internalFormat = undefined;\r\n this._dirtyMipmap = true;\r\n this._textureTarget = Texture.TEXTURE_2D;\r\n this.setInternalFormatType(Texture.UNSIGNED_BYTE);\r\n this._isCompressed = false;\r\n\r\n this._flipY = true;\r\n this._colorSpaceConversion = Texture.NONE; //Texture.BROWSER_DEFAULT_WEBGL;\r\n },\r\n\r\n // check https://www.khronos.org/registry/webgl/specs/latest/1.0/#PIXEL_STORAGE_PARAMETERS\r\n setColorSpaceConversion: function(enumValue) {\r\n this._colorSpaceConversion = enumValue;\r\n },\r\n\r\n setFlipY: function(bool) {\r\n this._flipY = bool;\r\n },\r\n\r\n getTextureTarget: function() {\r\n return this._textureTarget;\r\n },\r\n\r\n getTextureObject: function() {\r\n return this._textureObject;\r\n },\r\n\r\n setTextureSize: function(w, h) {\r\n var maxSize = WebglCaps.instance().getWebGLParameter('MAX_TEXTURE_SIZE');\r\n\r\n if (w !== this._textureWidth || h !== this._textureHeight) this.dirty();\r\n\r\n if (w !== undefined) {\r\n if (w > maxSize) {\r\n notify.error(\r\n 'width (' +\r\n w +\r\n ') too big for GPU. Max Texture Size is \"' +\r\n maxSize +\r\n '\"'\r\n );\r\n this._textureWidth = maxSize;\r\n } else {\r\n this._textureWidth = w;\r\n }\r\n }\r\n\r\n if (h !== undefined) {\r\n if (h > maxSize) {\r\n notify.error(\r\n 'height (' +\r\n h +\r\n ') too big for GPU. Max Texture Size is \"' +\r\n maxSize +\r\n '\"'\r\n );\r\n this._textureHeight = maxSize;\r\n } else {\r\n this._textureHeight = h;\r\n }\r\n }\r\n\r\n this._textureNull = false;\r\n },\r\n\r\n init: function(state) {\r\n if (!this._gl) {\r\n this.setGraphicContext(state.getGraphicContext());\r\n }\r\n\r\n if (!this._textureObject) {\r\n this._textureObject = Texture.getTextureManager(this._gl).generateTextureObject(\r\n this._gl,\r\n this,\r\n this._textureTarget,\r\n this._internalFormat,\r\n this._textureWidth,\r\n this._textureHeight\r\n );\r\n\r\n this.dirty();\r\n this._dirtyTextureObject = false;\r\n this._textureNull = false;\r\n }\r\n },\r\n\r\n addApplyTexImage2DCallback: function(callback) {\r\n var index = this._applyTexImage2DCallbacks.indexOf(callback);\r\n if (index < 0) {\r\n this._applyTexImage2DCallbacks.push(callback);\r\n }\r\n },\r\n\r\n removeApplyTexImage2DCallback: function(callback) {\r\n var index = this._applyTexImage2DCallbacks.indexOf(callback);\r\n if (index >= 0) {\r\n this._applyTexImage2DCallbacks.splice(index, 1);\r\n }\r\n },\r\n\r\n getWidth: function() {\r\n return this._textureWidth;\r\n },\r\n\r\n getHeight: function() {\r\n return this._textureHeight;\r\n },\r\n\r\n releaseGLObjects: function() {\r\n if (\r\n this._textureObject !== undefined &&\r\n this._textureObject !== null &&\r\n this._gl !== undefined\r\n ) {\r\n Texture.getTextureManager(this._gl).releaseTextureObject(this._textureObject);\r\n GLObject.removeObject(this._gl, this);\r\n }\r\n this.invalidate();\r\n },\r\n\r\n getWrapT: function() {\r\n return this._wrapT;\r\n },\r\n\r\n getWrapS: function() {\r\n return this._wrapS;\r\n },\r\n\r\n setWrapS: function(value) {\r\n if (typeof value === 'string') {\r\n this._wrapS = checkAndFixEnum(value, Texture.CLAMP_TO_EDGE);\r\n } else {\r\n this._wrapS = value;\r\n }\r\n\r\n this.dirtyTextureParameters();\r\n },\r\n\r\n setWrapT: function(value) {\r\n if (typeof value === 'string') {\r\n this._wrapT = checkAndFixEnum(value, Texture.CLAMP_TO_EDGE);\r\n } else {\r\n this._wrapT = value;\r\n }\r\n\r\n this.dirtyTextureParameters();\r\n },\r\n\r\n // TODO CP:\r\n // we should split dirty texture object of parameters\r\n // dirty parameters only regenarate parameter\r\n // dirty texture object needs to release a texture and\r\n // re allocate one\r\n dirtyTextureParameters: function() {\r\n this.dirty(); // make everything dirty for now\r\n this.dirtyMipmap();\r\n this.dirtyTextureObject();\r\n },\r\n\r\n dirtyTextureObject: function() {\r\n this._dirtyTextureObject = true;\r\n this.dirtyMipmap();\r\n this.dirty(); // make everything dirty for now\r\n },\r\n\r\n getMinFilter: function() {\r\n return this._minFilter;\r\n },\r\n\r\n getMagFilter: function() {\r\n return this._magFilter;\r\n },\r\n\r\n // https://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt\r\n setMaxAnisotropy: function(multiplier) {\r\n this._maxAnisotropy = multiplier;\r\n this.dirtyTextureParameters();\r\n },\r\n\r\n getMaxAnisotropy: function() {\r\n return this._maxAnisotropy;\r\n },\r\n\r\n // some value enable mipmapping\r\n setMinFilter: function(value) {\r\n if (typeof value === 'string') {\r\n this._minFilter = checkAndFixEnum(value, Texture.LINEAR);\r\n } else {\r\n this._minFilter = value;\r\n }\r\n\r\n this.dirtyTextureParameters();\r\n },\r\n\r\n // Either Linear or nearest.\r\n setMagFilter: function(value) {\r\n if (typeof value === 'string') {\r\n this._magFilter = checkAndFixEnum(value, Texture.LINEAR);\r\n } else {\r\n this._magFilter = value;\r\n }\r\n\r\n this.dirtyTextureParameters();\r\n },\r\n\r\n setImage: function(img, imageFormat) {\r\n var image = img;\r\n if (\r\n img instanceof window.Image ||\r\n img instanceof HTMLCanvasElement ||\r\n img instanceof ImageBitmap ||\r\n img instanceof Uint8Array ||\r\n img instanceof Uint16Array ||\r\n img instanceof Float32Array\r\n ) {\r\n image = new Image(img);\r\n }\r\n\r\n this._image = image;\r\n this.setImageFormat(imageFormat);\r\n if (image) {\r\n if (image.getWidth && image.getHeight) {\r\n this.setTextureSize(image.getWidth(), image.getHeight());\r\n } else if (image.width && image.height) {\r\n this.setTextureSize(image.width, image.height);\r\n }\r\n }\r\n this._textureNull = false;\r\n this.dirty();\r\n },\r\n\r\n getImage: function() {\r\n return this._image;\r\n },\r\n\r\n setImageFormat: function(format) {\r\n var imageFormat = format;\r\n if (imageFormat) {\r\n if (typeof imageFormat === 'string') imageFormat = Texture[imageFormat];\r\n\r\n this._imageFormat = imageFormat;\r\n } else {\r\n this._imageFormat = Texture.RGBA;\r\n }\r\n },\r\n\r\n setInternalFormatType: function(value) {\r\n // UNSIGNED_BYTE, HALF_FLOAT, FLOAT\r\n\r\n if (typeof value === 'string') {\r\n this._type = Texture[value];\r\n } else {\r\n this._type = value;\r\n }\r\n },\r\n\r\n getInternalFormatType: function() {\r\n return this._type;\r\n },\r\n\r\n setUnrefImageDataAfterApply: function(bool) {\r\n this._unrefImageDataAfterApply = bool;\r\n },\r\n\r\n checkIsCompressed: function(format) {\r\n var fo = format || this._internalFormat;\r\n switch (fo) {\r\n case Texture.COMPRESSED_RGB_S3TC_DXT1_EXT:\r\n case Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT:\r\n case Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT:\r\n case Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT:\r\n case Texture.COMPRESSED_RGB_ATC_WEBGL:\r\n case Texture.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:\r\n case Texture.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:\r\n case Texture.COMPRESSED_RGB_PVRTC_4BPPV1_IMG:\r\n case Texture.COMPRESSED_RGB_PVRTC_2BPPV1_IMG:\r\n case Texture.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:\r\n case Texture.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:\r\n case Texture.COMPRESSED_RGB_ETC1_WEBGL:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n },\r\n\r\n setInternalFormat: function(formatSource) {\r\n // RGB, RGBA, ALPHA, LUMINANCE, LUMINANCE_ALPHA\r\n // RGB16F, RGB32F, etc...\r\n // DEPTH_COMPONENT, DEPTH_STENCIL\r\n\r\n var format = formatSource;\r\n if (format) {\r\n if (typeof format === 'string') format = Texture[format];\r\n\r\n this._isCompressed = this.checkIsCompressed(format);\r\n } else {\r\n this._isCompressed = false;\r\n format = Texture.RGBA;\r\n }\r\n\r\n this._internalFormat = format;\r\n },\r\n\r\n getInternalFormat: function() {\r\n return this._internalFormat;\r\n },\r\n\r\n isDirtyMipmap: function() {\r\n return this._dirtyMipmap;\r\n },\r\n\r\n // Will cause the mipmaps to be regenerated on the next bind of the texture\r\n // Nothing will be done if the minFilter is not of the form XXX_MIPMAP_XXX\r\n // TODO : not to be used if the texture is compressed !\r\n dirtyMipmap: function() {\r\n this._dirtyMipmap = true;\r\n },\r\n\r\n applyFilterParameter: function(gl, target) {\r\n var powerOfTwo = isPowerOf2(this._textureWidth) && isPowerOf2(this._textureHeight);\r\n if (!powerOfTwo) {\r\n // NPOT non support in webGL explained here\r\n // https://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support\r\n // so disabling mipmap...\r\n this._wrapT = Texture.CLAMP_TO_EDGE;\r\n this._wrapS = Texture.CLAMP_TO_EDGE;\r\n\r\n if (\r\n this._minFilter === Texture.LINEAR_MIPMAP_LINEAR ||\r\n this._minFilter === Texture.LINEAR_MIPMAP_NEAREST\r\n ) {\r\n this._minFilter = Texture.LINEAR;\r\n }\r\n }\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, this._magFilter);\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, this._minFilter);\r\n\r\n // handle extension EXT_texture_filter_anisotropic\r\n if (this._maxAnisotropy > 1.0 && Texture.ANISOTROPIC_SUPPORT_EXT) {\r\n var multiplier =\r\n this._maxAnisotropy < Texture.ANISOTROPIC_SUPPORT_MAX ?\r\n this._maxAnisotropy :\r\n Texture.ANISOTROPIC_SUPPORT_MAX;\r\n gl.texParameterf(target, Texture.TEXTURE_MAX_ANISOTROPY_EXT, multiplier);\r\n }\r\n\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, this._wrapS);\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, this._wrapT);\r\n },\r\n\r\n generateMipmap: function(gl, target) {\r\n this._dirtyMipmap = false;\r\n if (!this.hasMipmapFilter()) return;\r\n\r\n // manual mipmap provided\r\n var img = this._image;\r\n if (img && img.hasMipmap()) {\r\n var internalFormat = this._getInternalFormatGL();\r\n var mips = img.getMipmap();\r\n for (var level = 1, nbLevel = mips.length; level < nbLevel; level++) {\r\n var imi = mips[level];\r\n if (this._isCompressed)\r\n this.applyTexImage2D(\r\n gl,\r\n this._textureTarget,\r\n level,\r\n internalFormat,\r\n imi.getWidth(),\r\n imi.getHeight(),\r\n 0,\r\n imi.getImage()\r\n );\r\n else\r\n this.applyTexImage2D(\r\n gl,\r\n this._textureTarget,\r\n level,\r\n internalFormat,\r\n imi.getWidth(),\r\n imi.getHeight(),\r\n 0,\r\n this._internalFormat,\r\n this._type,\r\n imi.getImage()\r\n );\r\n }\r\n } else {\r\n // automatic mipmap\r\n gl.generateMipmap(target);\r\n }\r\n },\r\n\r\n // return true if contains a mipmap filter\r\n hasMipmapFilter: function() {\r\n return (\r\n this._minFilter === Texture.NEAREST_MIPMAP_NEAREST ||\r\n this._minFilter === Texture.LINEAR_MIPMAP_NEAREST ||\r\n this._minFilter === Texture.NEAREST_MIPMAP_LINEAR ||\r\n this._minFilter === Texture.LINEAR_MIPMAP_LINEAR\r\n );\r\n },\r\n\r\n applyTexImage2D: function(gl) {\r\n var args = Array.prototype.slice.call(arguments, 1);\r\n\r\n // use parameters of pixel store\r\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);\r\n gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._colorSpaceConversion);\r\n\r\n if (this._isCompressed) gl.compressedTexImage2D.apply(gl, args);\r\n else gl.texImage2D.apply(gl, args);\r\n\r\n // call a callback when upload is done if there is one\r\n var numCallback = this._applyTexImage2DCallbacks.length;\r\n if (numCallback > 0) {\r\n for (var i = 0, l = numCallback; i < l; i++) {\r\n this._applyTexImage2DCallbacks[i].call(this);\r\n }\r\n }\r\n },\r\n\r\n computeTextureFormat: function() {\r\n if (!this._internalFormat) {\r\n this._internalFormat = this._imageFormat || Texture.RGBA;\r\n this._imageFormat = this._internalFormat;\r\n } else {\r\n this._imageFormat = this._internalFormat;\r\n }\r\n },\r\n\r\n applyImage: function(gl) {\r\n var internalFormat = this._getInternalFormatGL();\r\n var image = this._image || null;\r\n var data = image && this._image.getImage();\r\n\r\n var type = this._getTypeGL();\r\n\r\n if (this._isCompressed) {\r\n this.applyTexImage2D(\r\n gl,\r\n this._textureTarget,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n data\r\n );\r\n } else if (!data || image.isTypedArray()) {\r\n this.applyTexImage2D(\r\n gl,\r\n this._textureTarget,\r\n 0,\r\n internalFormat,\r\n this._textureWidth,\r\n this._textureHeight,\r\n 0,\r\n this._internalFormat,\r\n type,\r\n data\r\n );\r\n } else {\r\n this.applyTexImage2D(\r\n gl,\r\n this._textureTarget,\r\n 0,\r\n internalFormat,\r\n this._internalFormat,\r\n type,\r\n data\r\n );\r\n }\r\n\r\n if (image) image.setDirty(false);\r\n },\r\n\r\n apply: function(state) {\r\n var gl = state.getGraphicContext();\r\n // if need to release the texture\r\n if (this._dirtyTextureObject) {\r\n this.releaseGLObjects();\r\n this._dirtyTextureObject = false;\r\n this.setGraphicContext(gl);\r\n }\r\n\r\n if (this._textureObject !== undefined && !this.isDirty()) {\r\n this._textureObject.bind(gl);\r\n // If we have modified the texture via Rtt or texSubImage2D and _need_ updated mipmaps,\r\n\r\n // image update like video\r\n if (this._image !== undefined && this._image.isDirty()) {\r\n this.applyImage(gl);\r\n this.dirtyMipmap();\r\n }\r\n // then we must regenerate the mipmaps explicitly.\r\n // In all other cases, don't set this flag because it can be costly\r\n if (this.isDirtyMipmap()) {\r\n this.generateMipmap(gl, this._textureTarget);\r\n }\r\n } else if (this._textureNull) {\r\n gl.bindTexture(this._textureTarget, null);\r\n } else {\r\n var image = this._image;\r\n if (image !== undefined) {\r\n // when data is ready we will upload it to the gpu\r\n if (image.isReady()) {\r\n // must be called before init\r\n this.computeTextureFormat();\r\n\r\n var imgWidth = image.getWidth() || this._textureWidth;\r\n var imgHeight = image.getHeight() || this._textureHeight;\r\n\r\n this.setTextureSize(imgWidth, imgHeight);\r\n\r\n if (!this._textureObject) {\r\n this.init(state);\r\n }\r\n\r\n this._textureObject.bind(gl);\r\n\r\n this.applyImage(gl);\r\n this.applyFilterParameter(gl, this._textureTarget);\r\n this.generateMipmap(gl, this._textureTarget);\r\n\r\n if (this._unrefImageDataAfterApply) {\r\n this._image = undefined;\r\n }\r\n\r\n this._dirty = false;\r\n } else {\r\n gl.bindTexture(this._textureTarget, null);\r\n }\r\n } else if (this._textureHeight !== 0 && this._textureWidth !== 0) {\r\n // must be called before init\r\n this.computeTextureFormat();\r\n\r\n if (!this._textureObject) {\r\n this.init(state);\r\n }\r\n this._textureObject.bind(gl);\r\n\r\n this.applyImage(gl);\r\n\r\n this.applyFilterParameter(gl, this._textureTarget);\r\n this.generateMipmap(gl, this._textureTarget);\r\n this._dirty = false;\r\n }\r\n }\r\n },\r\n\r\n _getInternalFormatGL: function() {\r\n var internalFormat = this._internalFormat;\r\n\r\n // gl1\r\n if (!WebglCaps.instance().isWebGL2()) {\r\n return internalFormatGl2ToGl1[internalFormat] || internalFormat;\r\n }\r\n\r\n // gl2\r\n var map = internalFormatGl1ToGl2[this._type];\r\n return (map && map[internalFormat]) || internalFormat;\r\n },\r\n\r\n _getTypeGL: function() {\r\n if (this._type === Texture.HALF_FLOAT && !WebglCaps.instance().isWebGL2())\r\n return Texture.HALF_FLOAT_OES;\r\n return this._type;\r\n }\r\n })\r\n ),\r\n 'osg',\r\n 'Texture'\r\n);\r\n\r\nTexture.textureNull = new Texture();\r\n\r\nTexture.createFromImage = function(image, format) {\r\n var a = new Texture();\r\n a.setImage(image, format);\r\n return a;\r\n};\r\n\r\nTexture.createFromCanvas = function(canvas, format) {\r\n return Texture.createFromImage(canvas, format);\r\n};\r\n\r\nexport default Texture;","import ShaderGenerator from '../osgShader/ShaderGenerator';\r\nimport ShadowCompiler from './ShadowCastCompiler';\r\n\r\nvar ShaderGeneratorShadowCast = function() {\r\n ShaderGenerator.apply(this, arguments);\r\n this.setShaderCompiler(ShadowCompiler);\r\n};\r\n\r\nShaderGeneratorShadowCast.prototype = ShaderGenerator.prototype;\r\n\r\nexport default ShaderGeneratorShadowCast;","import utils from './utils';\r\nimport NodeVisitor from './NodeVisitor';\r\n\r\nvar UpdateVisitor = function() {\r\n NodeVisitor.call(this);\r\n this.visitorType = NodeVisitor.UPDATE_VISITOR;\r\n this._numUpdateCallback = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n UpdateVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n resetStats: function() {\r\n this._numUpdateCallback = 0;\r\n },\r\n\r\n apply: function(node) {\r\n // a way to avoid extra call is to implement getNumChildrenRequiringUpdateTraversal\r\n // and stateset.requiresUpdateTraversal()\r\n\r\n // handle callback in stateset\r\n var stateSet = node.getStateSet();\r\n if (stateSet && stateSet.requiresUpdateTraversal()) {\r\n var updateCallbackList = stateSet.getUpdateCallbackList();\r\n\r\n var numStateSetUpdateCallback = updateCallbackList.length;\r\n if (numStateSetUpdateCallback) {\r\n this._numUpdateCallback += numStateSetUpdateCallback;\r\n for (var i = 0, l = numStateSetUpdateCallback; i < l; i++)\r\n updateCallbackList[i].update(stateSet, this);\r\n }\r\n }\r\n\r\n // handle callback in nodes\r\n var ncs = node.getUpdateCallbackList();\r\n var numUpdateCallback = ncs.length;\r\n for (var j = 0; j < numUpdateCallback; j++) {\r\n this._numUpdateCallback++;\r\n if (!ncs[j].update(node, this)) {\r\n return;\r\n }\r\n }\r\n\r\n if (node.getNumChildrenRequiringUpdateTraversal() > 0) this.traverse(node);\r\n }\r\n }),\r\n 'osg',\r\n 'NodeVisitor'\r\n);\r\n\r\nexport default UpdateVisitor;","import utils from './utils';\r\nimport BoundingSphere from './BoundingSphere';\r\nimport Camera from './Camera';\r\nimport ComputeMatrixFromNodePath from './computeMatrixFromNodePath';\r\nimport CullSettings from './CullSettings';\r\nimport CullingSet from './CullingSet';\r\nimport { mat4 } from './glMatrix';\r\nimport Plane from './Plane';\r\nimport Transform from './Transform';\r\nimport TransformEnums from './transformEnums';\r\nimport { vec3 } from './glMatrix';\r\nimport PooledArray from './PooledArray';\r\nimport PooledResource from './PooledResource';\r\nimport PooledMap from './PooledMap';\r\n\r\nvar createCullingSet = function() {\r\n return new CullingSet();\r\n};\r\n\r\nvar CullStack = function() {\r\n this._modelViewMatrixStack = new PooledArray();\r\n this._projectionMatrixStack = new PooledArray();\r\n this._viewportStack = new PooledArray();\r\n this._cullingSetStack = new PooledArray();\r\n this._frustumVolume = -1.0;\r\n this._bbCornerFar = 0;\r\n this._bbCornerNear = 0;\r\n\r\n // keep a matrix in memory to avoid to create matrix\r\n this._pooledMatrix = new PooledResource(mat4.create);\r\n\r\n this._pooledCullingSet = new PooledResource(createCullingSet);\r\n\r\n // data for caching camera matrix inverse for computation of world/view\r\n // contains index of the camera node in the nodepath\r\n this._cameraIndexStack = new PooledArray();\r\n\r\n // contains index of the camera modelview matrix in the modelViewMatrixStack\r\n this._cameraModelViewIndexStack = new PooledArray();\r\n\r\n // contains the id has a key to computed Inverse Matrix\r\n this._cameraMatrixInverse = new PooledMap();\r\n this._cameraMatrixInverseRoot = undefined;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n CullStack,\r\n utils.objectInherit(CullSettings.prototype, {\r\n reset: function() {\r\n this._modelViewMatrixStack.reset();\r\n this._projectionMatrixStack.reset();\r\n this._cullingSetStack.reset();\r\n\r\n this._pooledMatrix.reset();\r\n this._pooledCullingSet.reset();\r\n\r\n this._cameraModelViewIndexStack.reset();\r\n this._cameraIndexStack.reset();\r\n\r\n this._cameraMatrixInverse.reset();\r\n\r\n this._cameraMatrixInverseRoot = undefined;\r\n },\r\n\r\n getProjectionMatrixStack: function() {\r\n return this._projectionMatrixStack;\r\n },\r\n getCurrentProjectionMatrix: function() {\r\n return this._projectionMatrixStack.back();\r\n },\r\n\r\n getCurrentModelViewMatrix: function() {\r\n return this._modelViewMatrixStack.back();\r\n },\r\n\r\n getCameraInverseMatrix: function() {\r\n // Return or compute and cache the MatrixInverse of the last\r\n // active camera in absolute reference\r\n\r\n // if no index the camera inverse is the root with an fake id\r\n if (!this._cameraIndexStack.getLength()) return this._cameraMatrixInverseRoot;\r\n\r\n var idx = this._cameraIndexStack.back();\r\n\r\n // get the camera node\r\n var camera = this.getNodePath()[idx];\r\n var id = camera.getInstanceID();\r\n\r\n var mapCameraInverse = this._cameraMatrixInverse.getMap();\r\n var cameraInverse = mapCameraInverse[id];\r\n\r\n if (cameraInverse === undefined) {\r\n var indexInModelViewMatrixStack = this._cameraModelViewIndexStack.back();\r\n var mat = this._modelViewMatrixStack.getArray()[indexInModelViewMatrixStack];\r\n cameraInverse = this._pooledMatrix.getOrCreateObject();\r\n mat4.invert(cameraInverse, mat);\r\n this._cameraMatrixInverse.set(id, cameraInverse);\r\n }\r\n return cameraInverse;\r\n },\r\n\r\n getCurrentModelMatrix: function() {\r\n // Improvment could be to cache more things\r\n // and / or use this method only if the shader use it\r\n var invMatrix = this.getCameraInverseMatrix();\r\n var m = this._pooledMatrix.getOrCreateObject();\r\n var world = mat4.mul(m, invMatrix, this.getCurrentModelViewMatrix());\r\n return world;\r\n },\r\n\r\n getCurrentViewMatrix: function() {\r\n // Improvment could be to cache more things\r\n // and / or use this method only if the shader use it\r\n var modelViewMatrixStackArray = this._modelViewMatrixStack.getArray();\r\n if (!this._cameraIndexStack.getLength()) return modelViewMatrixStackArray[0];\r\n\r\n // also we could keep the index of the current to avoid lenght-1 at each access\r\n // it's implemented in osg like that:\r\n // https://github.com/openscenegraph/osg/blob/master/include/osg/fast_back_stack\r\n return modelViewMatrixStackArray[this._cameraModelViewIndexStack.back()];\r\n },\r\n\r\n getViewport: function() {\r\n if (this._viewportStack.getLength() === 0) {\r\n return undefined;\r\n }\r\n return this._viewportStack.back();\r\n },\r\n getLookVectorLocal: function(outLookVector) {\r\n var lookVectorLocal = this.getCurrentModelViewMatrix();\r\n return vec3.set(\r\n outLookVector, -lookVectorLocal[2], -lookVectorLocal[6], -lookVectorLocal[10]\r\n );\r\n },\r\n pushViewport: function(vp) {\r\n this._viewportStack.push(vp);\r\n },\r\n popViewport: function() {\r\n this._viewportStack.pop();\r\n },\r\n\r\n getFrustumPlanes: (function() {\r\n var mvp = mat4.create();\r\n\r\n return function(out, projection, view, withNearFar) {\r\n mat4.mul(mvp, projection, view);\r\n\r\n var computeNearFar = !!withNearFar;\r\n\r\n // Right clipping plane.\r\n var right = out[0];\r\n right[0] = mvp[3] - mvp[0];\r\n right[1] = mvp[7] - mvp[4];\r\n right[2] = mvp[11] - mvp[8];\r\n right[3] = mvp[15] - mvp[12];\r\n\r\n // Left clipping plane.\r\n var left = out[1];\r\n left[0] = mvp[3] + mvp[0];\r\n left[1] = mvp[7] + mvp[4];\r\n left[2] = mvp[11] + mvp[8];\r\n left[3] = mvp[15] + mvp[12];\r\n\r\n // Bottom clipping plane.\r\n var bottom = out[2];\r\n bottom[0] = mvp[3] + mvp[1];\r\n bottom[1] = mvp[7] + mvp[5];\r\n bottom[2] = mvp[11] + mvp[9];\r\n bottom[3] = mvp[15] + mvp[13];\r\n\r\n // Top clipping plane.\r\n var top = out[3];\r\n top[0] = mvp[3] - mvp[1];\r\n top[1] = mvp[7] - mvp[5];\r\n top[2] = mvp[11] - mvp[9];\r\n top[3] = mvp[15] - mvp[13];\r\n\r\n if (computeNearFar) {\r\n // Far clipping plane.\r\n var far = out[4];\r\n far[0] = mvp[3] - mvp[2];\r\n far[1] = mvp[7] - mvp[6];\r\n far[2] = mvp[11] - mvp[10];\r\n far[3] = mvp[15] - mvp[14];\r\n\r\n // Near clipping plane.\r\n var near = out[5];\r\n near[0] = mvp[3] + mvp[2];\r\n near[1] = mvp[7] + mvp[6];\r\n near[2] = mvp[11] + mvp[10];\r\n near[3] = mvp[15] + mvp[14];\r\n }\r\n\r\n //Normalize the planes\r\n var j = withNearFar ? 6 : 4;\r\n for (var i = 0; i < j; i++) {\r\n Plane.normalizeEquation(out[i]);\r\n }\r\n };\r\n })(),\r\n\r\n pushCullingSet: function() {\r\n var cs = this._pooledCullingSet.getOrCreateObject();\r\n if (this._enableFrustumCulling) {\r\n mat4.getFrustumPlanes(\r\n cs.getFrustum().getPlanes(),\r\n this.getCurrentProjectionMatrix(),\r\n this.getCurrentModelViewMatrix(),\r\n false\r\n );\r\n // TODO: no far no near.\r\n // should check if we have them\r\n // should add at least a near 0 clip if not\r\n cs.getFrustum().setupMask(4);\r\n }\r\n\r\n this._cullingSetStack.push(cs);\r\n },\r\n popCullingSet: function() {\r\n return this._cullingSetStack.pop();\r\n },\r\n getCurrentCullingSet: function() {\r\n return this._cullingSetStack.back();\r\n },\r\n\r\n pushCurrentMask: function() {\r\n var cs = this.getCurrentCullingSet();\r\n if (cs) cs.pushCurrentMask();\r\n },\r\n popCurrentMask: function() {\r\n var cs = this.getCurrentCullingSet();\r\n if (cs) cs.popCurrentMask();\r\n },\r\n\r\n isVerticesCulled: function(vertices) {\r\n if (!this._enableFrustumCulling) return false;\r\n return this.getCurrentCullingSet().isVerticesCulled(vertices);\r\n },\r\n\r\n isBoundingBoxCulled: function(bb) {\r\n if (!this._enableFrustumCulling) return false;\r\n return bb.valid() && this.getCurrentCullingSet().isBoundingBoxCulled(bb);\r\n },\r\n\r\n isBoundingSphereCulled: function(bs) {\r\n if (!this._enableFrustumCulling) return false;\r\n return bs.valid() && this.getCurrentCullingSet().isBoundingSphereCulled(bs);\r\n },\r\n\r\n isCulled: (function() {\r\n var bsWorld = new BoundingSphere();\r\n return function(node, nodePath) {\r\n if (!this._enableFrustumCulling) return false;\r\n if (node.isCullingActive()) {\r\n if (this.getCurrentCullingSet().getCurrentResultMask() === 0) return false; // father bounding sphere totally inside\r\n\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n mat4.identity(matrix);\r\n\r\n var maxNodePathLength = nodePath.length;\r\n if (node instanceof Transform) {\r\n // MatrixTransform getBound is already transformed to\r\n // its local space whereas nodepath also have its matrix ...\r\n // so to get world space, you HAVE to remove that matrix from nodePATH\r\n maxNodePathLength--;\r\n }\r\n\r\n ComputeMatrixFromNodePath.computeLocalToWorld(\r\n nodePath,\r\n true,\r\n matrix,\r\n maxNodePathLength\r\n );\r\n\r\n node.getBound().transformMat4(bsWorld, matrix);\r\n\r\n return this.getCurrentCullingSet().isBoundingSphereCulled(bsWorld);\r\n } else {\r\n this.getCurrentCullingSet().resetCullingMask();\r\n return false;\r\n }\r\n };\r\n })(),\r\n\r\n pushModelViewMatrix: (function() {\r\n var lookVector = vec3.create();\r\n return function(matrix) {\r\n // When pushing a matrix, it can be a transform or camera. To compute\r\n // differents matrix type in shader ( ViewMatrix/ModelMatrix/ModelViewMatrix )\r\n // we track camera node when using pushModelViewMatrix\r\n // To detect a camera, we check on the nodepath the type of the node and if the\r\n // camera is relatif or absolute.\r\n // When we detect an absolute camera we keep it's index to get it when needed to\r\n // compute the World/View matrix\r\n // There is an exception for the root camera, the root camera is not pushed on the\r\n // CullVisitor but only its matrixes, so to handle this we compute the inverse camera\r\n // when the nodepath has a lenght of 0\r\n // To avoid to compute too much inverse matrix, we keep a cache of them during the\r\n // traverse and store the result under the instanceID key, except for the root\r\n var np = this.getNodePath();\r\n var length = np.length;\r\n if (!length) {\r\n // root\r\n var matInverse = this._pooledMatrix.getOrCreateObject();\r\n mat4.invert(matInverse, matrix);\r\n this._cameraMatrixInverseRoot = matInverse;\r\n } else {\r\n var index = length - 1;\r\n if (\r\n np[index].getTypeID() === Camera.getTypeID() &&\r\n np[index].getReferenceFrame() === TransformEnums.ABSOLUTE_RF\r\n ) {\r\n this._cameraIndexStack.push(index);\r\n this._cameraModelViewIndexStack.push(\r\n this._modelViewMatrixStack.getLength()\r\n );\r\n }\r\n }\r\n\r\n this._modelViewMatrixStack.push(matrix);\r\n this.getLookVectorLocal(lookVector);\r\n\r\n /*jshint bitwise: false */\r\n this._bbCornerFar =\r\n (lookVector[0] >= 0 ? 1 : 0) |\r\n (lookVector[1] >= 0 ? 2 : 0) |\r\n (lookVector[2] >= 0 ? 4 : 0);\r\n this._bbCornerNear = ~this._bbCornerFar & 7;\r\n /*jshint bitwise: true */\r\n };\r\n })(),\r\n popModelViewMatrix: (function() {\r\n var lookVector = vec3.create();\r\n\r\n return function() {\r\n // if same index it's a camera and we have to pop it\r\n var np = this.getNodePath();\r\n var index = np.length - 1;\r\n if (this._cameraIndexStack.getLength() && index === this._cameraIndexStack.back()) {\r\n this._cameraIndexStack.pop();\r\n this._cameraModelViewIndexStack.pop();\r\n }\r\n\r\n this._modelViewMatrixStack.pop();\r\n\r\n if (this._modelViewMatrixStack.getLength()) {\r\n this.getLookVectorLocal(lookVector);\r\n } else {\r\n vec3.set(lookVector, 0.0, 0.0, -1.0);\r\n }\r\n\r\n /*jshint bitwise: false */\r\n this._bbCornerFar =\r\n (lookVector[0] >= 0.0 ? 1 : 0) |\r\n (lookVector[1] >= 0.0 ? 2 : 0) |\r\n (lookVector[2] >= 0.0 ? 4 : 0);\r\n this._bbCornerNear = ~this._bbCornerFar & 7;\r\n /*jshint bitwise: true */\r\n };\r\n })(),\r\n\r\n pushProjectionMatrix: function(matrix) {\r\n this._projectionMatrixStack.push(matrix);\r\n\r\n // need to recompute frustum volume.\r\n this._frustumVolume = -1.0;\r\n\r\n this.pushCullingSet();\r\n },\r\n popProjectionMatrix: function() {\r\n this._projectionMatrixStack.pop();\r\n\r\n // need to recompute frustum volume.\r\n this._frustumVolume = -1.0;\r\n\r\n this.popCullingSet();\r\n }\r\n }),\r\n 'osg',\r\n 'CullStack'\r\n);\r\n\r\nexport default CullStack;","import P from 'bluebird';\r\nimport utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport PagedLOD from '../osg/PagedLOD';\r\nimport Timer from '../osg/Timer';\r\n\r\nvar FindPagedLODsVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n this._activePagedLODList = undefined;\r\n this._frameNumber = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n FindPagedLODsVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getTypeID() === PagedLOD.getTypeID()) {\r\n node.setFrameNumberOfLastTraversal(this._frameNumber);\r\n this._activePagedLODList.add(node);\r\n }\r\n this.traverse(node);\r\n },\r\n set: function(pagedLODList, frameNumber) {\r\n this._activePagedLODList = pagedLODList;\r\n this._frameNumber = frameNumber;\r\n }\r\n }),\r\n 'osgDB',\r\n 'FindPagedLODsVisitor'\r\n);\r\n\r\nvar ReleaseVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ReleaseVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n // mark GLResources in nodes to be released\r\n node.releaseGLObjects();\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgDB',\r\n 'ReleaseVisitor'\r\n);\r\n\r\nvar ExpiredPagedLODVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n this._childrenList = [];\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ExpiredPagedLODVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getTypeID() === PagedLOD.getTypeID()) {\r\n this._childrenList.push(node);\r\n this._markRequestsExpired(node);\r\n }\r\n this.traverse(node);\r\n },\r\n\r\n removeExpiredChildrenAndFindPagedLODs: function(\r\n plod,\r\n expiryTime,\r\n expiryFrame,\r\n removedChildren\r\n ) {\r\n if (!plod.children.length) return false;\r\n\r\n var sizeBefore = removedChildren.length;\r\n plod.removeExpiredChildren(expiryTime, expiryFrame, removedChildren);\r\n for (var i = sizeBefore; i < removedChildren.length; i++) {\r\n removedChildren[i].accept(this);\r\n }\r\n return sizeBefore !== removedChildren.length;\r\n },\r\n\r\n _markRequestsExpired: function(plod) {\r\n var numRanges = plod._perRangeDataList.length;\r\n var request;\r\n for (var i = 0; i < numRanges; i++) {\r\n request = plod.getDatabaseRequest(i);\r\n if (request !== undefined) {\r\n request._groupExpired = true;\r\n request._loadedModel = null;\r\n }\r\n }\r\n },\r\n reset: function() {\r\n this._childrenList.length = 0;\r\n }\r\n }),\r\n 'osgDB',\r\n 'ExpiredPagedLODVisitor'\r\n);\r\n\r\n// Helper functions to avoid undesired memory allocation\r\nvar sortByTimeStamp = function(r1, r2) {\r\n return r2._timeStamp - r1._timeStamp;\r\n};\r\nvar sortByPriority = function(r1, r2) {\r\n // Ask for newer requests first.\r\n var value = r1._timeStamp - r2._timeStamp;\r\n // Ask for the greater priority if the timestamp is the same.\r\n if (value === 0) {\r\n value = r1._priority - r2._priority;\r\n }\r\n return value;\r\n};\r\n\r\n/**\r\n * Database paging class which manages the loading of files\r\n * and synchronizing of loaded models with the main scene graph.\r\n * @class DatabasePager\r\n */\r\nvar DatabasePager = function() {\r\n this._pendingRequests = [];\r\n this._pendingNodes = [];\r\n this._loading = false;\r\n this._progressCallback = undefined;\r\n this._lastCB = true;\r\n this._activePagedLODList = new Set();\r\n this._childrenToRemoveList = new Set();\r\n this._downloadingRequestsNumber = 0;\r\n this._maxRequestsPerFrame = 10;\r\n this._acceptNewRequests = true;\r\n this._releaseVisitor = new ReleaseVisitor();\r\n this._expiredPagedLODVisitor = new ExpiredPagedLODVisitor();\r\n this._findPagedLODsVisitor = new FindPagedLODsVisitor();\r\n // In OSG the targetMaximumNumberOfPagedLOD is 300 by default\r\n // here we set 75 as we need to be more strict with memory in a browser\r\n // This value can be setted using setTargetMaximumNumberOfPageLOD method.\r\n this._targetMaximumNumberOfPagedLOD = 75;\r\n // Helper variables to avoid memory allocation, not for user access\r\n this._elapsedTime = 0;\r\n this._beginTime = 0;\r\n this._availableTime = 0;\r\n};\r\n\r\nvar DatabaseRequest = function() {\r\n this._loadedModel = undefined;\r\n this._group = undefined;\r\n this._url = undefined;\r\n this._function = undefined;\r\n this._timeStamp = 0.0;\r\n this._groupExpired = false;\r\n this._priority = 0.0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n DatabasePager, {\r\n setTargetMaximumNumberOfPageLOD: function(target) {\r\n this._targetMaximumNumberOfPagedLOD = target;\r\n },\r\n\r\n getTargetMaximumNumberOfPageLOD: function() {\r\n return this._targetMaximumNumberOfPagedLOD;\r\n },\r\n\r\n setAcceptNewDatabaseRequests: function(acceptNewRequests) {\r\n this._acceptNewRequests = acceptNewRequests;\r\n },\r\n getAcceptNewDatabaseRequests: function() {\r\n return this._acceptNewRequests;\r\n },\r\n reset: function() {\r\n this._pendingRequests = [];\r\n this._pendingNodes = [];\r\n this._loading = false;\r\n this._lastCB = true;\r\n this._activePagedLODList.clear();\r\n this._childrenToRemoveList.clear();\r\n this._downloadingRequestsNumber = 0;\r\n this._maxRequestsPerFrame = 10;\r\n this._acceptNewRequests = true;\r\n this._targetMaximumNumberOfPagedLOD = 75;\r\n },\r\n\r\n updateSceneGraph: function(frameStamp) {\r\n // Progress callback\r\n if (this._progressCallback !== undefined) {\r\n // Maybe we should encapsulate this in a promise.\r\n this.executeProgressCallback();\r\n }\r\n // We need to control the time spent in DatabasePager tasks to\r\n // avoid making the rendering slow.\r\n // Probably we can have a time parameter to manage all the tasks.\r\n // Now it is fixed to 0.0025 ms to remove expired childs\r\n // and 0.005 ms to add to the scene the loaded requests.\r\n\r\n // Remove expired nodes\r\n this.removeExpiredSubgraphs(frameStamp, 0.0025);\r\n // Time to do the requests.\r\n this.takeRequests();\r\n // Add the loaded data to the graph\r\n this.addLoadedDataToSceneGraph(frameStamp, 0.005);\r\n },\r\n\r\n executeProgressCallback: function() {\r\n if (this._pendingRequests.length > 0 || this._pendingNodes.length > 0) {\r\n this._progressCallback(\r\n this._pendingRequests.length + this._downloadingRequestsNumber,\r\n this._pendingNodes.length\r\n );\r\n this._lastCB = false;\r\n } else {\r\n if (!this._lastCB) {\r\n this._progressCallback(\r\n this._pendingRequests.length + this._downloadingRequestsNumber,\r\n this._pendingNodes.length\r\n );\r\n this._lastCB = true;\r\n }\r\n }\r\n },\r\n\r\n setMaxRequestsPerFrame: function(numRequests) {\r\n this._maxRequestsPerFrame = numRequests;\r\n },\r\n\r\n getMaxRequestsPerFrame: function() {\r\n return this._maxRequestsPerFrame;\r\n },\r\n\r\n getRequestListSize: function() {\r\n return this._pendingRequests.length + this._downloadingRequestsNumber;\r\n },\r\n\r\n setProgressCallback: function(cb) {\r\n this._progressCallback = cb;\r\n },\r\n\r\n addLoadedDataToSceneGraph: function(frameStamp, availableTime) {\r\n if (!this._pendingNodes.length || availableTime <= 0.0) return 0.0;\r\n\r\n // Prune the list of database requests.\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n this._pendingNodes.sort(sortByTimeStamp);\r\n\r\n for (var i = 0; i < this._pendingNodes.length; i++) {\r\n if (elapsedTime > availableTime) return 0.0;\r\n\r\n var request = this._pendingNodes.shift();\r\n var frameNumber = frameStamp.getFrameNumber();\r\n var timeStamp = frameStamp.getSimulationTime();\r\n\r\n // If the request is not expired, then add/register new childs\r\n if (request._groupExpired === false) {\r\n var plod = request._group;\r\n plod.setTimeStamp(plod.children.length, timeStamp);\r\n plod.setFrameNumber(plod.children.length, frameNumber);\r\n plod.addChildNode(request._loadedModel);\r\n\r\n // Register PagedLODs.\r\n if (!this._activePagedLODList.has(plod)) {\r\n this.registerPagedLODs(plod, frameNumber);\r\n } else {\r\n this.registerPagedLODs(request._loadedModel, frameNumber);\r\n }\r\n } else {\r\n // Clean the request\r\n request._loadedModel = undefined;\r\n request = undefined;\r\n }\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n availableTime -= elapsedTime;\r\n return availableTime;\r\n },\r\n\r\n isLoading: function() {\r\n return this._loading;\r\n },\r\n\r\n registerPagedLODs: function(subgraph, frameNumber) {\r\n if (!subgraph) return;\r\n this._findPagedLODsVisitor.set(this._activePagedLODList, frameNumber);\r\n subgraph.accept(this._findPagedLODsVisitor);\r\n },\r\n\r\n requestNodeFile: function(func, url, node, timestamp, priority) {\r\n // Check if we are currently accepting requests.\r\n if (!this._acceptNewRequests) return undefined;\r\n // We don't need to determine if the dbrequest is in the queue\r\n // That is already done in the PagedLOD, so we just create the request\r\n var dbrequest = new DatabaseRequest();\r\n dbrequest._group = node;\r\n dbrequest._function = func;\r\n dbrequest._url = url;\r\n dbrequest._timeStamp = timestamp;\r\n dbrequest._priority = priority;\r\n this._pendingRequests.push(dbrequest);\r\n return dbrequest;\r\n },\r\n\r\n takeRequests: function() {\r\n if (this._pendingRequests.length) {\r\n var numRequests = Math.min(this._maxRequestsPerFrame, this._pendingRequests.length);\r\n this._pendingRequests.sort(sortByPriority);\r\n for (var i = 0; i < numRequests; i++) {\r\n this._downloadingRequestsNumber++;\r\n this.processRequest(this._pendingRequests.shift());\r\n }\r\n }\r\n },\r\n\r\n processRequest: function(dbrequest) {\r\n this._loading = true;\r\n var that = this;\r\n // Check if the request is valid;\r\n if (dbrequest._groupExpired) {\r\n //Notify.log( 'DatabasePager::processRequest() Request expired.' );\r\n that._downloadingRequestsNumber--;\r\n this._loading = false;\r\n return;\r\n }\r\n\r\n // Load from function\r\n if (dbrequest._function !== undefined) {\r\n this.loadNodeFromFunction(dbrequest._function, dbrequest._group).then(function(\r\n child\r\n ) {\r\n that._downloadingRequestsNumber--;\r\n dbrequest._loadedModel = child;\r\n that._pendingNodes.push(dbrequest);\r\n that._loading = false;\r\n });\r\n } else if (dbrequest._url !== '') {\r\n // Load from URL\r\n this.loadNodeFromURL(dbrequest._url).then(function(child) {\r\n that._downloadingRequestsNumber--;\r\n dbrequest._loadedModel = child;\r\n that._pendingNodes.push(dbrequest);\r\n that._loading = false;\r\n });\r\n }\r\n },\r\n\r\n loadNodeFromFunction: function(func, plod) {\r\n // Need to call with pagedLOD as parent, to be able to have multiresolution structures.\r\n var promise = func(plod);\r\n // should func always return a promise ?\r\n if (!promise) return P.reject();\r\n if (promise && promise.then) return promise;\r\n return P.resolve(promise);\r\n },\r\n\r\n loadNodeFromURL: function(url) {\r\n var ReaderParser = require('./readerParser').default;\r\n // Call to ReaderParser just in case there is a custom readNodeURL Callback\r\n // See osgDB/options.js and/or osgDB/Input.js\r\n // TODO: We should study if performance can be improved if separating the XHTTP request from\r\n // the parsing. This way several/many request could be done at the same time.\r\n // Also we should be able to cancel requests, so there is a need to have access\r\n // to the HTTPRequest Object\r\n return ReaderParser.readNodeURL(url);\r\n },\r\n\r\n releaseGLExpiredSubgraphs: function(availableTime) {\r\n this._availableTime = availableTime;\r\n if (!this._childrenToRemoveList.size || availableTime <= 0.0) return 0.0;\r\n // We need to test if we have time to flush\r\n this._elapsedTime = 0.0;\r\n this._beginTime = Timer.instance().tick();\r\n this._childrenToRemoveList.forEach(this._releaseExpiredSubgraphs, this);\r\n this._availableTime -= this._elapsedTime;\r\n return this._availableTime;\r\n },\r\n\r\n // function to avoid memory allocation in forEach\r\n _releaseExpiredSubgraphs: function(node) {\r\n // If we don't have more time, break the loop.\r\n if (this._elapsedTime > this._availableTime) return;\r\n this._childrenToRemoveList.delete(node);\r\n node.accept(this._releaseVisitor);\r\n node.removeChildren();\r\n node = null;\r\n this._elapsedTime = Timer.instance().deltaS(this._beginTime, Timer.instance().tick());\r\n },\r\n\r\n removeExpiredSubgraphs: function(frameStamp, availableTime) {\r\n if (frameStamp.getFrameNumber() === 0) return 0.0;\r\n var numToPrune = this._activePagedLODList.size - this._targetMaximumNumberOfPagedLOD;\r\n var expiryTime = frameStamp.getSimulationTime() - 0.1;\r\n var expiryFrame = frameStamp.getFrameNumber() - 1;\r\n // First traverse and remove inactive PagedLODs, as their children will\r\n // certainly have expired.\r\n // TODO: Then traverse active nodes if we still need to prune.\r\n if (numToPrune > 0) {\r\n availableTime = this.removeExpiredChildren(\r\n numToPrune,\r\n expiryTime,\r\n expiryFrame,\r\n availableTime\r\n );\r\n }\r\n return availableTime;\r\n },\r\n\r\n removeExpiredChildren: function(numToPrune, expiryTime, expiryFrame, availableTime) {\r\n // Iterate over the activePagedLODList to remove expired children\r\n // We need to control the time spent in remove childs.\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var that = this;\r\n var removedChildren = [];\r\n var expiredPagedLODVisitor = this._expiredPagedLODVisitor;\r\n expiredPagedLODVisitor.reset();\r\n\r\n this._activePagedLODList.forEach(function(plod) {\r\n // Check if we have time, else return 0\r\n if (elapsedTime > availableTime) return 0.0;\r\n if (numToPrune < 0) return availableTime;\r\n // See if plod is still active, so we don't have to prune\r\n if (expiryFrame < plod.getFrameNumberOfLastTraversal()) return availableTime;\r\n expiredPagedLODVisitor.removeExpiredChildrenAndFindPagedLODs(\r\n plod,\r\n expiryTime,\r\n expiryFrame,\r\n removedChildren\r\n );\r\n for (var i = 0; i < expiredPagedLODVisitor._childrenList.length; i++) {\r\n that._activePagedLODList.delete(expiredPagedLODVisitor._childrenList[i]);\r\n numToPrune--;\r\n }\r\n // Add to the remove list all the childs deleted\r\n for (i = 0; i < removedChildren.length; i++) {\r\n that._childrenToRemoveList.add(removedChildren[i]);\r\n }\r\n expiredPagedLODVisitor._childrenList.length = 0;\r\n removedChildren.length = 0;\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n });\r\n availableTime -= elapsedTime;\r\n return availableTime;\r\n }\r\n },\r\n 'osgDB',\r\n 'DatabasePager'\r\n);\r\n\r\nexport default DatabasePager;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\nimport Uniform from './Uniform';\r\nimport { mat3 } from './glMatrix';\r\nimport { mat4 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\nimport { vec4 } from './glMatrix';\r\n\r\n// use the same kind of opengl lights\r\n// see http://www.glprogramming.com/red/chapter05.html\r\n\r\nvar Light = function(lightNum, disable) {\r\n StateAttribute.call(this);\r\n\r\n var lightNumber = lightNum !== undefined ? lightNum : 0;\r\n\r\n this._ambient = vec4.fromValues(0.2, 0.2, 0.2, 1.0);\r\n this._diffuse = vec4.fromValues(0.8, 0.8, 0.8, 1.0);\r\n this._specular = vec4.fromValues(0.2, 0.2, 0.2, 1.0);\r\n\r\n // Default is directional as postion[3] is 0\r\n this._position = vec4.fromValues(0.0, 0.0, 1.0, 0.0);\r\n this._direction = vec3.fromValues(0.0, 0.0, -1.0);\r\n\r\n // TODO : refactor lights management w=1.0 (isHemi), w=-1.0\r\n // (isNotHemi) _ground contains the color but w says if it's\r\n // an hemi or not\r\n this._ground = vec4.fromValues(0.2, 0.2, 0.2, -1.0);\r\n\r\n this._spotCutoff = 180.0;\r\n this._spotBlend = 0.01;\r\n\r\n // the array contains constant, linear, quadratic factor\r\n this._attenuation = vec4.fromValues(1.0, 0.0, 0.0, 0.0);\r\n\r\n this._lightNumber = lightNumber;\r\n\r\n this._enable = !disable;\r\n this._dirtyHash = true;\r\n this._hash = '';\r\n};\r\n\r\nLight.DIRECTION = 'DIRECTION';\r\nLight.SPOT = 'SPOT';\r\nLight.POINT = 'POINT';\r\nLight.HEMI = 'HEMI';\r\n\r\nLight.uniforms = {};\r\nutils.createPrototypeStateAttribute(\r\n Light,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Light',\r\n\r\n cloneType: function() {\r\n return new Light(this._lightNumber, true);\r\n },\r\n\r\n getTypeMember: function() {\r\n return this.attributeType + this._lightNumber;\r\n },\r\n\r\n getUniformName: function(name) {\r\n return 'u' + this.getTypeMember() + '_' + name;\r\n },\r\n\r\n getHash: function() {\r\n if (!this._dirtyHash) return this._hash;\r\n\r\n this._hash = this._computeInternalHash();\r\n this._dirtyHash = false;\r\n return this._hash;\r\n },\r\n\r\n _computeInternalHash: function() {\r\n return this.getTypeMember() + this.getLightType() + this.isEnabled().toString();\r\n },\r\n getOrCreateUniforms: function() {\r\n var obj = Light;\r\n var typeMember = this.getTypeMember();\r\n\r\n if (obj.uniforms[typeMember]) return obj.uniforms[typeMember];\r\n\r\n obj.uniforms[typeMember] = {\r\n viewPosition: Uniform.createFloat4(this.getUniformName('viewPosition')),\r\n viewDirection: Uniform.createFloat3(this.getUniformName('viewDirection')),\r\n modelViewMatrix: Uniform.createMatrix4(this.getUniformName('modelViewMatrix')),\r\n modelViewNormalMatrix: Uniform.createMatrix3(\r\n this.getUniformName('modelViewNormalMatrix')\r\n ),\r\n\r\n ambient: Uniform.createFloat4(this.getUniformName('ambient')),\r\n diffuse: Uniform.createFloat4(this.getUniformName('diffuse')),\r\n specular: Uniform.createFloat4(this.getUniformName('specular')),\r\n attenuation: Uniform.createFloat4(this.getUniformName('attenuation')),\r\n\r\n spotCutOff: Uniform.createFloat1(this.getUniformName('spotCutOff')),\r\n spotBlend: Uniform.createFloat1(this.getUniformName('spotBlend')),\r\n ground: Uniform.createFloat4(this.getUniformName('ground'))\r\n };\r\n\r\n return obj.uniforms[typeMember];\r\n },\r\n\r\n // enable / disable is not implemented in uniform\r\n // we should add it\r\n isEnabled: function() {\r\n return this._enable;\r\n },\r\n\r\n setEnabled: function(bool) {\r\n this._enable = bool;\r\n this._dirtyHash = true;\r\n },\r\n\r\n // colors\r\n setAmbient: function(a) {\r\n vec4.copy(this._ambient, a);\r\n },\r\n\r\n getAmbient: function() {\r\n return this._ambient;\r\n },\r\n\r\n setDiffuse: function(a) {\r\n vec4.copy(this._diffuse, a);\r\n },\r\n\r\n getDiffuse: function() {\r\n return this._diffuse;\r\n },\r\n\r\n setSpecular: function(a) {\r\n vec4.copy(this._specular, a);\r\n },\r\n\r\n getSpecular: function() {\r\n return this._specular;\r\n },\r\n\r\n // position, also used for directional light\r\n // position[3] === 0 means directional\r\n // see creating lightsources http://www.glprogramming.com/red/chapter05.html\r\n setPosition: function(a) {\r\n vec4.copy(this._position, a);\r\n },\r\n\r\n getPosition: function() {\r\n return this._position;\r\n },\r\n\r\n // unused for directional\r\n setDirection: function(a) {\r\n vec3.copy(this._direction, a);\r\n },\r\n\r\n getDirection: function() {\r\n return this._direction;\r\n },\r\n\r\n setSpotCutoff: function(a) {\r\n this._spotCutoff = a;\r\n },\r\n\r\n getSpotCutoff: function() {\r\n return this._spotCutoff;\r\n },\r\n\r\n setSpotBlend: function(a) {\r\n this._spotBlend = a;\r\n },\r\n\r\n getSpotBlend: function() {\r\n return this._spotBlend;\r\n },\r\n\r\n // set/get the color of the ground\r\n setGround: function(a) {\r\n vec3.copy(this._ground, a);\r\n },\r\n\r\n getGround: function() {\r\n return this._ground;\r\n },\r\n\r\n // attenuation coeff\r\n setConstantAttenuation: function(value) {\r\n this._attenuation[0] = value;\r\n },\r\n\r\n getConstantAttenuation: function() {\r\n return this._attenuation[0];\r\n },\r\n\r\n setLinearAttenuation: function(value) {\r\n this._attenuation[1] = value;\r\n },\r\n\r\n getLinearAttenuation: function() {\r\n return this._attenuation[1];\r\n },\r\n\r\n setQuadraticAttenuation: function(value) {\r\n this._attenuation[2] = value;\r\n },\r\n\r\n getQuadraticAttenuation: function() {\r\n return this._attenuation[2];\r\n },\r\n\r\n setLightType: function(type) {\r\n if (type === Light.DIRECTION) return this.setLightAsDirection();\r\n else if (type === Light.SPOT) return this.setLightAsSpot();\r\n else if (type === Light.HEMI) return this.setLightAsHemi();\r\n return this.setLightAsPoint();\r\n },\r\n\r\n getLightType: function() {\r\n if (this.isDirectionLight()) return Light.DIRECTION;\r\n else if (this.isSpotLight()) return Light.SPOT;\r\n else if (this.isHemiLight()) return Light.HEMI;\r\n return Light.POINT;\r\n },\r\n\r\n setLightAsSpot: function() {\r\n vec4.set(this._position, 0.0, 0.0, 0.0, 1.0);\r\n vec3.set(this._direction, 0.0, 0.0, -1.0);\r\n this._ground[3] = -1.0;\r\n this._spotCutoff = 90;\r\n this._dirtyHash = true;\r\n },\r\n\r\n setLightAsPoint: function() {\r\n vec4.set(this._position, 0.0, 0.0, 0.0, 1.0);\r\n vec3.set(this._direction, 0.0, 0.0, -1.0);\r\n this._ground[3] = -1.0;\r\n this._dirtyHash = true;\r\n },\r\n\r\n setLightAsDirection: function() {\r\n vec4.set(this._position, 0.0, 0.0, 1.0, 0.0);\r\n this._spotCutoff = 180;\r\n this._ground[3] = -1.0;\r\n this._dirtyHash = true;\r\n },\r\n\r\n setLightAsHemi: function() {\r\n vec4.set(this._position, 0.0, 0.0, 1.0, 0.0);\r\n this._spotCutoff = 180;\r\n this._ground[3] = 1.0;\r\n this._dirtyHash = true;\r\n },\r\n\r\n setLightNumber: function(unit) {\r\n this._lightNumber = unit;\r\n this._dirtyHash = true;\r\n },\r\n\r\n getLightNumber: function() {\r\n return this._lightNumber;\r\n },\r\n\r\n // internal helper\r\n isSpotLight: function() {\r\n return this._spotCutoff < 180.0;\r\n },\r\n\r\n isDirectionLight: function() {\r\n return this._position[3] === 0.0 && this._ground[3] === -1.0;\r\n },\r\n\r\n isHemiLight: function() {\r\n return this._ground[3] === 1.0;\r\n },\r\n\r\n // matrix is current model view, which can mean:\r\n // world (node refAbsolute)\r\n // world+camera (camera is refAbsolute)\r\n // world+camera+camera+... (camera relative...)\r\n applyPositionedUniform: function(matrix) {\r\n var uniformMap = this.getOrCreateUniforms();\r\n\r\n var modelView = uniformMap.modelViewMatrix.getInternalArray();\r\n var modelViewNormal = uniformMap.modelViewNormalMatrix.getInternalArray();\r\n var viewPosition = uniformMap.viewPosition.getInternalArray();\r\n var viewDirection = uniformMap.viewDirection.getInternalArray();\r\n\r\n mat4.copy(modelView, matrix);\r\n mat3.normalFromMat4(modelViewNormal, matrix);\r\n\r\n vec4.transformMat4(viewPosition, this._position, modelView);\r\n vec3.transformMat3(viewDirection, this._direction, modelViewNormal);\r\n },\r\n\r\n apply: function() {\r\n if (!this._enable) return;\r\n\r\n var uniformMap = this.getOrCreateUniforms();\r\n\r\n if (this.isSpotLight()) {\r\n var spotsize = Math.cos(this._spotCutoff * Math.PI / 180.0);\r\n uniformMap.spotCutOff.setFloat(spotsize);\r\n uniformMap.spotBlend.setFloat((1.0 - spotsize) * this._spotBlend);\r\n }\r\n\r\n if (this.isHemiLight()) {\r\n uniformMap.ground.setFloat4(this._ground);\r\n }\r\n\r\n uniformMap.attenuation.setFloat4(this._attenuation);\r\n uniformMap.diffuse.setFloat4(this._diffuse);\r\n uniformMap.specular.setFloat4(this._specular);\r\n uniformMap.ambient.setFloat4(this._ambient);\r\n }\r\n }),\r\n 'osg',\r\n 'Light'\r\n);\r\n\r\nexport default Light;","import WebGLCaps from '../osg/WebGLCaps';\r\nimport notify from '../osg/notify';\r\n\r\nconst replaceCallback = function(e, t) {\r\n return \"core_\" + t\r\n}\r\n\r\nconst r = function(e, t) {\r\n return \"#define \" + t\r\n}\r\n\r\nconst shaderExtension = \"(GL_EXT_shader_texture_lod|GL_OES_standard_derivatives|GL_EXT_draw_buffers|GL_EXT_frag_depth;)\"\r\nconst regExt = new RegExp(\"#\\\\s*extension\\\\s+\" + shaderExtension + \".*\", \"g\")\r\nconst globalReg = new RegExp(shaderExtension, \"g\")\r\nconst decalrs = []\r\nconst fragData = function(e, t) {\r\n var datagl = \"glFragData_\" + t;\r\n decalrs[t] = \"layout(location = \" + t + \") out vec4 \" + datagl + \";\";\r\n return datagl\r\n}\r\n\r\nconst convert2WebGL2 = function(e, t) {\r\n return e = function(e) {\r\n return (e = e.replace(regExt, r)).replace(globalReg, replaceCallback)\r\n }(e = (e = (e = (e = e.replace(/attribute\\s+/g, \"in \")).replace(/varying\\s+/g, t ? \"in \" : \"out \")).replace(/(texture2D|textureCube)\\s*\\(/g, \"texture(\")).replace(/(textureCubeLodEXT)\\s*\\(/g, \"textureLod(\")),\r\n t && (decalrs.length = 0,\r\n e = e.replace(/gl_FragData\\s*\\[\\s*(\\d+)\\s*\\]/g, fragData),\r\n decalrs.length || decalrs.push(\"out vec4 glFragColor_0;\"),\r\n e = (e = e.replace(/gl_FragColor/g, \"glFragColor_0\")).replace(/void\\s+main\\s*\\(/g, decalrs.join(\"\\n\") + \"\\nvoid main(\")),\r\n e\r\n}\r\n\r\nconst NextShaderProcessor = {}\r\n\r\nconst cbFilterDuplicate = function(e, t, i) {\r\n return !t || e !== i[t - 1]\r\n};\r\n\r\nNextShaderProcessor.getSortedUnique = function(e) {\r\n return e.sort().filter(cbFilterDuplicate)\r\n}\r\n\r\nconst isStringInteger = function(e) {\r\n return /^[\\+|\\-]?\\d+$/.test(e)\r\n}\r\n\r\nconst getFinalDefinedValue = function(e, t) {\r\n for (; e[t] && t !== e[t];)\r\n t = e[t];\r\n return t\r\n}\r\n\r\nconst testIf = function(defines, line) {\r\n if (line.startsWith(\"#ifdef\"))\r\n return void 0 !== defines[line.substr(7 - line.length)];\r\n if (line.startsWith(\"#ifndef\"))\r\n return void 0 === defines[line.substr(8 - line.length)];\r\n if (line.startsWith(\"#else\"))\r\n return !0;\r\n for (var txt = line.match(/[#elif|#if]\\s+(.*)/)[1], tokens = txt.split(/\\b\\d+\\b|\\W+|defined+/g), i = 0; i < tokens.length; ++i) {\r\n var tok = tokens[i];\r\n if (tok) {\r\n var value = getFinalDefinedValue(defines, defines[tok]);\r\n void 0 === value || isStringInteger(value) || (value = !0),\r\n txt = txt.replace(tok, value)\r\n }\r\n }\r\n return eval(\"var defined = function(x) { return x !== undefined | 0; };\\n\" + txt)\r\n}\r\nconst processBranch = function(e, t, i, n) {\r\n for (var r = [1], a = t; a < e.length; ++a) {\r\n var o = e[a].trim();\r\n if (o.startsWith(\"#endif\"))\r\n r.length--;\r\n else if (o.startsWith(\"#el\")) {\r\n var s = r.length - 1;\r\n 0 === r[s] ? r[s] = testIf(i, o) ? 1 : 0 : 1 === r[s] && (r[s] = 2)\r\n } else if (o.startsWith(\"#if\"))\r\n r.push(testIf(i, o) ? 1 : 0);\r\n else {\r\n for (var u = !0, l = r.length; l--;)\r\n u = u && 1 === r[l];\r\n if (u)\r\n if (o.startsWith(\"#\"))\r\n if (o.startsWith(\"#extension\"))\r\n n.push(o);\r\n else if (o.startsWith(\"#undef\"))\r\n i[o.match(/#undef\\s+(\\w+)/)[1]] = void 0,\r\n n.push(o);\r\n else if (o.startsWith(\"#define\")) {\r\n var h = o.match(/#define\\s+(\\w+)\\s*(.*)/); -\r\n 1 !== o.indexOf(h[1] + \"(\") ? i[h[1]] = {\r\n args: o.match(/\\(.*?\\)/)[0].match(/\\w+/g),\r\n body: o.match(/\\)(.*)/)[1]\r\n } : i[h[1]] = h[2]\r\n } else\r\n console.error(\"unknown preprocessor line: \" + o);\r\n else\r\n n.push(o)\r\n }\r\n }\r\n}\r\nconst fixIndent = function(e) {\r\n for (var t = (e = e.replace(/(\\n\\s*\\n)+/g, \"\\n\\n\")).split(\"\\n\"), i = \"\", n = 0; n < t.length; ++n) {\r\n var r = t[n].trim(),\r\n a = -1 !== r.indexOf(\"{\"),\r\n o = -1 !== r.indexOf(\"}\");\r\n !a && o && (i = i.substr(4)),\r\n t[n] = i + r,\r\n a && !o && (i += \" \")\r\n }\r\n return t.join(\"\\n\")\r\n}\r\nconst cleanDeclarations = function(e, t) {\r\n for (var i = 0; i < t.length; ++i)\r\n e = e.replace(t[i], \"\"),\r\n t[i] = t[i].replace(/\\s+/g, \" \").replace(/\\s+;/, \";\");\r\n return e\r\n}\r\nconst handleVaryings = function(e) {\r\n var t = e.match(/varying\\s.*?;/g);\r\n if (!t)\r\n return e;\r\n e = cleanDeclarations(e, t),\r\n t = NextShaderProcessor.getSortedUnique(t);\r\n for (var i = 0; i < t.length; ++i)\r\n if (-1 !== t[i].indexOf(\"vViewNormal;\")) {\r\n var n = t[0];\r\n t[0] = t[i],\r\n t[i] = n;\r\n break\r\n }\r\n return \"\\n\" + t.join(\"\\n\") + \"\\n\" + e\r\n}\r\nconst handleUniforms = function(e) {\r\n var t = e.match(/uniform\\s.*?;/g);\r\n return t ? (e = cleanDeclarations(e, t),\r\n \"\\n\" + (t = NextShaderProcessor.getSortedUnique(t)).join(\"\\n\") + \"\\n\" + e) : e\r\n}\r\nconst handleAttributes = function(e) {\r\n var t = e.match(/attribute\\s.*?;/g);\r\n if (!t)\r\n return e;\r\n e = cleanDeclarations(e, t),\r\n t = NextShaderProcessor.getSortedUnique(t);\r\n for (var i = 0; i < t.length; ++i)\r\n if (-1 !== t[i].indexOf(\" Vertex;\")) {\r\n t.unshift(t[i]),\r\n t.splice(i + 1, 1);\r\n break\r\n }\r\n return \"\\n\" + t.join(\"\\n\") + \"\\n\" + e\r\n}\r\nconst handlePrecision = function(e) {\r\n var t = e.match(/precision\\s+(high|low|medium)p\\s+float\\s*;/);\r\n return t ? t[0] + \"\\n\" + e.replace(t[0], \"\") : \"precision \" + WebGLCaps.instance().getShaderMaxPrecisionFloat() + \"p float;\\n\" + e\r\n}\r\nconst addExtensions = function(e) {\r\n var t = e.match(/#extension\\s(\\w+)\\s:\\s(\\w+)/g);\r\n if (!t)\r\n return e;\r\n t = NextShaderProcessor.getSortedUnique(t);\r\n for (var i = 0; i < t.length; ++i)\r\n e = e.replace(t[i], \"\");\r\n return t.join(\"\\n\") + \"\\n\" + e\r\n}\r\nconst addVersion = function(e) {\r\n return (WebGLCaps.instance().isWebGL2() ? \"#version 300 es\\n\" : \"#version 100\\n\") + e\r\n}\r\nconst hasVersion = function(e) {\r\n return e.match(/^#\\s*version/m)\r\n}\r\nconst cbUnroll = function(e, t, i) {\r\n t = parseInt(t);\r\n for (var n = \"\", r = 0; r < t; ++r)\r\n n += i.replace(/%ID%/g, r);\r\n return n\r\n}\r\nconst unrollReplace = function(e) {\r\n return e.replace(/%UNROLL ([0-9]+)%([\\s\\S]+?)%%/g, cbUnroll)\r\n}\r\nconst glslPreprocessShader = function(e) {\r\n return window.glslesPreprocessor(e, {\r\n debugExperimental: !1,\r\n defines: [],\r\n doStats: !1,\r\n extensions: [],\r\n pruneComments: !0,\r\n logCounts: !1,\r\n minify: !1,\r\n output: 0,\r\n preprocess: !0,\r\n profileTimeEach: !1,\r\n profileTimeGlobal: !1,\r\n pruneUnused: !0,\r\n pruneDefines: !0,\r\n replaceDefine: !0,\r\n optimize: !0,\r\n tabs: 4,\r\n whitespace: !0\r\n })\r\n}\r\nconst extractArguments = function(e, t) {\r\n for (var i = [\"\"], n = 0, r = t; r < e.length; ++r) {\r\n if (\"(\" === e[r])\r\n n++;\r\n else if (\")\" === e[r]) {\r\n if (0 === n)\r\n return [i, r + 1];\r\n if (0 === --n) {\r\n i[i.length - 1] += e[r];\r\n continue\r\n }\r\n }\r\n \",\" !== e[r] || 0 !== n ? i[i.length - 1] += e[r] : i.push(\"\")\r\n }\r\n}\r\nconst replaceRange = function(e, t, i, n) {\r\n return e.substring(0, t) + n + e.substring(i)\r\n}\r\nconst resolveDefineFunction = function(e, t, i) {\r\n var n = new RegExp(\"\\\\b\" + t + \"\\\\b\\\\s*\\\\(\", \"g\"),\r\n r = e.match(n);\r\n if (!r)\r\n return e;\r\n for (var a = i.args, o = i.body, s = 0; s < r.length; ++s) {\r\n var u = r[s],\r\n l = e.indexOf(u),\r\n h = l + u.length,\r\n c = extractArguments(e, h),\r\n d = c[0],\r\n f = o.replace(/\\w+/g, (function(e) {\r\n var t = a.indexOf(e);\r\n return -1 !== t ? d[t] : e\r\n }));\r\n e = replaceRange(e, l, c[1], f)\r\n }\r\n return e\r\n}\r\nconst resolveDefines = function(e, t) {\r\n for (var i = Object.keys(t), n = 0; n < i.length; ++n) {\r\n for (var r = i[n], a = t[r], o = \"object\" == typeof a, s = !o && new RegExp(\"\\\\b\" + r + \"\\\\b\", \"g\"), u = n + 1; u < i.length; ++u) {\r\n var l = i[u],\r\n h = t[l];\r\n undefined !== h && (\"object\" == typeof h ? h.body = o ? resolveDefineFunction(h.body, r, a) : h.body.replace(s, a) : t[l] = o ? resolveDefineFunction(h, r, a) : h.replace(s, a))\r\n }\r\n e = o ? resolveDefineFunction(e, r, a) : e.replace(s, a)\r\n }\r\n return e\r\n}\r\nconst extensions = [\"EXT_shader_texture_lod\", \"EXT_draw_buffers\", \"EXT_frag_depth\", \"OES_standard_derivatives\"]\r\nconst getDefaultDefines = function() {\r\n for (var keys = {}, t = WebGLCaps.instance(), i = t.getWebGLExtensions(), n = 0; n < extensions.length; ++n) {\r\n var r = extensions[n];\r\n i[r] && (keys[\"GL_\" + r] = \"GL_\" + r)\r\n }\r\n return \"high\" === t.getShaderMaxPrecisionFloat() && (keys.GL_FRAGMENT_PRECISION_HIGH = \"GL_FRAGMENT_PRECISION_HIGH\"), keys\r\n}\r\nconst fastPreprocess = function(source) {\r\n source = source.replace(/(\\/\\*([\\s\\S]*?)\\*\\/)|(\\/\\/(.*)$)/gm, \"\");\r\n var t = getDefaultDefines(),\r\n i = [];\r\n return processBranch(source.split(\"\\n\"), 0, t, i, !0),\r\n resolveDefines(i.join(\"\\n\"), t)\r\n}\r\nconst preprocess = function(e) {\r\n var t = e.match(\"#define SHADER_NAME .*\");\r\n const cleanShader = false // (0, viewer_getOptions__WEBPACK_IMPORTED_MODULE_2__.Z)().cleanShader\r\n return e = cleanShader && window.glslesPreprocessor ? glslPreprocessShader(e) : fastPreprocess(e),\r\n t ? t[0] + \"\\n\" + e : e\r\n};\r\nNextShaderProcessor.processIncludes = function(e, t) {\r\n return e.replace(/#pragma include ([\"^+\"]?[\"\\ \"[a-zA-Z_0-9](.*)\"]*?)/g, (function(e, i) {\r\n var n = i.split(\" \")[0].replace(/\"/g, \"\");\r\n return -1 !== t.indexOf(n) ? \"\" : (t.push(n),\r\n NextShaderProcessor.processIncludes(NextShaderProcessor.getShaderTextPure(n), t))\r\n }))\r\n}\r\nNextShaderProcessor.processShader = function(unprocessedShader) {\r\n if (hasVersion(unprocessedShader))\r\n return unprocessedShader;\r\n let shader = NextShaderProcessor.processIncludes(unprocessedShader, []),\r\n i = -1 === shader.indexOf(\"gl_Position\");\r\n return shader = shader.replace(/#pragma DECLARE_FUNCTION/g, '//#pragma DECLARE_FUNCTION'),\r\n shader = shader.replace(/\\\\\\n/g, \"\"),\r\n shader = unrollReplace(shader),\r\n shader = preprocess(shader),\r\n shader = handleVaryings(shader),\r\n shader = handleUniforms(shader),\r\n shader = handleAttributes(shader),\r\n shader = fixIndent(shader),\r\n WebGLCaps.instance().isWebGL2() && convert2WebGL2(shader, i),\r\n shader = handlePrecision(shader),\r\n shader = addExtensions(shader),\r\n shader = addVersion(shader)\r\n // avoid warning on unrecognized pragma\r\n\r\n}\r\n\r\nconst shadersText = {};\r\nNextShaderProcessor.addShaders = function(shaders) { \r\n for (var key in shaders)\r\n //shadersText[key] && console.warn(\"Shader already added : \" + key),\r\n shadersText[key] = shaders[key]\r\n}\r\n\r\nNextShaderProcessor.hasShader = function(e) {\r\n return undefined !== shadersText[e]\r\n}\r\n\r\nNextShaderProcessor.getShaderTextPure = function(e) {\r\n var text = shadersText[e];\r\n text || notify.error(\"shader file/text: \" + e + \" not registered\")\r\n return text\r\n}\r\n\r\nNextShaderProcessor.getShader = function(key) {\r\n var shader = NextShaderProcessor.getShaderTextPure(key);\r\n return NextShaderProcessor.processShader(shader)\r\n}\r\n\r\n\r\nimport shaderLib from './shaderLib';\r\nimport shadowShaderLib from '../osgShadow/shaderLib';\r\nNextShaderProcessor.addShaders(shaderLib);\r\nNextShaderProcessor.addShaders(shadowShaderLib);\r\n\r\n\r\nexport default NextShaderProcessor","import utils from './utils';\r\nimport Object from './Object';\r\nimport GLObject from './GLObject';\r\nimport Timer from './Timer';\r\n\r\n/**\r\n * VertexArrayObject \"Bundles\" multipel vertex / normal / ... buffer bind\r\n * in one webgl call\r\n * @class VertexArrayObject\r\n */\r\nvar VertexArrayObject = function() {\r\n GLObject.call(this);\r\n // maybe could inherit from Object\r\n this._instanceID = Object.getInstanceID();\r\n this._vaoObject = undefined;\r\n this.dirty();\r\n};\r\n\r\n// static cache of glBuffers flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nVertexArrayObject._sDeletedGLVertexArrayObjectCache = new window.Map();\r\n\r\n// static method to delete Program\r\nVertexArrayObject.deleteGLVertexArrayObject = function(gl, buffer) {\r\n if (!VertexArrayObject._sDeletedGLVertexArrayObjectCache.has(gl))\r\n VertexArrayObject._sDeletedGLVertexArrayObjectCache.set(gl, []);\r\n VertexArrayObject._sDeletedGLVertexArrayObjectCache.get(gl).push(buffer);\r\n};\r\n\r\n// static method to flush all the cached glPrograms which need to be deleted in the GL context specified\r\nVertexArrayObject.flushDeletedGLVertexArrayObjects = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n if (!VertexArrayObject._sDeletedGLVertexArrayObjectCache.has(gl)) return availableTime;\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var deleteList = VertexArrayObject._sDeletedGLVertexArrayObjectCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteVertexArray(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nVertexArrayObject.flushAllDeletedGLVertexArrayObjects = function(gl) {\r\n if (!VertexArrayObject._sDeletedGLVertexArrayObjectCache.has(gl)) return;\r\n var deleteList = VertexArrayObject._sDeletedGLVertexArrayObjectCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0; i--) {\r\n gl.deleteVertexArray(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n};\r\n\r\nVertexArrayObject.onLostContext = function(gl) {\r\n if (!VertexArrayObject._sDeletedGLVertexArrayObjectCache.has(gl)) return;\r\n var deleteList = VertexArrayObject._sDeletedGLVertexArrayObjectCache.get(gl);\r\n deleteList.length = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n VertexArrayObject,\r\n utils.objectInherit(GLObject.prototype, {\r\n getInstanceID: function() {\r\n return this._instanceID;\r\n },\r\n\r\n invalidate: function() {\r\n this._vaoObject = undefined;\r\n this.dirty();\r\n },\r\n\r\n releaseGLObjects: function() {\r\n if (this._vaoObject !== undefined && this._gl !== undefined) {\r\n VertexArrayObject.deleteGLVertexArrayObject(this._gl, this._vaoObject);\r\n GLObject.removeObject(this._gl, this);\r\n }\r\n this.invalidate();\r\n },\r\n\r\n create: function(gl) {\r\n this._vaoObject = gl.createVertexArray();\r\n this._dirty = false;\r\n },\r\n\r\n bind: function(gl) {\r\n if (!this._gl) {\r\n this.setGraphicContext(gl);\r\n }\r\n\r\n var vao = this._vaoObject;\r\n if (!vao) return;\r\n\r\n gl.bindVertexArray(this._vaoObject);\r\n },\r\n\r\n dirty: function() {\r\n this._dirty = true;\r\n },\r\n\r\n isDirty: function() {\r\n return this._dirty;\r\n }\r\n }),\r\n 'osg',\r\n 'VertexArrayObject'\r\n);\r\n\r\nexport default VertexArrayObject;","import BufferArray from '../osg/BufferArray';\r\nimport Camera from '../osg/Camera';\r\nimport FrameStamp from '../osg/FrameStamp';\r\nimport FrameBufferObject from '../osg/FrameBufferObject';\r\nimport Light from '../osg/Light';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Texture from '../osg/Texture';\r\nimport Program from '../osg/Program';\r\nimport Shader from '../osg/Shader';\r\nimport Scissor from '../osg/Scissor';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Viewport from '../osg/Viewport';\r\nimport VertexArrayObject from '../osg/VertexArrayObject';\r\nimport WebGLCaps from '../osg/WebGLCaps';\r\nimport IntersectionVisitor from '../osgUtil/IntersectionVisitor';\r\nimport LineSegmentIntersector from '../osgUtil/LineSegmentIntersector';\r\nimport Renderer from '../osgViewer/Renderer';\r\nimport Scene from '../osgViewer/Scene';\r\nimport DisplayGraph from '../osgUtil/DisplayGraph';\r\nimport notify from '../osg/notify';\r\n\r\n// View is normally inherited from osg/View. In osgjs we dont need it yet\r\n// this split, so everything is in osgViewer/View\r\n\r\nvar View = function() {\r\n this._camera = new Camera();\r\n this._camera.setName('OSGJS camera');\r\n\r\n this._scene = new Scene();\r\n this._camera.setName('OSGJS Scene');\r\n\r\n this._frameStamp = new FrameStamp();\r\n this._lightingMode = undefined;\r\n this._manipulator = undefined;\r\n this._canvasWidth = 0;\r\n this._canvasHeight = 0;\r\n\r\n this._clientWidth;\r\n this._clientHeight;\r\n this._sizeObserver;\r\n\r\n this._requestContinousUpdate = true;\r\n this._requestRedraw = true;\r\n\r\n this.setLightingMode(View.LightingMode.HEADLIGHT);\r\n // assign a renderer to the camera\r\n var renderer = this.createRenderer(this.getCamera());\r\n renderer.setFrameStamp(this._frameStamp);\r\n this.getCamera().setRenderer(renderer);\r\n this.getCamera().setView(this);\r\n};\r\n\r\nView.LightingMode = {\r\n NO_LIGHT: 0,\r\n HEADLIGHT: 1,\r\n SKY_LIGHT: 2\r\n};\r\n\r\nView.prototype = {\r\n requestRedraw: function() {\r\n this._requestRedraw = true;\r\n },\r\n requestContinuousUpdate: function(bool) {\r\n this._requestContinousUpdate = bool;\r\n },\r\n createRenderer: function(camera) {\r\n var render = new Renderer(camera);\r\n //camera->setStats(new osg::Stats(\"Camera\"));\r\n return render;\r\n },\r\n\r\n setGraphicContext: function(gc) {\r\n this.getCamera()\r\n .getRenderer()\r\n .getState()\r\n .setGraphicContext(gc);\r\n },\r\n\r\n getGraphicContext: function() {\r\n return this.getCamera()\r\n .getRenderer()\r\n .getState()\r\n .getGraphicContext();\r\n },\r\n\r\n initWebGLCaps: function(gl, force) {\r\n WebGLCaps.instance(gl, force);\r\n },\r\n\r\n // check Each frame because HTML standard inconsistencies\r\n // - mobile full-screen, device orientation, etc\r\n // peculiarity of webgl canvas resizing here some details\r\n // http://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\r\n // screen size\r\n // http://tripleodeon.com/2011/12/first-understand-your-screen/\r\n // touchy is touchy: many things to know\r\n // http://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\r\n // ResizeObserver allows to handle that without polling\r\n // https://developers.google.com/web/updates/2016/10/resizeobserver\r\n computeCanvasSize: function(canvas) {\r\n let supportOffscreen = typeof OffscreenCanvas !== 'undefined'\r\n\r\n if (supportOffscreen && canvas instanceof OffscreenCanvas) {\r\n this._clientWidth = canvas.width;\r\n this._clientHeight = canvas.height;\r\n } else if (!this._sizeObserver) {\r\n \r\n if (window.ResizeObserver) {\r\n this._sizeObserver = new ResizeObserver(function() {\r\n this._clientWidth = canvas.clientWidth;\r\n this._clientHeight = canvas.clientHeight;\r\n }.bind(this));\r\n this._sizeObserver.observe(canvas);\r\n\r\n this._clientWidth = canvas.clientWidth;\r\n this._clientHeight = canvas.clientHeight;\r\n } else {\r\n this._clientWidth = canvas.clientWidth;\r\n this._clientHeight = canvas.clientHeight;\r\n }\r\n }\r\n\r\n if (this._clientWidth < 1) this._clientWidth = 1;\r\n if (this._clientHeight < 1) this._clientHeight = 1;\r\n\r\n var devicePixelRatio = this._devicePixelRatio;\r\n\r\n var widthPixel = Math.floor(this._clientWidth * devicePixelRatio);\r\n var heightPixel = Math.floor(this._clientHeight * devicePixelRatio);\r\n\r\n var hasChanged = false;\r\n if (this._canvasWidth !== widthPixel) {\r\n canvas.width = widthPixel;\r\n this._canvasWidth = widthPixel;\r\n hasChanged = true;\r\n }\r\n\r\n if (this._canvasHeight !== heightPixel) {\r\n canvas.height = heightPixel;\r\n this._canvasHeight = heightPixel;\r\n hasChanged = true;\r\n }\r\n return hasChanged;\r\n },\r\n\r\n getCanvasWidth: function() {\r\n return this._canvasWidth;\r\n },\r\n\r\n getCanvasHeight: function() {\r\n return this._canvasHeight;\r\n },\r\n\r\n getCanvasClientWidth: function() {\r\n return Math.ceil(this._canvasWidth / this._devicePixelRatio);\r\n },\r\n\r\n getCanvasClientHeight: function() {\r\n return Math.ceil(this._canvasHeight / this._devicePixelRatio);\r\n },\r\n\r\n getCanvasPixelRatio: function() {\r\n // in case of VR headset, it's probably not relevant anymore\r\n return this._devicePixelRatio;\r\n },\r\n\r\n setUpView: function(canvas, options) {\r\n var devicePixelRatio = window.devicePixelRatio || 1;\r\n var overrideDevicePixelRatio = options.getNumber('overrideDevicePixelRatio');\r\n var maxDevicePixelRatio = options.getNumber('maxDevicePixelRatio') || -1;\r\n\r\n // override the pixel ratio, used to save pixel on mobile\r\n if (typeof overrideDevicePixelRatio === 'number') {\r\n devicePixelRatio = overrideDevicePixelRatio;\r\n } else if (maxDevicePixelRatio !== -1) {\r\n devicePixelRatio = Math.min(devicePixelRatio, maxDevicePixelRatio);\r\n }\r\n this._devicePixelRatio = devicePixelRatio;\r\n\r\n this.computeCanvasSize(canvas);\r\n\r\n var width = canvas.width;\r\n var height = canvas.height;\r\n var ratio = width / height;\r\n\r\n this._camera.setViewport(new Viewport(0, 0, width, height));\r\n this._camera.setScissor(new Scissor());\r\n\r\n this._camera.setGraphicContext(this.getGraphicContext());\r\n mat4.lookAt(\r\n this._camera.getViewMatrix(),\r\n vec3.fromValues(0.0, 0.0, -10.0),\r\n vec3.create(),\r\n vec3.fromValues(0.0, 1.0, 0.0)\r\n );\r\n mat4.perspective(\r\n this._camera.getProjectionMatrix(),\r\n Math.PI / 180 * 27,\r\n ratio,\r\n 1.0,\r\n 1000.0\r\n );\r\n\r\n if (options && options.enableFrustumCulling)\r\n this.getCamera()\r\n .getRenderer()\r\n .getCullVisitor()\r\n .setEnableFrustumCulling(true);\r\n\r\n // add a function to refresh the graph from the console\r\n if (options && options.debugGraph) {\r\n var camera = this.getCamera();\r\n DisplayGraph.instance().refreshGraph = function() {\r\n var displayGraph = DisplayGraph.instance();\r\n displayGraph.setDisplayGraphRenderer(true);\r\n displayGraph.createGraph(camera);\r\n };\r\n\r\n notify.log(\r\n 'to refresh the graphs type in the console:\\nOSG.osgUtil.DisplayGraph.instance().refreshGraph()'\r\n );\r\n }\r\n },\r\n\r\n /**\r\n * X = 0 at the left\r\n * Y = 0 at the BOTTOM\r\n */\r\n computeIntersections: function(x, y, traversalMask) {\r\n /*jshint bitwise: false */\r\n if (traversalMask === undefined) {\r\n traversalMask = ~0;\r\n }\r\n /*jshint bitwise: true */\r\n\r\n if (!this._lsi) {\r\n this._lsi = new LineSegmentIntersector();\r\n } else {\r\n this._lsi.reset();\r\n }\r\n\r\n if (!this._origIntersect) {\r\n this._origIntersect = vec3.create();\r\n this._dstIntersect = vec3.create();\r\n }\r\n\r\n this._lsi.set(\r\n vec3.set(this._origIntersect, x, y, 0.0),\r\n vec3.set(this._dstIntersect, x, y, 1.0)\r\n );\r\n\r\n if (!this._iv) {\r\n this._iv = new IntersectionVisitor();\r\n this._iv.setIntersector(this._lsi);\r\n } else {\r\n this._iv.reset();\r\n }\r\n this._iv.setTraversalMask(traversalMask);\r\n this._camera.accept(this._iv);\r\n\r\n return this._lsi.getIntersections();\r\n },\r\n\r\n setFrameStamp: function(frameStamp) {\r\n this._frameStamp = frameStamp;\r\n },\r\n\r\n getFrameStamp: function() {\r\n return this._frameStamp;\r\n },\r\n\r\n setCamera: function(camera) {\r\n this._camera = camera;\r\n },\r\n\r\n getCamera: function() {\r\n return this._camera;\r\n },\r\n\r\n setSceneData: function(node) {\r\n var previousNode = this._scene.getSceneData();\r\n if (node === previousNode) return;\r\n\r\n this._scene.setSceneData(node);\r\n\r\n var children = this._camera.getChildren();\r\n var statsNode = undefined;\r\n for (var i = 0, l = children.length; i < l; i++) {\r\n if (children[i].getName() === 'osgStats') {\r\n statsNode = children[i];\r\n break;\r\n }\r\n }\r\n this._camera.removeChildren();\r\n this._camera.addChild(node);\r\n if (statsNode) this._camera.addChild(statsNode);\r\n },\r\n\r\n getSceneData: function() {\r\n return this._scene.getSceneData();\r\n },\r\n\r\n setDatabasePager: function(dbpager) {\r\n this._scene.setDatabasePager(dbpager);\r\n },\r\n\r\n getDatabasePager: function() {\r\n return this._scene.getDatabasePager();\r\n },\r\n\r\n getScene: function() {\r\n return this._scene;\r\n },\r\n\r\n getManipulator: function() {\r\n return this._manipulator;\r\n },\r\n\r\n setManipulator: function(manipulator) {\r\n this._manipulator = manipulator;\r\n },\r\n\r\n getLight: function() {\r\n return this._light;\r\n },\r\n\r\n setLight: function(light) {\r\n this._light = light;\r\n if (this._lightingMode !== View.LightingMode.NO_LIGHT) {\r\n this._scene.getOrCreateStateSet().setAttributeAndModes(this._light);\r\n }\r\n },\r\n\r\n getLightingMode: function() {\r\n return this._lightingMode;\r\n },\r\n\r\n setLightingMode: function(lightingMode) {\r\n if (this._lightingMode !== lightingMode) {\r\n this._lightingMode = lightingMode;\r\n\r\n if (this._lightingMode !== View.LightingMode.NO_LIGHT) {\r\n if (!this._light) this._light = new Light();\r\n } else {\r\n this._light = undefined;\r\n }\r\n }\r\n },\r\n\r\n // In OSG this call is done in SceneView\r\n flushDeletedGLObjects: function(availableTimeBudget) {\r\n // Flush all deleted OpenGL objects within the specified availableTime\r\n var gl = this.getGraphicContext();\r\n var availableTime = availableTimeBudget;\r\n availableTime = BufferArray.flushDeletedGLBufferArrays(gl, availableTime);\r\n availableTime = VertexArrayObject.flushDeletedGLVertexArrayObjects(gl, availableTime);\r\n availableTime = Texture.getTextureManager(gl).flushDeletedTextureObjects(gl, availableTime);\r\n availableTime = Program.flushDeletedGLPrograms(gl, availableTime);\r\n availableTime = Shader.flushDeletedGLShaders(gl, availableTime);\r\n availableTime = FrameBufferObject.flushDeletedGLFrameBuffers(gl, availableTime);\r\n FrameBufferObject.flushDeletedGLRenderBuffers(gl, availableTime);\r\n },\r\n\r\n flushAllDeletedGLObjects: function() {\r\n // Flush all deleted OpenGL objects\r\n var gl = this.getGraphicContext();\r\n VertexArrayObject.flushAllDeletedGLVertexArrayObjects(gl);\r\n BufferArray.flushAllDeletedGLBufferArrays(gl);\r\n Texture.getTextureManager(gl).flushAllDeletedTextureObjects(gl);\r\n Program.flushAllDeletedGLPrograms(gl);\r\n Shader.flushAllDeletedGLShaders(gl);\r\n FrameBufferObject.flushAllDeletedGLFrameBuffers(gl);\r\n FrameBufferObject.flushAllDeletedGLRenderBuffers(gl);\r\n }\r\n};\r\n\r\nexport default View;\r\n","import primitiveSet from './primitiveSet';\r\n\r\n/**\r\n * DrawElements manage rendering of indexed primitives\r\n * @class DrawElements\r\n */\r\nvar DrawElements = function(mode, indices) {\r\n this.mode = primitiveSet.POINTS;\r\n if (mode !== undefined) {\r\n if (typeof mode === 'string') {\r\n mode = primitiveSet[mode];\r\n }\r\n this.mode = mode;\r\n }\r\n this.count = 0;\r\n this.offset = 0;\r\n this.indices = indices;\r\n this.uType = DrawElements.UNSIGNED_SHORT;\r\n if (indices !== undefined) {\r\n this.setIndices(indices);\r\n }\r\n};\r\n\r\nDrawElements.UNSIGNED_BYTE = 0x1401;\r\nDrawElements.UNSIGNED_SHORT = 0x1403;\r\nDrawElements.UNSIGNED_INT = 0x1405;\r\n\r\n/** @lends DrawElements.prototype */\r\nDrawElements.prototype = {\r\n getMode: function() {\r\n return this.mode;\r\n },\r\n draw: function(state) {\r\n if (this.count === 0) return;\r\n state.setIndexArray(this.indices);\r\n this.drawElements(state);\r\n },\r\n drawElements: function(state) {\r\n var gl = state.getGraphicContext();\r\n gl.drawElements(this.mode, this.count, this.uType, this.offset);\r\n },\r\n setIndices: function(indices) {\r\n this.indices = indices;\r\n var elts = indices.getElements();\r\n this.count = elts.length;\r\n\r\n var nbBytes = elts.BYTES_PER_ELEMENT;\r\n if (nbBytes === 1) this.uType = DrawElements.UNSIGNED_BYTE;\r\n else if (nbBytes === 2) this.uType = DrawElements.UNSIGNED_SHORT;\r\n else if (nbBytes === 4) this.uType = DrawElements.UNSIGNED_INT;\r\n },\r\n getIndices: function() {\r\n return this.indices;\r\n },\r\n setFirst: function(val) {\r\n this.offset = val;\r\n },\r\n getFirst: function() {\r\n return this.offset;\r\n },\r\n setCount: function(val) {\r\n this.count = val;\r\n },\r\n getCount: function() {\r\n return this.count;\r\n },\r\n getNumIndices: function() {\r\n return this.indices.getElements().length;\r\n },\r\n index: function(i) {\r\n return this.indices.getElements()[i];\r\n }\r\n};\r\n\r\nexport default DrawElements;\r\n","import utils from './utils';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport KdTree from './KdTree';\r\n\r\nvar KdTreeBuilder = function(options) {\r\n NodeVisitor.call(this);\r\n this._buildOptions = {\r\n _numVerticesProcessed: 0,\r\n _targetNumTrianglesPerLeaf: 50,\r\n _maxNumLevels: 20\r\n };\r\n\r\n if (!options) return;\r\n\r\n // merge options\r\n var perLeaf = options._targetNumTrianglesPerLeaf;\r\n var maxLevel = options._maxNumLevels;\r\n\r\n if (perLeaf !== undefined) this._buildOptions._targetNumTrianglesPerLeaf = perLeaf;\r\n if (maxLevel !== undefined) this._buildOptions._maxNumLevels = maxLevel;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n KdTreeBuilder,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getShape) {\r\n var shape = node.getShape();\r\n // we test if the kdTree is already built and if we can build it (null means we skip it)\r\n if (shape === undefined) {\r\n var kdTree = new KdTree();\r\n if (kdTree.build(this._buildOptions, node)) {\r\n node.setShape(kdTree);\r\n }\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osg',\r\n 'KdTreeBuilder'\r\n);\r\n\r\nexport default KdTreeBuilder;\r\n","import utils from '../osg/utils';\r\nimport BufferArrayProxy from '../osg/BufferArrayProxy';\r\nimport notify from '../osg/notify';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Geometry from '../osg/Geometry';\r\nimport StateSet from '../osg/StateSet';\r\nimport MorphAttribute from './MorphAttribute';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport BoundingBox from '../osg/BoundingBox';\r\n\r\n/**\r\n * MorphGeometry manage up to MorphGeometry.MAX_MORPH_GPU morphTargets\r\n * @class MorphGeometry\r\n * @inherits Geometry\r\n */\r\n\r\nvar MorphGeometry = function() {\r\n Geometry.call(this);\r\n\r\n this._shape = null; // by default no kdtree/shape for morph\r\n\r\n this._targets = []; // Target list (Geometry)\r\n this._stateSetAnimation = new StateSet(); // StateSet to handle morphAttribute\r\n this._targetWeights = new Float32Array(MorphGeometry.MAX_MORPH_GPU); // Fixed length array feed by UpdateMorph\r\n\r\n this._morphAttribute = undefined;\r\n this._morphTargetNames = undefined;\r\n\r\n this._maxMorphGPU = MorphGeometry.MAX_MORPH_GPU; // used by updateMorph to limit the number of morphed attributes done by the gpu\r\n\r\n this._isInitialized = false;\r\n};\r\n\r\n// sync with UpdateMorph\r\nMorphGeometry.EFFECTIVE_EPS = 0.05;\r\n\r\n// this should be constant, if you change it only do it at parse time, otherwise it's better to call setMaximumPossibleMorphGPU\r\nMorphGeometry.MAX_MORPH_GPU = 4;\r\n\r\nutils.createPrototypeNode(\r\n MorphGeometry,\r\n utils.objectInherit(Geometry.prototype, {\r\n init: function() {\r\n if (this._morphAttribute) {\r\n this._isInitialized = true;\r\n return false;\r\n }\r\n\r\n this._morphAttribute = new MorphAttribute(\r\n Math.min(this._maxMorphGPU, this.getMorphTargets().length)\r\n );\r\n this.getStateSetAnimation().setAttributeAndModes(\r\n this._morphAttribute,\r\n StateAttribute.ON\r\n );\r\n this._morphAttribute.setTargetWeights(this.getTargetsWeight());\r\n\r\n if (this._targets[0]) {\r\n this._morphTargetNames = window.Object.keys(\r\n this._targets[0].getVertexAttributeList()\r\n );\r\n this._morphAttribute.copyTargetNames(this._morphTargetNames);\r\n } else {\r\n this._morphTargetNames = [];\r\n notify.error('No Targets in the MorphGeometry !');\r\n }\r\n\r\n this._isInitialized = true;\r\n return true;\r\n },\r\n\r\n getMaximumPossibleMorphGPU: function() {\r\n return this._maxMorphGPU;\r\n },\r\n\r\n setMaximumPossibleMorphGPU: function(nb) {\r\n this._maxMorphGPU = nb;\r\n this._isInitialized = false; // it's mostly UpdateMorph that we want to dirty\r\n if (this._morphAttribute) this._morphAttribute.setNumTargets(nb);\r\n },\r\n\r\n getMorphTargetNames: function() {\r\n return this._morphTargetNames;\r\n },\r\n\r\n getStateSetAnimation: function() {\r\n return this._stateSetAnimation;\r\n },\r\n\r\n getMorphTargets: function() {\r\n return this._targets;\r\n },\r\n\r\n isInitialized: function() {\r\n return this._isInitialized;\r\n },\r\n\r\n getTargetsWeight: function() {\r\n return this._targetWeights;\r\n },\r\n\r\n computeBoundingBox: (function() {\r\n var tmpBox = new BoundingBox();\r\n\r\n return function(boundingBox) {\r\n Geometry.prototype.computeBoundingBox.call(this, boundingBox);\r\n\r\n // expand bb with targets\r\n // Note : if the morphs have many many targets it can be done more smartly in\r\n // the UpdateMorph on each frame by just taking into account the \"active morphs\"\r\n for (var i = 0, l = this._targets.length; i < l; i++) {\r\n boundingBox.expandByBoundingBox(this._targets[i].computeBoundingBox(tmpBox));\r\n }\r\n\r\n return boundingBox;\r\n };\r\n })(),\r\n\r\n mergeChildrenVertexAttributeList: function() {\r\n for (var i = 0, l = this._targets.length; i < l; i++) {\r\n var target = this._targets[i];\r\n\r\n // change BufferArray to BufferArrayProxy\r\n var attributeList = target.getVertexAttributeList();\r\n for (var keyAttribute in attributeList) {\r\n var att = attributeList[keyAttribute];\r\n // check it's a buffer array before swtiching to proxy\r\n if (att && !att.getBufferArray) {\r\n attributeList[keyAttribute] = new BufferArrayProxy(att);\r\n }\r\n }\r\n\r\n Geometry.appendVertexAttributeToList(\r\n target.getVertexAttributeList(),\r\n this.getVertexAttributeList(),\r\n i\r\n );\r\n }\r\n },\r\n\r\n _computeEffectiveSumWeights: function() {\r\n var sum = 0.0;\r\n var weights = this._targetWeights;\r\n for (var i = 0, nb = weights.length; i < nb; ++i) {\r\n var weight = weights[i];\r\n if (Math.abs(weight) <= MorphGeometry.EFFECTIVE_EPS) continue;\r\n\r\n sum += weight;\r\n }\r\n var eps = 1e-5;\r\n if (Math.abs(sum) > eps) return sum;\r\n return sum < 0.0 ? -eps : eps;\r\n },\r\n\r\n computeTransformedVertex: function(id, out) {\r\n out = out || vec3.create();\r\n\r\n var id3 = id * 3;\r\n\r\n var weights = this._targetWeights;\r\n var vList = this.getVertexAttributeList();\r\n\r\n var baseVerts = vList.Vertex.getElements();\r\n\r\n var sumWeights = 1.0 - this._computeEffectiveSumWeights();\r\n out[0] = sumWeights * baseVerts[id3];\r\n out[1] = sumWeights * baseVerts[id3 + 1];\r\n out[2] = sumWeights * baseVerts[id3 + 2];\r\n\r\n for (var j = 0, nb = weights.length; j < nb; ++j) {\r\n var weight = weights[j];\r\n if (Math.abs(weight) <= MorphGeometry.EFFECTIVE_EPS) continue;\r\n\r\n var morphElts = vList['Vertex_' + j].getElements();\r\n out[0] += weight * morphElts[id3];\r\n out[1] += weight * morphElts[id3 + 1];\r\n out[2] += weight * morphElts[id3 + 2];\r\n }\r\n\r\n return out;\r\n },\r\n\r\n computeTransformedVertices: function() {\r\n var weights = this._targetWeights;\r\n var vList = this.getVertexAttributeList();\r\n\r\n var baseVerts = vList.Vertex.getElements();\r\n var vertexLen = baseVerts.length;\r\n\r\n var morphedVerts = (this._morphedVerts =\r\n this._morphedVerts || new Float32Array(vertexLen));\r\n\r\n // base vertex influence\r\n var baseWeight = 1.0 - this._computeEffectiveSumWeights();\r\n for (var i = 0; i < vertexLen; ++i) {\r\n morphedVerts[i] = baseWeight * baseVerts[i];\r\n }\r\n\r\n for (var j = 0, nb = weights.length; j < nb; ++j) {\r\n var weight = weights[j];\r\n if (Math.abs(weight) <= MorphGeometry.EFFECTIVE_EPS) continue;\r\n\r\n // important : we should not take getInitialBufferArray as we should take the partially computed cpu morph from UpdateMorph\r\n var morphElts = vList['Vertex_' + j].getElements();\r\n for (var k = 0; k < vertexLen; ++k) {\r\n morphedVerts[k] += weight * morphElts[k];\r\n }\r\n }\r\n\r\n return morphedVerts;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'MorphGeometry'\r\n);\r\n\r\nexport default MorphGeometry;\r\n","import utils from './utils';\r\nimport notify from './notify';\r\nimport Node from './Node';\r\nimport WebGLCaps from './WebGLCaps';\r\nimport DrawElements from './DrawElements';\r\nimport BufferArrayProxy from './BufferArrayProxy';\r\nimport VertexArrayObject from './VertexArrayObject';\r\nimport primitiveFunctor from './primitiveFunctor'\r\nimport { vec3 } from './glMatrix';\r\n/**\r\n * Geometry manage array and primitives to draw a geometry.\r\n * @class Geometry\r\n */\r\n\r\nvar Geometry = function() {\r\n Node.call(this);\r\n\r\n this._attributes = {};\r\n this._primitives = [];\r\n\r\n // function is generated for each Shader Program ID\r\n // which generates a a special \"draw\"\r\n // TODO: could be upon hash of combination of attributes\r\n // (as multiple shader Programs can use same combination of attributes)\r\n this._cacheDrawCall = {};\r\n\r\n // VAO cached data, per combination of vertex buffer\r\n // program id also the cache key\r\n this._useVAO = undefined;\r\n this._vao = {};\r\n this._cacheVertexAttributeBufferList = {};\r\n\r\n // null means the kdTree builder will skip the kdTree creation\r\n this._shape = undefined;\r\n};\r\n\r\nGeometry.enableVAO = true;\r\n\r\n/** @lends Geometry.prototype */\r\nutils.createPrototypeNode(\r\n Geometry,\r\n utils.objectInherit(Node.prototype, {\r\n releaseGLObjects: function() {\r\n if (this.stateset !== undefined) this.stateset.releaseGLObjects();\r\n\r\n for (var keyAttribute in this._attributes) {\r\n var value = this._attributes[keyAttribute];\r\n value.releaseGLObjects();\r\n }\r\n\r\n for (var i = 0, h = this._primitives.length; i < h; i++) {\r\n var prim = this._primitives[i];\r\n if (prim.getIndices !== undefined) {\r\n if (prim.getIndices() !== undefined && prim.getIndices() !== null) {\r\n prim.indices.releaseGLObjects();\r\n }\r\n }\r\n }\r\n\r\n this.releaseVAO();\r\n },\r\n\r\n releaseVAO: function() {\r\n if (!this._useVAO || !this._glContext) return;\r\n\r\n for (var prgID in this._vao) {\r\n if (this._vao[prgID]) {\r\n this._vao[prgID].releaseGLObjects();\r\n this._vao[prgID] = undefined;\r\n }\r\n }\r\n },\r\n\r\n dirty: function() {\r\n this._cacheDrawCall = {};\r\n this.releaseVAO();\r\n },\r\n\r\n getPrimitives: function() {\r\n // Notify.warn( 'deprecated use instead getPrimitiveSetList' );\r\n return this.getPrimitiveSetList();\r\n },\r\n\r\n getAttributes: function() {\r\n // Notify.warn( 'deprecated use instead getVertexAttributeList' );\r\n return this.getVertexAttributeList();\r\n },\r\n\r\n getShape: function() {\r\n return this._shape;\r\n },\r\n\r\n setShape: function(shape) {\r\n this._shape = shape;\r\n },\r\n\r\n getVertexAttributeList: function() {\r\n return this._attributes;\r\n },\r\n\r\n /**\r\n * Return the primitiveset list\r\n * If you modify something inside this array\r\n * you must call dirty() on the Geometry\r\n */\r\n getPrimitiveSetList: function() {\r\n return this._primitives;\r\n },\r\n\r\n /**\r\n * Set the buffer array on the attribute name key\r\n * key is often something like Vertex, Normal, Color, ...\r\n * for classic geometry\r\n *\r\n * if you change a buffer a dirty will be automatically\r\n * called to rebuild the VAO if needed.\r\n */\r\n setVertexAttribArray: function(key, array) {\r\n if (this._attributes[key] !== array) {\r\n this._attributes[key] = array;\r\n this.dirty();\r\n }\r\n },\r\n\r\n _generateVertexSetup: function(\r\n validAttributeKeyList,\r\n validAttributeIndexList,\r\n includeFirstIndexBuffer\r\n ) {\r\n // generate setup for vertex attribute\r\n // will be used as setup for vao or as is without vao\r\n var vertexAttributeSetup = [\r\n '//generated by Geometry::implementation',\r\n 'state.lazyDisablingOfVertexAttributes();',\r\n 'var attr;'\r\n ];\r\n\r\n for (var i = 0, l = validAttributeKeyList.length; i < l; i++) {\r\n vertexAttributeSetup.push(\r\n \"attr = this._attributes['\" + validAttributeKeyList[i] + \"'];\"\r\n );\r\n vertexAttributeSetup.push(\r\n 'if ( attr.BufferArrayProxy ) attr = attr.getBufferArray();'\r\n );\r\n vertexAttributeSetup.push('if ( !attr.isValid() ) return;');\r\n vertexAttributeSetup.push(\r\n 'state.setVertexAttribArray(' +\r\n validAttributeIndexList[i] +\r\n ', attr, attr.getNormalize() );'\r\n );\r\n }\r\n\r\n vertexAttributeSetup.push('state.applyDisablingOfVertexAttributes();');\r\n\r\n if (includeFirstIndexBuffer)\r\n vertexAttributeSetup.push(\r\n 'state.setIndexArray( this._primitives[ 0 ].getIndices() );'\r\n );\r\n\r\n return vertexAttributeSetup;\r\n },\r\n\r\n _generatePrimitives: function(validPrimitives, hasVertexColor, optimizeVAO) {\r\n var primitiveSetup = [\r\n hasVertexColor ? 'state.enableVertexColor();' : 'state.disableVertexColor();'\r\n ];\r\n if (optimizeVAO) {\r\n return primitiveSetup.concat([\r\n 'var primitive = this._primitives[ ' + validPrimitives[0] + ' ];',\r\n 'var indexes = primitive.getIndices();',\r\n 'if ( indexes.isDirty() ) {;',\r\n ' indexes.bind( gl );',\r\n ' indexes.compile( gl );',\r\n '};',\r\n 'primitive.drawElements( state );'\r\n ]);\r\n }\r\n\r\n primitiveSetup.push('var primitives = this._primitives;');\r\n for (var j = 0, m = validPrimitives.length; j < m; j++) {\r\n primitiveSetup.push('primitives[' + validPrimitives[j] + '].draw(state);');\r\n }\r\n\r\n return primitiveSetup;\r\n },\r\n\r\n /**\r\n * Generate a function specific to the Geometry/Program\r\n * two version one using VAO and a regular one\r\n */\r\n generateDrawCommand: (function() {\r\n var validAttributeList = [];\r\n var validAttributeKeyList = [];\r\n\r\n return function(state, program, prgID, validPrimitives) {\r\n var attributesCacheMap = program._attributesCache;\r\n var geometryVertexAttributes = this.getVertexAttributeList();\r\n\r\n validAttributeKeyList.length = 0;\r\n validAttributeList.length = 0;\r\n\r\n // 1 - register valid vertex attributes and color flag\r\n\r\n var attribute, j, m, attr;\r\n\r\n var useVAO = this._useVAO;\r\n var listVABuff = useVAO ? [] : undefined;\r\n\r\n var hasVertexColor = false;\r\n\r\n for (var key in attributesCacheMap) {\r\n attribute = attributesCacheMap[key];\r\n attr = geometryVertexAttributes[key];\r\n\r\n if (attr === undefined) continue;\r\n\r\n var attributeBuffer = this._attributes[key];\r\n\r\n // dont use VAO if we have BufferArrayProxy\r\n // typically used for morphing\r\n if (attributeBuffer instanceof BufferArrayProxy) {\r\n attributeBuffer = attributeBuffer.getBufferArray();\r\n useVAO = false;\r\n }\r\n\r\n if (!attributeBuffer.isValid()) return undefined;\r\n\r\n // store for later usage at draw time/update\r\n if (useVAO) listVABuff.push(attributeBuffer);\r\n\r\n if (!hasVertexColor && key === 'Color') hasVertexColor = true;\r\n\r\n validAttributeKeyList.push(key);\r\n validAttributeList.push(attribute);\r\n }\r\n\r\n var autogeneratedFunction;\r\n var functionName;\r\n\r\n // generate specific function using VAO or standard\r\n if (useVAO) {\r\n this._cacheVertexAttributeBufferList[prgID] = listVABuff;\r\n\r\n // if there is only one drawElement we can put the index buffer\r\n // in the vao\r\n var optimizeIndexBufferVAO =\r\n validPrimitives.length === 1 &&\r\n this._primitives[validPrimitives[0]] instanceof DrawElements;\r\n\r\n var vertexAttributeSetup = this._generateVertexSetup(\r\n validAttributeKeyList,\r\n validAttributeList,\r\n optimizeIndexBufferVAO\r\n );\r\n\r\n state.clearVertexAttribCache();\r\n\r\n var gl = state.getGraphicContext();\r\n var vao = new VertexArrayObject(gl);\r\n vao.create(gl);\r\n state.setVertexArrayObject(vao);\r\n this._vao[prgID] = vao;\r\n\r\n // evaluate the vertexAttribute setup to register into the vao\r\n /*jshint evil: true */\r\n var vertexSetupCommand = new Function('state', vertexAttributeSetup.join('\\n'));\r\n /*jshint evil: false */\r\n vertexSetupCommand.call(this, state);\r\n\r\n // setup the program\r\n var vaoSetup = [\r\n 'var gl = state.getGraphicContext();',\r\n 'var vao = this._vao[ ' + prgID + ' ] ',\r\n 'var hasChanged = state.setVertexArrayObject( vao );',\r\n 'if ( hasChanged ) {',\r\n ' var vaList = this._cacheVertexAttributeBufferList[ ' + prgID + ' ];',\r\n ' var va;'\r\n ];\r\n for (j = 0, m = listVABuff.length; j < m; j++) {\r\n vaoSetup.push(' va = vaList[ ' + j + '];');\r\n vaoSetup.push(' if ( va.isDirty() ) {;');\r\n vaoSetup.push(' va.bind( gl );');\r\n vaoSetup.push(' va.compile( gl );');\r\n vaoSetup.push(' };');\r\n }\r\n vaoSetup.push('}');\r\n\r\n autogeneratedFunction = vaoSetup\r\n .concat(\r\n this._generatePrimitives(\r\n validPrimitives,\r\n hasVertexColor,\r\n optimizeIndexBufferVAO\r\n )\r\n )\r\n .join('\\n');\r\n functionName = 'GeometryDrawImplementationCacheVAO';\r\n } else {\r\n autogeneratedFunction = this._generateVertexSetup(\r\n validAttributeKeyList,\r\n validAttributeList,\r\n false\r\n )\r\n .concat(this._generatePrimitives(validPrimitives, hasVertexColor, false))\r\n .join('\\n');\r\n functionName = 'GeometryDrawImplementationCache';\r\n }\r\n\r\n /*jshint evil: true */\r\n // name the function\r\n // http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript\r\n var drawCommand = new Function(\r\n 'state',\r\n 'return function ' + functionName + '( state ) { ' + autogeneratedFunction + '}'\r\n )();\r\n /*jshint evil: false */\r\n\r\n this._cacheDrawCall[prgID] = drawCommand;\r\n return drawCommand;\r\n };\r\n })(),\r\n\r\n _getValidPrimitives: function() {\r\n var validPrimitives = [];\r\n\r\n for (var i = 0; i < this._primitives.length; i++) {\r\n var primitive = this._primitives[i];\r\n if (!primitive.getCount()) {\r\n if (!this._warnInvalidPrimitives) {\r\n notify.warn(\r\n 'geometry with instanceID ' +\r\n this._instanceID +\r\n ' has invalid primitives'\r\n );\r\n this._warnInvalidPrimitives = true;\r\n }\r\n continue;\r\n }\r\n validPrimitives.push(i);\r\n }\r\n\r\n return validPrimitives;\r\n },\r\n\r\n drawImplementation: function(state) {\r\n var program = state.getLastProgramApplied();\r\n var prgID = program.getInstanceID();\r\n\r\n state.drawGeometry(this);\r\n var cachedDraw = this._cacheDrawCall[prgID];\r\n\r\n if (!this._vao[prgID]) {\r\n state.setVertexArrayObject(null);\r\n } else {\r\n if (this._vao[prgID].isDirty()) {\r\n // need vertex array recreation\r\n // ie: lost context\r\n cachedDraw = undefined;\r\n }\r\n }\r\n\r\n if (cachedDraw) {\r\n cachedDraw.call(this, state);\r\n return;\r\n }\r\n\r\n if (!this._primitives.length) {\r\n if (!this._warnNoPrimitives) {\r\n notify.warn(\r\n 'geometry with instanceID ' + this._instanceID + ' has no primitives'\r\n );\r\n this._warnNoPrimitives = true;\r\n }\r\n return;\r\n }\r\n\r\n var validPrimitives = this._getValidPrimitives();\r\n if (!validPrimitives.length) return;\r\n\r\n // generate cachedDraw\r\n if (this._useVAO === undefined && Geometry.enableVAO) {\r\n // will be null if not supported\r\n this._useVAO = WebGLCaps.instance().hasVAO();\r\n this._glContext = state.getGraphicContext();\r\n }\r\n\r\n cachedDraw = this.generateDrawCommand(state, program, prgID, validPrimitives);\r\n cachedDraw.call(this, state);\r\n state.setVertexArrayObject(null);\r\n },\r\n\r\n setBound: function(bb) {\r\n this._boundingBox = bb;\r\n this._boundingBoxComputed = true;\r\n },\r\n\r\n computeCentroid: function() {\r\n if(this._centroidComputed === true)\r\n {\r\n return vec3.clone(this._centroid)\r\n }\r\n this._centroid = vec3.create()\r\n let scale = 1 / 3\r\n let sumArea = 0\r\n let tmp1Vec3 = vec3.create()\r\n let tmp2Vec3 = vec3.create()\r\n let vertices = this.getVertexAttributeList().Vertex.getElements();\r\n let operator = {\r\n operatorTriangle : function ( v1, v2, v3 ) {\r\n vec3.sub(tmp1Vec3, v2, v1)\r\n vec3.sub(tmp2Vec3, v3, v1)\r\n let area = vec3.dot(tmp1Vec3, tmp2Vec3) / 2\r\n vec3.add(tmp1Vec3, v1, v2)\r\n vec3.add(tmp2Vec3, v3, tmp1Vec3)\r\n vec3.scale(tmp1Vec3, tmp2Vec3, scale * area)\r\n sumArea += area\r\n vec3.add(this._centroid, this._centroid, tmp1Vec3)\r\n }.bind(this)\r\n };\r\n primitiveFunctor(this, operator, vertices)\r\n vec3.scale(this._centroid, this._centroid, 1 / sumArea)\r\n this._centroidComputed = true\r\n return vec3.clone(this._centroid)\r\n },\r\n\r\n computeBoundingBox: function(boundingBox) {\r\n boundingBox.init();\r\n\r\n var vertexArray = this.getVertexAttributeList().Vertex;\r\n if (vertexArray && vertexArray.getElements() && vertexArray.getItemSize() > 2) {\r\n var vertexes = vertexArray.getElements();\r\n var itemSize = vertexArray.getItemSize();\r\n\r\n var min = boundingBox.getMin();\r\n var max = boundingBox.getMax();\r\n\r\n var minx = min[0];\r\n var miny = min[1];\r\n var minz = min[2];\r\n var maxx = max[0];\r\n var maxy = max[1];\r\n var maxz = max[2];\r\n\r\n // if the box is un-initialized min=Inf and max=-Inf\r\n // we can't simply write if(x > min) [...] else (x < max) [...]\r\n // most of the time the else condition is run so it's a kinda useless\r\n // optimization anyway\r\n for (var idx = 0, l = vertexes.length; idx < l; idx += itemSize) {\r\n var v1 = vertexes[idx];\r\n var v2 = vertexes[idx + 1];\r\n var v3 = vertexes[idx + 2];\r\n if (v1 < minx) minx = v1;\r\n if (v1 > maxx) maxx = v1;\r\n if (v2 < miny) miny = v2;\r\n if (v2 > maxy) maxy = v2;\r\n if (v3 < minz) minz = v3;\r\n if (v3 > maxz) maxz = v3;\r\n }\r\n\r\n min[0] = minx;\r\n min[1] = miny;\r\n min[2] = minz;\r\n max[0] = maxx;\r\n max[1] = maxy;\r\n max[2] = maxz;\r\n }\r\n\r\n return boundingBox;\r\n },\r\n\r\n computeBoundingSphere: function(boundingSphere) {\r\n boundingSphere.init();\r\n var bb = this.getBoundingBox();\r\n boundingSphere.expandByBoundingBox(bb);\r\n return boundingSphere;\r\n }\r\n }),\r\n 'osg',\r\n 'Geometry'\r\n);\r\n\r\nGeometry.appendVertexAttributeToList = function(from, to, postfix) {\r\n for (var key in from) {\r\n var keyPostFix = key;\r\n if (postfix !== undefined) keyPostFix += '_' + postfix;\r\n\r\n to[keyPostFix] = from[key];\r\n }\r\n};\r\n\r\nexport default Geometry;","import notify from './notify';\r\nimport utils from './utils';\r\n\r\nvar OptionsDefault = {\r\n antialias: true, // activate MSAA\r\n //'overrideDevicePixelRatio': 1, // if specified override the device pixel ratio\r\n fullscreen: true,\r\n enableFrustumCulling: false,\r\n scrollwheel: true,\r\n webgl2: false,\r\n powerPreference: 'high-performance',\r\n shaderStats: false, // display compilation timing in the console\r\n stats: false // display stats, check in osgStats/Stats for all url options\r\n // statsFilter=cull;myGroup;webgl filters groups to display\r\n // statsFontSize=12 change the size of the fonts default 12\r\n // statsShowGraph=1 display graph\r\n};\r\n\r\nvar Options = function() {\r\n for (var keyOption in OptionsDefault) {\r\n this[keyOption] = OptionsDefault[keyOption];\r\n }\r\n};\r\n\r\nvar urlOptions;\r\nOptions.getOptionsURL = function() {\r\n if (urlOptions) return urlOptions;\r\n\r\n urlOptions = {};\r\n\r\n if (!window.location.search) return urlOptions;\r\n\r\n var vars = [];\r\n var hash;\r\n // slice(1) to remove leading '?'\r\n var hashes = window.location.search.slice(1).split('&');\r\n for (var i = 0; i < hashes.length; i++) {\r\n hash = hashes[i].split('=');\r\n var element = hash[0];\r\n vars.push(element);\r\n var result = hash[1];\r\n\r\n // ideally we should have typed option\r\n if (result === '0' || result === 'false') continue;\r\n if (result === undefined) result = '1';\r\n\r\n urlOptions[element] = result;\r\n }\r\n\r\n if (urlOptions.log !== undefined) {\r\n var level = urlOptions.log.toLowerCase();\r\n\r\n switch (level) {\r\n case 'debug':\r\n notify.setNotifyLevel(notify.DEBUG);\r\n break;\r\n case 'info':\r\n notify.setNotifyLevel(notify.INFO);\r\n break;\r\n case 'notice':\r\n notify.setNotifyLevel(notify.NOTICE);\r\n break;\r\n case 'warn':\r\n notify.setNotifyLevel(notify.WARN);\r\n break;\r\n case 'error':\r\n notify.setNotifyLevel(notify.ERROR);\r\n break;\r\n case 'html':\r\n var logContent = [];\r\n var divLogger = document.createElement('div');\r\n var codeElement = document.createElement('pre');\r\n document.addEventListener('DOMContentLoaded', function() {\r\n document.body.insertBefore(divLogger, document.body.firstChild);\r\n divLogger.appendChild(codeElement);\r\n });\r\n var logFunc = function(str) {\r\n logContent.unshift(str);\r\n codeElement.innerHTML = logContent.join('\\n');\r\n };\r\n divLogger.style.overflow = 'hidden';\r\n divLogger.style.position = 'absolute';\r\n divLogger.style.zIndex = '10000';\r\n divLogger.style.height = '100%';\r\n divLogger.style.maxWidth = '600px';\r\n divLogger.style.pointerEvents = 'none';\r\n codeElement.style.overflow = 'scroll';\r\n codeElement.style.width = '105%';\r\n codeElement.style.height = '100%';\r\n codeElement.style.fontSize = '10px';\r\n codeElement.style.pointerEvents = 'none';\r\n\r\n ['log', 'error', 'warn', 'info', 'debug'].forEach(function(value) {\r\n window.console[value] = logFunc;\r\n });\r\n break;\r\n }\r\n }\r\n\r\n return urlOptions;\r\n};\r\n\r\nOptions.prototype = {\r\n extend: function(options) {\r\n utils.objectMix(this, options);\r\n return this;\r\n },\r\n\r\n get: function(key) {\r\n return this[key];\r\n },\r\n\r\n getBoolean: function(key) {\r\n var val = this.getString(key);\r\n if (val) return val !== 'false' && val !== '0';\r\n return undefined;\r\n },\r\n\r\n getNumber: function(key) {\r\n var val = this[key];\r\n if (val) return Number(val);\r\n return undefined;\r\n },\r\n\r\n getString: function(key) {\r\n var val = this[key];\r\n if (val !== undefined) return this[key].toString();\r\n return undefined;\r\n },\r\n\r\n extendWithOptionsURL: function() {\r\n this.extend(Options.getOptionsURL());\r\n }\r\n};\r\n\r\nexport default Options;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar Depth = function(func, near, far, writeMask) {\r\n StateAttribute.call(this);\r\n\r\n this._func = Depth.LESS;\r\n this._near = 0.0;\r\n this._far = 1.0;\r\n this._writeMask = true;\r\n\r\n if (func !== undefined) {\r\n if (typeof func === 'string') {\r\n this._func = Depth[func];\r\n } else {\r\n this._func = func;\r\n }\r\n }\r\n if (near !== undefined) {\r\n this._near = near;\r\n }\r\n if (far !== undefined) {\r\n this._far = far;\r\n }\r\n if (writeMask !== undefined) {\r\n this._writeMask = writeMask;\r\n }\r\n};\r\n\r\nDepth.DISABLE = 0x0000;\r\nDepth.NEVER = 0x0200;\r\nDepth.LESS = 0x0201;\r\nDepth.EQUAL = 0x0202;\r\nDepth.LEQUAL = 0x0203;\r\nDepth.GREATER = 0x0204;\r\nDepth.NOTEQUAL = 0x0205;\r\nDepth.GEQUAL = 0x0206;\r\nDepth.ALWAYS = 0x0207;\r\n\r\nutils.createPrototypeStateAttribute(\r\n Depth,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Depth',\r\n cloneType: function() {\r\n return new Depth();\r\n },\r\n setRange: function(near, far) {\r\n this._near = near;\r\n this._far = far;\r\n },\r\n setWriteMask: function(mask) {\r\n this._writeMask = mask;\r\n },\r\n getWriteMask: function() {\r\n return this._writeMask;\r\n },\r\n getFunc: function() {\r\n return this._func;\r\n },\r\n apply: function(state) {\r\n state.applyDepth(this);\r\n }\r\n }),\r\n 'osg',\r\n 'Depth'\r\n);\r\n\r\nexport default Depth;","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport PooledResource from '../osg/PooledResource';\r\nimport PooledArray from '../osg/PooledArray';\r\nimport TransformEnums from '../osg/transformEnums';\r\n\r\nvar IntersectionVisitor = function() {\r\n NodeVisitor.call(this);\r\n // We could need to use a stack of intersectors in case we want\r\n // to use several intersectors. Right now we use only one.\r\n this._intersector = undefined;\r\n\r\n this._projectionStack = new PooledArray();\r\n this._modelStack = new PooledArray();\r\n this._viewStack = new PooledArray();\r\n this._windowStack = new PooledArray();\r\n this._pooledMatrix = new PooledResource(mat4.create);\r\n\r\n this.reset();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n IntersectionVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function() {\r\n this._pooledMatrix.reset();\r\n this._viewStack.reset();\r\n this._modelStack.reset();\r\n this._projectionStack.reset();\r\n this._windowStack.reset();\r\n\r\n this._viewStack.push(mat4.IDENTITY);\r\n this._modelStack.push(mat4.IDENTITY);\r\n this._projectionStack.push(mat4.IDENTITY);\r\n this._windowStack.push(mat4.IDENTITY);\r\n },\r\n setIntersector: function(intersector) {\r\n this._intersector = intersector;\r\n },\r\n getIntersector: function() {\r\n return this._intersector;\r\n },\r\n // Model matrix\r\n pushModelMatrix: function(matrix) {\r\n this._modelStack.push(matrix);\r\n },\r\n getModelMatrix: function() {\r\n return this._modelStack.back();\r\n },\r\n popModelMatrix: function() {\r\n return this._modelStack.pop();\r\n },\r\n // View Matrix\r\n pushViewMatrix: function(matrix) {\r\n this._viewStack.push(matrix);\r\n },\r\n getViewMatrix: function() {\r\n return this._viewStack.back();\r\n },\r\n popViewMatrix: function() {\r\n return this._viewStack.pop();\r\n },\r\n // Projection Matrix\r\n pushProjectionMatrix: function(matrix) {\r\n this._projectionStack.push(matrix);\r\n },\r\n getProjectionMatrix: function() {\r\n return this._projectionStack.back();\r\n },\r\n popProjectionMatrix: function() {\r\n return this._projectionStack.pop();\r\n },\r\n // Window Matrix\r\n pushWindowMatrix: function(matrix) {\r\n this._windowStack.push(matrix);\r\n },\r\n pushWindowMatrixUsingViewport: function(viewport) {\r\n this._windowStack.push(\r\n viewport.computeWindowMatrix(this._pooledMatrix.getOrCreateObject())\r\n );\r\n },\r\n getWindowMatrix: function() {\r\n return this._windowStack.back();\r\n },\r\n popWindowMatrix: function() {\r\n return this._windowStack.pop();\r\n },\r\n getTransformation: (function() {\r\n // We should move this to the intersector when we need to use different coordinate frames\r\n // Now we only support WINDOW coordinate frame\r\n\r\n // /!\\ 64 bit precision because the picking is jittery otherwise\r\n // It's probably caused by one of the camera matrix that has too big/small values\r\n // but currently it's the ony fix we have\r\n var mat = mat4.create64();\r\n\r\n return function() {\r\n mat4.copy(mat, this.getWindowMatrix());\r\n mat4.mul(mat, mat, this.getProjectionMatrix());\r\n mat4.mul(mat, mat, this.getViewMatrix());\r\n mat4.mul(mat, mat, this.getModelMatrix());\r\n\r\n return mat;\r\n };\r\n })(),\r\n\r\n enter: function(node) {\r\n // Call to each intersector\r\n return this._intersector.enter(node);\r\n },\r\n\r\n apply: function(node) {\r\n // Here we need to decide which apply method to use\r\n if (node.getViewMatrix) {\r\n // It's a Camera\r\n this.applyCamera(node);\r\n } else {\r\n if (node.getMatrix) {\r\n // It's a Transform Node\r\n this.applyTransform(node);\r\n } else {\r\n // It's a leaf or an intermediate node\r\n this.applyNode(node);\r\n }\r\n }\r\n },\r\n\r\n applyCamera: function(camera) {\r\n // We use an absolute reference frame for simplicity\r\n var vp = camera.getViewport();\r\n if (vp !== undefined) {\r\n this.pushWindowMatrixUsingViewport(vp);\r\n }\r\n\r\n var projection, view, model;\r\n if (\r\n camera.getReferenceFrame() === TransformEnums.RELATIVE_RF &&\r\n this.getViewMatrix() &&\r\n this.getProjectionMatrix()\r\n ) {\r\n // relative\r\n projection = mat4.mul(\r\n this._pooledMatrix.getOrCreateObject(),\r\n this.getProjectionMatrix(),\r\n camera.getProjectionMatrix()\r\n );\r\n view = this.getViewMatrix();\r\n model = mat4.mul(\r\n this._pooledMatrix.getOrCreateObject(),\r\n this.getModelMatrix(),\r\n camera.getViewMatrix()\r\n );\r\n } else {\r\n // absolute\r\n projection = camera.getProjectionMatrix();\r\n view = camera.getViewMatrix();\r\n model = mat4.identity(this._pooledMatrix.getOrCreateObject());\r\n }\r\n\r\n this.pushProjectionMatrix(projection);\r\n this.pushViewMatrix(view);\r\n this.pushModelMatrix(model);\r\n\r\n // TODO maybe we should do something like OSG for the transformation given\r\n // to the intersector (having a stack)\r\n this._intersector.setCurrentTransformation(this.getTransformation());\r\n this.traverse(camera);\r\n\r\n this.popModelMatrix();\r\n this.popViewMatrix();\r\n this.popProjectionMatrix();\r\n if (vp !== undefined) {\r\n this.popWindowMatrix();\r\n }\r\n this._intersector.setCurrentTransformation(this.getTransformation());\r\n },\r\n\r\n applyNode: function(node) {\r\n if (!this.enter(node)) return;\r\n // As this part of the code is potentially executed a lot of times we don't use instanceof\r\n // https://jsperf.com/instanceof-performance/25\r\n if (node.getPrimitiveSetList) {\r\n this._intersector.intersect(this, node);\r\n // If it is a leaf (it has primitives) we can safely return\r\n return;\r\n }\r\n if (node.traverse) {\r\n this.traverse(node);\r\n }\r\n },\r\n\r\n applyTransform: function(node) {\r\n // Now only use PROJECTION coordinate frame\r\n if (!this.enter(node)) return;\r\n // Accumulate Transform\r\n if (node.getReferenceFrame() === TransformEnums.ABSOLUTE_RF) {\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n this.pushViewMatrix(mat4.identity(matrix));\r\n this.pushModelMatrix(node.getMatrix());\r\n } else if (this._modelStack.getLength() > 0) {\r\n var m = mat4.copy(this._pooledMatrix.getOrCreateObject(), this.getModelMatrix());\r\n mat4.mul(m, m, node.getMatrix());\r\n this.pushModelMatrix(m);\r\n } else {\r\n this.pushModelMatrix(node.getMatrix());\r\n }\r\n\r\n // TODO see above\r\n this._intersector.setCurrentTransformation(this.getTransformation());\r\n this.traverse(node);\r\n\r\n this.popModelMatrix();\r\n if (node.getReferenceFrame() === TransformEnums.ABSOLUTE_RF) this.popViewMatrix();\r\n this._intersector.setCurrentTransformation(this.getTransformation());\r\n }\r\n }),\r\n 'osgUtil',\r\n 'IntersectionVisitor'\r\n);\r\n\r\nexport default IntersectionVisitor;\r\n","var notify = {};\r\n\r\n// Range of notify levels from DEBUG through to FATAL\r\n// ALWAYS is reserved for forcing the absorption of all messages.\r\n// Must be uppercase and match loggers\r\nnotify.ALWAYS = 0;\r\nnotify.FATAL = notify.ERROR = 1;\r\nnotify.WARN = 2;\r\nnotify.NOTICE = notify.LOG = 3;\r\nnotify.INFO = 4;\r\nnotify.DEBUG = 5;\r\n\r\nnotify.currentNotifyLevel = notify.LOG;\r\nnotify.console = window.console;\r\n\r\n/** logging with readability in mind.\r\n * @param { level } what severity is that log (gives text color too )\r\n * @param { str } actual log text\r\n * @param { fold } sometimes you want to hide looooong text\r\n */\r\nfunction logSub() {\r\n var intLevel = arguments[0];\r\n if (!notify.console || intLevel > notify.currentNotifyLevel) return;\r\n\r\n var strLevel = arguments[1];\r\n var args = Array.prototype.slice.call(arguments);\r\n args = args.splice(2, arguments.length);\r\n\r\n notify.console[strLevel].apply(notify.console, args);\r\n if (notify.traceLogCall && intLevel !== notify.ERROR) console.trace();\r\n}\r\n\r\nfunction logSubFold(intLevel, strLevel, title, str) {\r\n if (!notify.console || intLevel > notify.currentNotifyLevel) return;\r\n\r\n if (notify.console.groupCollapsed) notify.console.groupCollapsed(title);\r\n notify.console[strLevel](str);\r\n if (notify.traceLogCall && intLevel !== notify.ERROR) console.trace();\r\n\r\n if (notify.console.groupEnd) notify.console.groupEnd();\r\n}\r\n\r\nfunction unFlattenMatrix(m, rowMajor) {\r\n if (rowMajor) {\r\n return [m.slice(0, 4), m.slice(4, 8), m.slice(8, 12), m.slice(12, 16)];\r\n }\r\n\r\n return [\r\n [m[0], m[4], m[8], m[12]],\r\n [m[1], m[5], m[9], m[13]],\r\n [m[2], m[6], m[10], m[14]],\r\n [m[3], m[7], m[11], m[15]]\r\n ];\r\n}\r\n\r\nfunction logMatrix(intLevel, m, rowMajor) {\r\n if (intLevel > notify.currentNotifyLevel) return;\r\n\r\n if (notify.console.table) logSub('table', unFlattenMatrix(m, rowMajor));\r\n}\r\n\r\nfunction logMatrixFold(intLevel, title, m, rowMajor) {\r\n if (intLevel > notify.currentNotifyLevel) return;\r\n\r\n if (notify.console.table) logSubFold('table', title, unFlattenMatrix(m, rowMajor));\r\n}\r\n\r\nvar levelEntries = ['error', 'warn', 'log', 'info', 'debug'];\r\n\r\nfor (var i = 0; i < levelEntries.length; ++i) {\r\n var level = levelEntries[i];\r\n var intLevel = notify[level.toUpperCase()];\r\n notify[level] = logSub.bind(notify, intLevel, level);\r\n notify[level + 'Fold'] = logSubFold.bind(notify, intLevel, level);\r\n notify[level + 'Matrix'] = logMatrix.bind(notify, intLevel);\r\n notify[level + 'MatrixFold'] = logMatrixFold.bind(notify, intLevel);\r\n}\r\n\r\nnotify.group = logSub.bind(notify, notify.LOG, 'group');\r\nnotify.groupCollapsed = logSub.bind(notify, notify.LOG, 'groupCollapsed');\r\nnotify.groupEnd = notify.console.groupEnd;\r\n\r\n// alias\r\nnotify.notice = notify.log;\r\nnotify.noticeFold = notify.logFold;\r\nnotify.noticeMatrix = notify.logMatrix;\r\nnotify.noticeMatrixFold = notify.logMatrixFold;\r\n\r\nnotify.timeStamp = function() {};\r\n/* develblock:start */\r\nif (!notify.console || !notify.console.timeStamp) notify.timeStamp = function() {};\r\nelse {\r\n notify.timeStamp = function(label) {\r\n notify.console.timeStamp(label);\r\n };\r\n}\r\n/* develblock:end */\r\n\r\nnotify.assert = function(test, str) {\r\n if (this.console !== undefined && !test) {\r\n this.console.assert(test, str);\r\n }\r\n};\r\n\r\nnotify.setNotifyLevel = function(logLevel, trace) {\r\n notify.currentNotifyLevel = logLevel;\r\n if (trace !== undefined) notify.traceLogCall = trace;\r\n};\r\n\r\nnotify.getNotifyLevel = function() {\r\n return notify.currentNotifyLevel;\r\n};\r\n\r\nnotify.reportWebGLError = false;\r\n\r\nnotify.setConsole = function(replacement) {\r\n notify.console = replacement;\r\n};\r\n\r\nexport default notify;\r\n","import utils from '../../osg/utils';\r\nimport shaderUtils from '../utils';\r\nimport Node from './Node';\r\n\r\nvar sprintf = shaderUtils.sprintf;\r\n\r\n// Base Class for all variables Nodes\r\n// TODO: add precision\r\n// type {string} vec3/4/2, float, int, etc.\r\n// prefix {string} vec3/4/2, float, int, etc.\r\nvar Variable = function(type, prefix) {\r\n Node.call(this);\r\n this._name = 'Variable';\r\n this._prefix = prefix;\r\n this._type = type;\r\n this._value = undefined;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Variable,\r\n utils.objectInherit(Node.prototype, {\r\n getType: function() {\r\n return this._type;\r\n },\r\n\r\n getVariable: function() {\r\n return this._prefix;\r\n },\r\n\r\n setValue: function(value) {\r\n this._value = value;\r\n return this;\r\n },\r\n\r\n toString: function() {\r\n var str = this._name + ' ' + this._prefix;\r\n if (this._type) str += ' (' + this._type + ')';\r\n str += ' - id:' + this._id;\r\n return str;\r\n },\r\n\r\n declare: function() {\r\n if (this._value !== undefined) {\r\n return sprintf('%s %s = %s;', [this._type, this.getVariable(), this._value]);\r\n } else {\r\n return sprintf('%s %s;', [this._type, this.getVariable()]);\r\n }\r\n },\r\n\r\n isEmpty: function() {\r\n return this._value === undefined && this._inputs.length === 0;\r\n },\r\n\r\n reset: function() {\r\n this._inputs = [];\r\n this._outputs = null;\r\n this._value = undefined;\r\n this._text = undefined;\r\n }\r\n }),\r\n 'osgShader',\r\n 'Variable'\r\n);\r\n\r\n// Constant Variable\r\n// help glsl compiler and make sure no one writes in it :)\r\nvar Constant = function(type, prefix) {\r\n Variable.call(this, type, prefix);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Constant,\r\n utils.objectInherit(Variable.prototype, {\r\n declare: function() {\r\n return sprintf('const %s %s = %s;', [this._type, this.getVariable(), this._value]);\r\n }\r\n }),\r\n 'osgShader',\r\n 'Constant'\r\n);\r\n\r\nvar Uniform = function(type, prefix, size) {\r\n Variable.call(this, type, prefix);\r\n this._size = size;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Uniform,\r\n utils.objectInherit(Variable.prototype, {\r\n declare: function() {\r\n return undefined;\r\n },\r\n\r\n globalDeclaration: function() {\r\n if (this._size) {\r\n return sprintf('uniform %s %s[%s];', [this._type, this.getVariable(), this._size]);\r\n } else {\r\n return sprintf('uniform %s %s;', [this._type, this.getVariable()]);\r\n }\r\n }\r\n }),\r\n 'osgShader',\r\n 'Uniform'\r\n);\r\n\r\n// Vertex Attribute Variables\r\nvar Attribute = function(type, prefix) {\r\n Variable.call(this, type, prefix);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Attribute,\r\n utils.objectInherit(Variable.prototype, {\r\n declare: function() {\r\n return undefined;\r\n },\r\n\r\n globalDeclaration: function() {\r\n return sprintf('attribute %s %s;', [this._type, this.getVariable()]);\r\n }\r\n }),\r\n 'osgShader',\r\n 'Attribute'\r\n);\r\n\r\nvar Varying = function(type, prefix) {\r\n Variable.call(this, type, prefix);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Varying,\r\n utils.objectInherit(Variable.prototype, {\r\n declare: function() {\r\n return undefined;\r\n },\r\n\r\n globalDeclaration: function() {\r\n return sprintf('varying %s %s;', [this._type, this.getVariable()]);\r\n }\r\n }),\r\n 'osgShader',\r\n 'Varying'\r\n);\r\n\r\nvar Sampler = function(type, prefix) {\r\n Variable.call(this, type, prefix);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Sampler,\r\n utils.objectInherit(Variable.prototype, {\r\n declare: function() {\r\n return undefined;\r\n },\r\n\r\n globalDeclaration: function() {\r\n return sprintf('uniform %s %s;', [this._type, this.getVariable()]);\r\n }\r\n }),\r\n 'osgShader',\r\n 'Sampler'\r\n);\r\n\r\n// Graph Root Node Abstract Class\r\n// Derive from that for new outputs\r\n// gl_FragDepth, etc.\r\nvar Output = function(type, wholeName) {\r\n Variable.call(this, type, wholeName);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Output,\r\n utils.objectInherit(Variable.prototype, {\r\n _unique: true,\r\n isUnique: function() {\r\n return this._unique;\r\n },\r\n outputs: function() {\r\n /* do nothing for variable */\r\n return this;\r\n },\r\n getVariable: function() {\r\n return this._prefix;\r\n }\r\n }),\r\n 'osgShader',\r\n 'Output'\r\n);\r\n\r\n// Graph Root Nodes\r\nvar glFragColor = function() {\r\n Output.call(this, 'vec4', 'gl_FragColor');\r\n this._name = 'glFragColor';\r\n};\r\n\r\nutils.createPrototypeObject(\r\n glFragColor,\r\n utils.objectInherit(Output.prototype, {}),\r\n 'osgShader',\r\n 'glFragColor'\r\n);\r\n\r\nvar glPosition = function() {\r\n Output.call(this, 'vec4', 'gl_Position');\r\n this._name = 'glPosition';\r\n};\r\n\r\nutils.createPrototypeObject(\r\n glPosition,\r\n utils.objectInherit(Output.prototype, {}),\r\n 'osgShader',\r\n 'glPosition'\r\n);\r\n\r\nvar glPointSize = function() {\r\n Output.call(this, 'float', 'gl_PointSize');\r\n this._name = 'glPointSize';\r\n};\r\n\r\nutils.createPrototypeObject(\r\n glPointSize,\r\n utils.objectInherit(Output.prototype, {}),\r\n 'osgShader',\r\n 'glPointSize'\r\n);\r\n\r\nvar Define = function(name) {\r\n Node.call(this);\r\n this._defineName = name;\r\n this._defineValue = '';\r\n};\r\nutils.createPrototypeObject(\r\n Define,\r\n utils.objectInherit(Node.prototype, {\r\n type: 'Define',\r\n setValue: function(value) {\r\n this._defineValue = value;\r\n return this;\r\n },\r\n getDefines: function() {\r\n return ['#define ' + this._defineName + ' ' + this._defineValue];\r\n }\r\n }),\r\n 'osgShader',\r\n 'Define'\r\n);\r\n\r\nexport default {\r\n Output: Output,\r\n glPointSize: glPointSize,\r\n glPosition: glPosition,\r\n glFragColor: glFragColor,\r\n Sampler: Sampler,\r\n Variable: Variable,\r\n Constant: Constant,\r\n Attribute: Attribute,\r\n Varying: Varying,\r\n Uniform: Uniform,\r\n Define: Define\r\n};\r\n","import notify from '../../osg/notify';\r\nimport utils from '../../osg/utils';\r\nimport Node from './Node';\r\n\r\n// Abstract class\r\n// base operator contains helper for the constructor\r\n// it helps to do that:\r\n// arg0 = output\r\n// arg1 = input0 or [ inputs ]\r\n// arg2 = input1\r\n// ...\r\nvar BaseOperator = function() {\r\n Node.call(this);\r\n};\r\n\r\nBaseOperator.prototype = Node.prototype;\r\n\r\n// Add support this syntax:\r\n// new Add( output, input0, input1, ... )\r\n// new Add( output, [ inputs ] )\r\n// glsl code output = input0 + input1 +...\r\nvar Add = function() {\r\n BaseOperator.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Add,\r\n utils.objectInherit(BaseOperator.prototype, {\r\n type: 'Add',\r\n\r\n operator: '+',\r\n\r\n _getFirstVariableCast: function() {\r\n var variable = this._inputs[0].getVariable();\r\n var inType = this._inputs[0].getType();\r\n var outType = this._outputs.getType();\r\n\r\n if (outType === inType) return variable;\r\n\r\n // upcast float\r\n if (inType === 'float') return outType + '(' + variable + ')';\r\n\r\n // downcast vector\r\n if (outType === 'vec3') return variable + '.rgb';\r\n if (outType === 'vec2') return variable + '.rg';\r\n if (outType === 'float') return variable + '.r';\r\n\r\n notify.error('Mismatch type : ' + outType + ' with ' + inType + ', ' + variable);\r\n return variable;\r\n },\r\n\r\n computeShader: function() {\r\n // force inputs type to be all the same from the output\r\n var outputType = this._outputs.getType();\r\n var addType = '';\r\n\r\n if (outputType === 'vec4') addType = '.rgba';\r\n else if (outputType === 'vec3') addType = '.rgb';\r\n else if (outputType === 'vec2') addType = '.rg';\r\n\r\n var firstVariable = this._getFirstVariableCast();\r\n var str = this._outputs.getVariable() + ' = ' + firstVariable;\r\n\r\n for (var i = 1, l = this._inputs.length; i < l; i++) {\r\n var input = this._inputs[i];\r\n str += this.operator + input.getVariable();\r\n\r\n var inType = input.getType();\r\n if (inType !== 'float' && inType !== outputType) {\r\n str += addType;\r\n }\r\n }\r\n str += ';';\r\n return str;\r\n }\r\n }),\r\n 'osgShader',\r\n 'Add'\r\n);\r\n\r\n// Mult works like Add\r\n// glsl code output = input0 * input1 * ...\r\nvar Mult = function() {\r\n Add.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Mult,\r\n utils.objectInherit(Add.prototype, {\r\n type: 'Mult',\r\n operator: '*'\r\n }),\r\n 'osgShader',\r\n 'Mult'\r\n);\r\n\r\n// basic assignement alias: output = input\r\n// glsl code output = input0\r\nvar SetFromNode = function() {\r\n Add.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n SetFromNode,\r\n utils.objectInherit(Add.prototype, {\r\n type: 'SetFromNode'\r\n }),\r\n 'osgShader',\r\n 'SetFromNode'\r\n);\r\n\r\n// Mult Matrix * vector4\r\n// making the cast vector4(input.xyz, 0)\r\n// if needed\r\n// glsl code output = matrix * vector4(vec.xyz, 0)\r\nvar MatrixMultDirection = function() {\r\n Add.call(this);\r\n this._overwriteW = true; // if set to false, we copy the input alpha in the output alpha\r\n this._forceComplement = true;\r\n this._inverseOp = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n MatrixMultDirection,\r\n utils.objectInherit(Add.prototype, {\r\n type: 'MatrixMultDirection',\r\n operator: '*',\r\n validInputs: ['vec', 'matrix'],\r\n validOutputs: ['vec'],\r\n complement: '0.',\r\n setInverse: function(bool) {\r\n this._inverseOp = bool;\r\n return this;\r\n },\r\n setForceComplement: function(bool) {\r\n this._forceComplement = bool;\r\n return this;\r\n },\r\n setOverwriteW: function(bool) {\r\n this._overwriteW = bool;\r\n return this;\r\n },\r\n computeShader: function() {\r\n // force inputs type to be all the same from the output\r\n // and handle vector complement\r\n var vecIn = this._inputs.vec.getVariable();\r\n var matrix = this._inputs.matrix.getVariable();\r\n var vecOut = this._outputs.vec.getVariable();\r\n\r\n var inputType = this._inputs.vec.getType();\r\n var outputType = this._outputs.vec.getType();\r\n var matrixType = this._inputs.matrix.getType();\r\n\r\n var strOut = vecOut;\r\n\r\n if (matrixType === 'mat4') {\r\n strOut += ' = ';\r\n\r\n if (outputType !== 'vec4') strOut += outputType + '(';\r\n\r\n var strCasted = vecIn;\r\n if (this._forceComplement || inputType !== 'vec4')\r\n strCasted = 'vec4(' + vecIn + '.xyz, ' + this.complement + ')';\r\n\r\n strOut += this._inverseOp\r\n ? strCasted + this.operator + matrix\r\n : matrix + this.operator + strCasted;\r\n\r\n if (outputType !== 'vec4') strOut += ')';\r\n\r\n strOut += ';';\r\n\r\n if (!this._overwriteW && inputType === 'vec4')\r\n strOut += '\\n' + vecOut + '.a = ' + vecIn + '.a;';\r\n } else {\r\n if (outputType === 'vec4') strOut += '.xyz';\r\n strOut += ' = ';\r\n\r\n var strvec3 = vecIn + '.xyz';\r\n strOut +=\r\n (this._inverseOp\r\n ? strvec3 + this.operator + matrix\r\n : matrix + this.operator + strvec3) + ';';\r\n\r\n if (!this._overwriteW && outputType === 'vec4' && inputType === 'vec4')\r\n strOut += '\\n' + vecOut + '.a = ' + vecIn + '.a;';\r\n }\r\n\r\n return strOut;\r\n }\r\n }),\r\n 'osgShader',\r\n 'MatrixMultDirection'\r\n);\r\n\r\n// override only for complement.\r\n// glsl code output = matrix * vector4(vec.xyz, 1)\r\nvar MatrixMultPosition = function() {\r\n MatrixMultDirection.call(this);\r\n this._forceComplement = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n MatrixMultPosition,\r\n utils.objectInherit(MatrixMultDirection.prototype, {\r\n type: 'MatrixMultPosition',\r\n complement: '1.'\r\n }),\r\n 'osgShader',\r\n 'MatrixMultPosition'\r\n);\r\n\r\nvar Blend = function() {\r\n BaseOperator.apply(this);\r\n this._mode = 'MIX';\r\n};\r\nutils.createPrototypeObject(\r\n Blend,\r\n utils.objectInherit(BaseOperator.prototype, {\r\n type: 'Blend',\r\n mode: function(mode) {\r\n this._mode = mode;\r\n return this;\r\n },\r\n computeShader: function() {\r\n return this[this._mode === undefined ? 'MIX' : this._mode]();\r\n },\r\n ADD: function() {\r\n return (\r\n this._outputs.getVariable() +\r\n ' = ' +\r\n this._inputs[0].getVariable() +\r\n ' + (' +\r\n this._inputs[1].getVariable() +\r\n ' * ' +\r\n this._inputs[2].getVariable() +\r\n ');'\r\n );\r\n },\r\n MIX: function() {\r\n // result = val0*(1.0-t) + t*val1\r\n return (\r\n this._outputs.getVariable() +\r\n ' = mix(' +\r\n this._inputs[0].getVariable() +\r\n ', ' +\r\n this._inputs[1].getVariable() +\r\n ', ' +\r\n this._inputs[2].getVariable() +\r\n ');'\r\n );\r\n },\r\n MULTIPLY: function() {\r\n return (\r\n this._outputs.getVariable() +\r\n ' = ' +\r\n this._inputs[0].getVariable() +\r\n ' * mix( ' +\r\n this._inputs[0].getType() +\r\n '(1.0), ' +\r\n this._inputs[1].getVariable() +\r\n ', ' +\r\n this._inputs[2].getVariable() +\r\n ');'\r\n );\r\n }\r\n })\r\n);\r\n\r\n// For all you custom needs.\r\n//\r\n// call Code() with variable input/output replace\r\n// indexed by the '%'\r\n// getNode( 'InlineCode' ).code( '%out = %input;' ).inputs( {\r\n// input: this.getOrCreateConstant( 'float', 'unitFloat' ).setValue( '1.0' )\r\n// } ).outputs( {\r\n// out: this.getNode( 'glPointSize' )\r\n// }\r\n//\r\nvar InlineCode = function() {\r\n Node.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n InlineCode,\r\n utils.objectInherit(Node.prototype, {\r\n type: 'InlineCode',\r\n code: function(txt) {\r\n this._text = txt;\r\n return this;\r\n },\r\n computeShader: function() {\r\n // merge inputs and outputs dict to search in both\r\n var replaceVariables = utils.objectMix({}, this._inputs);\r\n replaceVariables = utils.objectMix(replaceVariables, this._outputs);\r\n\r\n // find all %string\r\n var r = new RegExp('%[A-Za-z0-9_]+', 'gm');\r\n var text = this._text;\r\n var result = this._text.match(r);\r\n\r\n var done = new Set(); // keep trace of replaced string\r\n\r\n for (var i = 0; i < result.length; i++) {\r\n var str = result[i].substr(1);\r\n if (!done.has(str)) {\r\n if (!replaceVariables[str]) {\r\n notify.error('error with inline code\\n' + this._text);\r\n notify.error('input ' + str + ' not provided for ' + result[i]);\r\n }\r\n var reg = new RegExp(result[i].toString(), 'gm');\r\n text = text.replace(reg, replaceVariables[str].getVariable());\r\n done.add(str);\r\n }\r\n }\r\n\r\n return text;\r\n }\r\n }),\r\n 'osgShader',\r\n 'InlineCode'\r\n);\r\n\r\nexport default {\r\n BaseOperator: BaseOperator,\r\n Mult: Mult,\r\n MatrixMultPosition: MatrixMultPosition,\r\n MatrixMultDirection: MatrixMultDirection,\r\n Add: Add,\r\n Blend: Blend,\r\n InlineCode: InlineCode,\r\n SetFromNode: SetFromNode\r\n};\r\n","import notify from '../osg/notify';\r\nimport data from './node/data';\r\nimport operations from './node/operations';\r\nimport shaderUtils from './utils';\r\nimport shaderLib from './shaderLib';\r\nimport shadowLib from '../osgShadow/shaderLib';\r\n\r\nvar Factory = function() {\r\n this._nodes = new window.Map();\r\n\r\n this.extractFunctions(shaderLib, 'lights.glsl');\r\n this.extractFunctions(shaderLib, 'lightCommon.glsl');\r\n this.extractFunctions(shaderLib, 'skinning.glsl');\r\n this.extractFunctions(shaderLib, 'morphing.glsl');\r\n this.extractFunctions(shaderLib, 'billboard.glsl');\r\n this.extractFunctions(shaderLib, 'functions.glsl');\r\n this.extractFunctions(shaderLib, 'textures.glsl');\r\n\r\n this.extractFunctions(shadowLib, 'shadowCast.glsl');\r\n this.extractFunctions(shadowLib, 'shadowReceive.glsl');\r\n\r\n this.registerNodes(data);\r\n this.registerNodes(operations);\r\n};\r\n\r\nFactory.prototype = {\r\n registerNodes: function(obj) {\r\n for (var key in obj) {\r\n this.registerNode(key, obj[key]);\r\n }\r\n },\r\n\r\n registerNode: function(name, constructor) {\r\n if (this._nodes.has(name)) {\r\n notify.warn('Node ' + name + ' already registered');\r\n }\r\n this._nodes.set(name, constructor);\r\n },\r\n\r\n extractFunctions: function(lib, filename) {\r\n this.registerNodes(shaderUtils.extractFunctions(lib, filename));\r\n },\r\n\r\n // extra argument are passed to the constructor of the node\r\n getNode: function(name) {\r\n var Constructor = this._nodes.get(name);\r\n if (!Constructor) {\r\n // Means either:\r\n // - the node isn't registered by methods above\r\n // - you mistyped the name\r\n // - Core Node has changed its Name\r\n notify.warn('Node ' + name + ' does not exist');\r\n return undefined;\r\n }\r\n\r\n // call a constructor with array arguments\r\n // http://www.ecma-international.org/ecma-262/5.1/#sec-13.2.2\r\n var instance = window.Object.create(Constructor.prototype);\r\n Constructor.apply(instance, Array.prototype.slice.call(arguments, 1));\r\n\r\n return instance;\r\n }\r\n};\r\n\r\nvar instance = new Factory();\r\n\r\nexport default instance;\r\n","export default \"#define PI 3.141593\\r\\n#define saturate(_x) clamp(_x, 0., 1.)\\r\\n\";","export default \"// approximation such as http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html\\r\\n// introduced slightly darker colors and more slight banding in the darks.\\r\\n\\r\\n// so we stick with the reference implementation (except we don't check if color >= 0.0):\\r\\n// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt\\r\\n#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055\\r\\n#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nfloat linearTosRGB(const in float color) { return LIN_SRGB(color); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec3 linearTosRGB(const in vec3 color) { return vec3(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b)); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 linearTosRGB(const in vec4 color) { return vec4(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b), color.a); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\\r\\nfloat sRGBToLinear(const in float color) { return SRGB_LIN(color); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\\r\\nvec3 sRGBToLinear(const in vec3 color) { return vec3(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b)); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\\r\\nvec4 sRGBToLinear(const in vec4 color) { return vec4(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b), color.a); }\\r\\n\\r\\n//http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\\r\\nvec3 RGBMToRGB( const in vec4 rgba ) {\\r\\n const float maxRange = 8.0;\\r\\n return rgba.rgb * maxRange * rgba.a;\\r\\n}\\r\\n\\r\\nconst mat3 LUVInverse = mat3( 6.0013, -2.700, -1.7995, -1.332, 3.1029, -5.7720, 0.3007, -1.088, 5.6268 );\\r\\n\\r\\nvec3 LUVToRGB( const in vec4 vLogLuv ) {\\r\\n float Le = vLogLuv.z * 255.0 + vLogLuv.w;\\r\\n vec3 Xp_Y_XYZp;\\r\\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\\r\\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;\\r\\n Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;\\r\\n vec3 vRGB = LUVInverse * Xp_Y_XYZp;\\r\\n return max(vRGB, 0.0);\\r\\n}\\r\\n\\r\\n// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 encodeRGBM(const in vec3 color, const in float range) {\\r\\n if(range <= 0.0) return vec4(color, 1.0);\\r\\n vec4 rgbm;\\r\\n vec3 col = color / range;\\r\\n rgbm.a = clamp( max( max( col.r, col.g ), max( col.b, 1e-6 ) ), 0.0, 1.0 );\\r\\n rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;\\r\\n rgbm.rgb = col / rgbm.a;\\r\\n return rgbm;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec3 decodeRGBM(const in vec4 color, const in float range) {\\r\\n if(range <= 0.0) return color.rgb;\\r\\n return range * color.rgb * color.a;\\r\\n}\\r\\n\\r\\n// https://twitter.com/pyalot/status/711956736639418369\\r\\n// https://github.com/mrdoob/three.js/issues/10331\\r\\n#pragma DECLARE_FUNCTION NODE_NAME:FrontNormal\\r\\n#define _frontNormal(normal) gl_FrontFacing ? normal : -normal\\r\\n\\r\\n#pragma DECLARE_FUNCTION NODE_NAME:Normalize\\r\\n#define _normalize(vec) normalize(vec)\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 preMultAlpha(const in vec3 color, const in float alpha) { return vec4(color.rgb * alpha, alpha); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 preMultAlpha(const in vec4 color) { return vec4(color.rgb * color.a, color.a); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 setAlpha(const in vec3 color, const in float alpha) { return vec4(color, alpha); }\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 setAlpha(const in vec3 color, const in vec4 alpha) { return vec4(color, alpha.a); }\\r\\n\";","export default \"float getLightAttenuation(const in float dist, const in vec4 lightAttenuation) {\\r\\n // lightAttenuation(constantEnabled, linearEnabled, quadraticEnabled)\\r\\n // TODO find a vector alu instead of 4 scalar\\r\\n float constant = lightAttenuation.x;\\r\\n float linear = lightAttenuation.y * dist;\\r\\n float quadratic = lightAttenuation.z * dist * dist;\\r\\n return 1.0 / (constant + linear + quadratic);\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvoid precomputeSpot(\\r\\n const in vec3 normal,\\r\\n const in vec3 viewVertex,\\r\\n \\r\\n const in vec3 lightViewDirection,\\r\\n const in vec4 lightAttenuation,\\r\\n const in vec3 lightViewPosition,\\r\\n const in float lightSpotCutOff,\\r\\n const in float lightSpotBlend,\\r\\n \\r\\n out float attenuation,\\r\\n out vec3 eyeLightDir,\\r\\n out float dotNL) {\\r\\n\\r\\n eyeLightDir = lightViewPosition - viewVertex;\\r\\n float dist = length(eyeLightDir);\\r\\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\\r\\n\\r\\n float cosCurAngle = dot(-eyeLightDir, lightViewDirection);\\r\\n float spot = cosCurAngle * smoothstep(0.0, 1.0, (cosCurAngle - lightSpotCutOff) / lightSpotBlend);\\r\\n\\r\\n dotNL = dot(eyeLightDir, normal);\\r\\n attenuation = spot * getLightAttenuation(dist, lightAttenuation);\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvoid precomputePoint(\\r\\n const in vec3 normal,\\r\\n const in vec3 viewVertex,\\r\\n\\r\\n const in vec4 lightAttenuation,\\r\\n const in vec3 lightViewPosition,\\r\\n\\r\\n out float attenuation,\\r\\n out vec3 eyeLightDir,\\r\\n out float dotNL) {\\r\\n\\r\\n eyeLightDir = lightViewPosition - viewVertex;\\r\\n float dist = length(eyeLightDir);\\r\\n\\r\\n attenuation = getLightAttenuation(dist, lightAttenuation);\\r\\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\\r\\n dotNL = dot(eyeLightDir, normal);\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvoid precomputeSun(\\r\\n const in vec3 normal,\\r\\n const in vec3 lightViewDirection,\\r\\n \\r\\n out float attenuation,\\r\\n out vec3 eyeLightDir,\\r\\n out float dotNL) {\\r\\n\\r\\n attenuation = 1.0;\\r\\n eyeLightDir = -lightViewDirection;\\r\\n dotNL = dot(eyeLightDir, normal);\\r\\n}\";","export default \"#pragma include \\\"lightCommon.glsl\\\"\\r\\n\\r\\n////////////////\\r\\n// COOK TORRANCE\\r\\n////////////////\\r\\nvec3 specularCookTorrance(\\r\\n const in vec3 normal,\\r\\n const in vec3 lightDir,\\r\\n const in vec3 eyeVector,\\r\\n const in float materialShininess,\\r\\n const in vec3 materialSpecular,\\r\\n const in vec3 lightSpecular) {\\r\\n \\r\\n vec3 h = normalize(eyeVector + lightDir);\\r\\n float nh = dot(normal, h);\\r\\n float specfac = 0.0;\\r\\n\\r\\n if(nh > 0.0) {\\r\\n float nv = max( dot(normal, eyeVector), 0.0 );\\r\\n float i = pow(nh, materialShininess);\\r\\n i = i / (0.1 + nv);\\r\\n specfac = i;\\r\\n }\\r\\n // ugly way to fake an energy conservation (mainly to avoid super bright stuffs with low glossiness)\\r\\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\\r\\n return specfac * materialSpecular * lightSpecular * att;\\r\\n}\\r\\n\\r\\nvec3 lambert(const in float dotNL, const in vec3 materialDiffuse, const in vec3 lightDiffuse) {\\r\\n return dotNL * materialDiffuse * lightDiffuse;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvoid computeLightLambertCookTorrance(\\r\\n const in vec3 normal,\\r\\n const in vec3 eyeVector,\\r\\n const in float dotNL,\\r\\n const in float attenuation,\\r\\n\\r\\n const in vec3 materialDiffuse,\\r\\n const in vec3 materialSpecular,\\r\\n const in float materialShininess,\\r\\n\\r\\n const in vec3 lightDiffuse,\\r\\n const in vec3 lightSpecular,\\r\\n const in vec3 eyeLightDir,\\r\\n\\r\\n out vec3 diffuseOut,\\r\\n out vec3 specularOut,\\r\\n out bool lighted) {\\r\\n\\r\\n lighted = dotNL > 0.0;\\r\\n if (lighted == false) {\\r\\n specularOut = diffuseOut = vec3(0.0);\\r\\n return;\\r\\n }\\r\\n\\r\\n specularOut = attenuation * specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular);\\r\\n diffuseOut = attenuation * lambert(dotNL, materialDiffuse, lightDiffuse);\\r\\n}\\r\\n\\r\\n///////\\r\\n// HEMI\\r\\n///////\\r\\n#pragma DECLARE_FUNCTION\\r\\nvoid hemiLight(\\r\\n const in vec3 normal,\\r\\n const in vec3 eyeVector,\\r\\n const in float dotNL,\\r\\n const in vec3 eyeLightDir,\\r\\n\\r\\n const in vec3 materialDiffuse,\\r\\n const in vec3 materialSpecular,\\r\\n const in float materialShininess,\\r\\n\\r\\n const in vec3 lightDiffuse,\\r\\n const in vec3 lightGround,\\r\\n\\r\\n out vec3 diffuseOut,\\r\\n out vec3 specularOut,\\r\\n out bool lighted) {\\r\\n\\r\\n lighted = false;\\r\\n float weight = 0.5 * dotNL + 0.5;\\r\\n diffuseOut = materialDiffuse * mix(lightGround, lightDiffuse, weight);\\r\\n\\r\\n // same cook-torrance as above for sky/ground\\r\\n float skyWeight = 0.5 * dot(normal, normalize(eyeVector + eyeLightDir)) + 0.5;\\r\\n float gndWeight = 0.5 * dot(normal, normalize(eyeVector - eyeLightDir)) + 0.5;\\r\\n float skySpec = pow(skyWeight, materialShininess);\\r\\n float skyGround = pow(gndWeight, materialShininess);\\r\\n float divisor = (0.1 + max( dot(normal, eyeVector), 0.0 ));\\r\\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\\r\\n \\r\\n specularOut = lightDiffuse * materialSpecular * weight * att * (skySpec + skyGround) / divisor;\\r\\n}\\r\\n\";","export default \"//////////////////////////////\\r\\n// OPTIMIZED VERSION (NO IF)\\r\\n//////////////////////////////\\r\\n#pragma DECLARE_FUNCTION\\r\\nmat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\\r\\n mat4 outMat_1;\\r\\n mat4 tmpMat_2;\\r\\n highp ivec4 tmpvar_3;\\r\\n tmpvar_3 = (3 * ivec4(bonesIndex));\\r\\n tmpMat_2 = mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\\r\\n vec4 tmpvar_4;\\r\\n tmpvar_4 = -(abs(weights));\\r\\n tmpMat_2[0] = uBones[tmpvar_3.x];\\r\\n tmpMat_2[1] = uBones[(tmpvar_3.x + 1)];\\r\\n tmpMat_2[2] = uBones[(tmpvar_3.x + 2)];\\r\\n outMat_1 = ((float(\\r\\n ((tmpvar_4.x + tmpvar_4.y) >= -((tmpvar_4.z + tmpvar_4.w)))\\r\\n ) * mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0)) + (weights.x * tmpMat_2));\\r\\n tmpMat_2[0] = uBones[tmpvar_3.y];\\r\\n tmpMat_2[1] = uBones[(tmpvar_3.y + 1)];\\r\\n tmpMat_2[2] = uBones[(tmpvar_3.y + 2)];\\r\\n outMat_1 = (outMat_1 + (weights.y * tmpMat_2));\\r\\n tmpMat_2[0] = uBones[tmpvar_3.z];\\r\\n tmpMat_2[1] = uBones[(tmpvar_3.z + 1)];\\r\\n tmpMat_2[2] = uBones[(tmpvar_3.z + 2)];\\r\\n outMat_1 = (outMat_1 + (weights.z * tmpMat_2));\\r\\n tmpMat_2[0] = uBones[tmpvar_3.w];\\r\\n tmpMat_2[1] = uBones[(tmpvar_3.w + 1)];\\r\\n tmpMat_2[2] = uBones[(tmpvar_3.w + 2)];\\r\\n outMat_1 = (outMat_1 + (weights.w * tmpMat_2));\\r\\n\\r\\n return outMat_1;\\r\\n}\\r\\n\\r\\n//////////////////////////////\\r\\n// UN-OPTIMIZED VERSION (WITH IF)\\r\\n//////////////////////////////\\r\\n\\r\\n// //http://http.developer.nvidia.com/GPUGems/gpugems_ch04.html\\r\\n// mat4 getMat4FromVec4( const int index, inout mat4 myMat ) {\\r\\n// // We have to use a global variable because we can't access dynamically\\r\\n// // matrix is transpose so we should do vec * matrix\\r\\n// myMat[0] = uBones[ index ];\\r\\n// myMat[1] = uBones[ index + 1];\\r\\n// myMat[2] = uBones[ index + 2];\\r\\n// return myMat;\\r\\n// }\\r\\n\\r\\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\\r\\n// ivec4 idx = 3 * ivec4(bonesIndex);\\r\\n// mat4 tmpMat = mat4(1.0);\\r\\n// mat4 outMat = mat4(0.0);\\r\\n\\r\\n// // we handle negative weights\\r\\n// if(all(equal(weights, vec4(0.0)))) return tmpMat;\\r\\n\\r\\n// if(weights.x != 0.0) outMat += weights.x * getMat4FromVec4( idx.x, tmpMat );\\r\\n// if(weights.y != 0.0) outMat += weights.y * getMat4FromVec4( idx.y, tmpMat );\\r\\n// if(weights.z != 0.0) outMat += weights.z * getMat4FromVec4( idx.z, tmpMat );\\r\\n// if(weights.w != 0.0) outMat += weights.w * getMat4FromVec4( idx.w, tmpMat );\\r\\n// return outMat;\\r\\n// }\\r\\n\\r\\n//////////////////////////////\\r\\n// UN-OPTIMIZED VERSION (NO IF)\\r\\n//////////////////////////////\\r\\n\\r\\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\\r\\n// ivec4 idx = 3 * ivec4(bonesIndex);\\r\\n// mat4 tmpMat = mat4(1.0);\\r\\n\\r\\n// // if sum is 0, return identity\\r\\n// vec4 absWeights = -abs(weights);\\r\\n// mat4 outMat = step(0.0, absWeights.x + absWeights.y + absWeights.z + absWeights.w) * tmpMat;\\r\\n\\r\\n// // we handle negative weights\\r\\n// // outMat[3][3] += weights.x + weights.y + weights.z + weights.w;\\r\\n\\r\\n// tmpMat[0] = uBones[ idx.x ];\\r\\n// tmpMat[1] = uBones[ idx.x + 1];\\r\\n// tmpMat[2] = uBones[ idx.x + 2];\\r\\n// outMat += weights.x * tmpMat;\\r\\n\\r\\n// tmpMat[0] = uBones[ idx.y ];\\r\\n// tmpMat[1] = uBones[ idx.y + 1];\\r\\n// tmpMat[2] = uBones[ idx.y + 2];\\r\\n// outMat += weights.y * tmpMat;\\r\\n\\r\\n// tmpMat[0] = uBones[ idx.z ];\\r\\n// tmpMat[1] = uBones[ idx.z + 1];\\r\\n// tmpMat[2] = uBones[ idx.z + 2];\\r\\n// outMat += weights.z * tmpMat;\\r\\n\\r\\n// tmpMat[0] = uBones[ idx.w ];\\r\\n// tmpMat[1] = uBones[ idx.w + 1];\\r\\n// tmpMat[2] = uBones[ idx.w + 2];\\r\\n// outMat += weights.w * tmpMat;\\r\\n\\r\\n// return outMat;\\r\\n// }\\r\\n\";","export default \"#pragma DECLARE_FUNCTION\\r\\nvec3 morphing(\\r\\n const in vec4 weights,\\r\\n const in vec3 vertex,\\r\\n const in vec3 target0) {\\r\\n\\r\\n return mix(vertex, target0, weights[0]);\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec3 morphing(\\r\\n const in vec4 weights,\\r\\n const in vec3 vertex,\\r\\n const in vec3 target0,\\r\\n const in vec3 target1) {\\r\\n\\r\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1]));\\r\\n vecOut += target0 * weights[0];\\r\\n vecOut += target1 * weights[1];\\r\\n return vecOut;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec3 morphing(\\r\\n const in vec4 weights,\\r\\n const in vec3 vertex,\\r\\n const in vec3 target0,\\r\\n const in vec3 target1,\\r\\n const in vec3 target2) {\\r\\n \\r\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2]));\\r\\n vecOut += target0 * weights[0];\\r\\n vecOut += target1 * weights[1];\\r\\n vecOut += target2 * weights[2];\\r\\n return vecOut;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec3 morphing(\\r\\n const in vec4 weights,\\r\\n const in vec3 vertex,\\r\\n const in vec3 target0,\\r\\n const in vec3 target1,\\r\\n const in vec3 target2,\\r\\n const in vec3 target3) {\\r\\n\\r\\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2] + weights[3]));\\r\\n vecOut += target0 * weights[0];\\r\\n vecOut += target1 * weights[1];\\r\\n vecOut += target2 * weights[2];\\r\\n vecOut += target3 * weights[3];\\r\\n return vecOut;\\r\\n}\\r\\n\";","export default \"#pragma DECLARE_FUNCTION\\r\\nvec3 textureRGB(const in sampler2D tex, const in vec2 uv) {\\r\\n return texture2D(tex, uv.xy).rgb;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 textureRGBA(const in sampler2D tex, const in vec2 uv) {\\r\\n return texture2D(tex, uv.xy).rgba;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nfloat textureIntensity(const in sampler2D tex, const in vec2 uv) {\\r\\n return texture2D(tex, uv).r;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nfloat textureAlpha(const in sampler2D tex, const in vec2 uv) {\\r\\n return texture2D(tex, uv.xy).a;\\r\\n}\\r\\n\";","export default \"\\r\\nfloat decodeFloatRGBA( vec4 rgba ) {\\r\\n return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) );\\r\\n}\\r\\n\\r\\nvec4 encodeFloatRGBA( float v ) {\\r\\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\\r\\n enc = fract(enc);\\r\\n enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);\\r\\n return enc;\\r\\n}\\r\\n\\r\\nvec2 decodeHalfFloatRGBA( vec4 rgba ) {\\r\\n return vec2(rgba.x + (rgba.y / 255.0), rgba.z + (rgba.w / 255.0));\\r\\n}\\r\\n\\r\\nvec4 encodeHalfFloatRGBA( vec2 v ) {\\r\\n const vec2 bias = vec2(1.0 / 255.0, 0.0);\\r\\n vec4 enc;\\r\\n enc.xy = vec2(v.x, fract(v.x * 255.0));\\r\\n enc.xy = enc.xy - (enc.yy * bias);\\r\\n\\r\\n enc.zw = vec2(v.y, fract(v.y * 255.0));\\r\\n enc.zw = enc.zw - (enc.ww * bias);\\r\\n return enc;\\r\\n}\\r\\n\";","export default \"vec3 getScale( const in mat4 matrix ) {\\r\\n // Only working with positive scales.\\r\\n float xs = matrix[0][0] * matrix[0][1] * matrix[0][2] * matrix[0][3] < 0. ? -1. : 1.;\\r\\n float ys = matrix[1][0] * matrix[1][1] * matrix[1][2] * matrix[1][3] < 0. ? -1. : 1.;\\r\\n float zs = matrix[2][0] * matrix[2][1] * matrix[2][2] * matrix[2][3] < 0. ? -1. : 1.;\\r\\n vec3 scale;\\r\\n scale.x = xs * sqrt( matrix[0][0] * matrix[0][0] + matrix[0][1] * matrix[0][1] + matrix[0][2] * matrix[0][2]);\\r\\n scale.y = ys * sqrt( matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]);\\r\\n scale.z = zs * sqrt( matrix[2][0] * matrix[2][0] + matrix[2][1] * matrix[2][1] + matrix[2][2] * matrix[2][2]);\\r\\n return scale;\\r\\n}\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 billboard( const in vec3 vertex, const in mat4 modelViewMatrix, const in mat4 projectionMatrix ) {\\r\\n vec3 scale = getScale( modelViewMatrix );\\r\\n return projectionMatrix * ( vec4( scale.x* vertex.x , scale.y * vertex.y, scale.z * vertex.z, 1.0 ) + vec4( modelViewMatrix[ 3 ].xyz, 0.0 ) );\\r\\n}\\r\\n\";","import common from './node/common.glsl';\r\nimport functions from './node/functions.glsl';\r\nimport lightCommon from './node/lightCommon.glsl';\r\nimport lights from './node/lights.glsl';\r\nimport skinning from './node/skinning.glsl';\r\nimport morphing from './node/morphing.glsl';\r\nimport textures from './node/textures.glsl';\r\nimport colorEncode from './node/colorEncode.glsl';\r\nimport billboard from './node/billboard.glsl';\r\n\r\nexport default {\r\n 'common.glsl': common,\r\n 'functions.glsl': functions,\r\n 'lightCommon.glsl': lightCommon,\r\n 'lights.glsl': lights,\r\n 'skinning.glsl': skinning,\r\n 'morphing.glsl': morphing,\r\n 'textures.glsl': textures,\r\n 'colorEncode.glsl': colorEncode,\r\n 'billboard.glsl': billboard\r\n};\r\n","import notify from './notify';\r\nimport utils from './utils';\r\nimport BoundingBox from './BoundingBox';\r\nimport { vec3, mat4 } from './glMatrix';\r\n\r\nvar BoundingSphere = function() {\r\n this._center = vec3.create();\r\n this._radius = -1.0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n BoundingSphere, {\r\n init: function() {\r\n vec3.init(this._center);\r\n this._radius = -1.0;\r\n },\r\n\r\n valid: function() {\r\n return this._radius >= 0.0;\r\n },\r\n\r\n set: function(center, radius) {\r\n this._center = center;\r\n this._radius = radius;\r\n },\r\n\r\n center: function() {\r\n return this._center;\r\n },\r\n\r\n radius: function() {\r\n return this._radius;\r\n },\r\n\r\n radius2: function() {\r\n return this._radius * this._radius;\r\n },\r\n\r\n volume: function() {\r\n var r = this._radius;\r\n return r * r * r * Math.PI * 4 / 3;\r\n },\r\n\r\n copy: function(other) {\r\n this._radius = other._radius;\r\n vec3.copy(this._center, other._center);\r\n },\r\n\r\n copyBoundingBox: function(box) {\r\n box.center(this._center);\r\n this._radius = box.radius();\r\n },\r\n\r\n expandByBoundingBox: (function() {\r\n var v = vec3.create();\r\n var newbb = new BoundingBox();\r\n\r\n return function(bb) {\r\n if (!bb.valid()) return;\r\n\r\n if (!this.valid()) {\r\n this.copyBoundingBox(bb);\r\n return;\r\n }\r\n\r\n vec3.copy(newbb._min, bb._min);\r\n vec3.copy(newbb._max, bb._max);\r\n\r\n for (var i = 0; i < 8; i++) {\r\n vec3.sub(v, bb.corner(i, v), this._center); // get the direction vector from corner\r\n vec3.normalize(v, v); // normalise it.\r\n vec3.scaleAndAdd(v, this._center, v, -this._radius); // move the vector in the opposite direction distance radius.\r\n newbb.expandByVec3(v); // add it into the new bounding box.\r\n }\r\n\r\n newbb.center(this._center);\r\n this._radius = newbb.radius();\r\n };\r\n })(),\r\n\r\n expandByvec3: function(v) {\r\n notify.warn('deprecated, use expandByVec3');\r\n this.expandByVec3(v);\r\n },\r\n\r\n expandByVec3: (function() {\r\n var dv = vec3.create();\r\n return function(v) {\r\n if (this.valid()) {\r\n vec3.sub(dv, v, this.center(dv));\r\n var r = vec3.length(dv);\r\n if (r > this.radius()) {\r\n var dr = (r - this.radius()) * 0.5;\r\n this._center[0] += dv[0] * (dr / r);\r\n this._center[1] += dv[1] * (dr / r);\r\n this._center[2] += dv[2] * (dr / r);\r\n this._radius += dr;\r\n }\r\n } else {\r\n this._center[0] = v[0];\r\n this._center[1] = v[1];\r\n this._center[2] = v[2];\r\n this._radius = 0.0;\r\n }\r\n };\r\n })(),\r\n\r\n expandRadiusBySphere: function(sh) {\r\n if (sh.valid()) {\r\n if (this.valid()) {\r\n var r = vec3.distance(this._center, sh._center) + sh._radius;\r\n if (r > this._radius) {\r\n this._radius = r;\r\n }\r\n // else do nothing as vertex is within sphere.\r\n } else {\r\n vec3.copy(this._center, sh._center);\r\n this._radius = sh._radius;\r\n }\r\n }\r\n },\r\n\r\n expandByBoundingSphere: function(sh) {\r\n // ignore operation if incomming BoundingSphere is invalid.\r\n if (!sh.valid()) {\r\n return;\r\n }\r\n\r\n // This sphere is not set so use the inbound sphere\r\n if (!this.valid()) {\r\n this._center[0] = sh._center[0];\r\n this._center[1] = sh._center[1];\r\n this._center[2] = sh._center[2];\r\n this._radius = sh.radius();\r\n\r\n return;\r\n }\r\n\r\n // Calculate d == The distance between the sphere centers\r\n var d = vec3.distance(sh.center(), this.center());\r\n\r\n // New sphere is already inside this one\r\n if (d + sh.radius() <= this.radius()) {\r\n return;\r\n }\r\n\r\n // New sphere completely contains this one\r\n if (d + this.radius() <= sh.radius()) {\r\n this._center[0] = sh._center[0];\r\n this._center[1] = sh._center[1];\r\n this._center[2] = sh._center[2];\r\n this._radius = sh._radius;\r\n return;\r\n }\r\n\r\n // Build a new sphere that completely contains the other two:\r\n //\r\n // The center point lies halfway along the line between the furthest\r\n // points on the edges of the two spheres.\r\n //\r\n // Computing those two points is ugly - so we'll use similar triangles\r\n var newRadius = (this.radius() + d + sh.radius()) * 0.5;\r\n var ratio = (newRadius - this.radius()) / d;\r\n\r\n this._center[0] += (sh._center[0] - this._center[0]) * ratio;\r\n this._center[1] += (sh._center[1] - this._center[1]) * ratio;\r\n this._center[2] += (sh._center[2] - this._center[2]) * ratio;\r\n\r\n this._radius = newRadius;\r\n },\r\n contains: function(v) {\r\n if (!this.valid()) return false;\r\n return vec3.sqrDist(this.center(), v) <= this.radius2();\r\n },\r\n intersects: function(bs) {\r\n if (!this.valid() || !bs.valid()) return false;\r\n var r = this.radius() + bs.radius();\r\n return vec3.sqrDist(bs.center(), this.center()) <= r * r;\r\n },\r\n\r\n transformMat4: (function() {\r\n var scaleVec = vec3.create();\r\n return function(out, matrix) {\r\n if (!this.valid()) return out;\r\n\r\n if (out._center !== this._center) {\r\n vec3.copy(out._center, this._center);\r\n out._radius = this._radius;\r\n }\r\n var sphCenter = out._center;\r\n var sphRadius = out._radius;\r\n\r\n mat4.getSqrScale(scaleVec, matrix);\r\n var scale = Math.sqrt(Math.max(Math.max(scaleVec[0], scaleVec[1]), scaleVec[2]));\r\n sphRadius = sphRadius * scale;\r\n out._radius = sphRadius;\r\n vec3.transformMat4(sphCenter, sphCenter, matrix);\r\n\r\n return out;\r\n };\r\n })()\r\n },\r\n 'osg',\r\n 'BoundingSphere'\r\n);\r\n\r\nexport default BoundingSphere;","import notify from './notify';\r\nimport utils from './utils';\r\nimport GLObject from './GLObject';\r\nimport StateAttribute from './StateAttribute';\r\nimport Timer from './Timer';\r\nimport WebglCaps from './WebGLCaps';\r\n\r\n/**\r\n * FrameBufferObject manage fbo / rtt\r\n * @class FrameBufferObject\r\n */\r\nvar FrameBufferObject = function() {\r\n GLObject.call(this);\r\n StateAttribute.call(this);\r\n\r\n this._fbo = undefined;\r\n this._rbo = undefined;\r\n this._attachments = [];\r\n this._buffers = [];\r\n this._dirty = true;\r\n this._hasMRT = WebglCaps.instance().getWebGLExtension('WEBGL_draw_buffers');\r\n};\r\n\r\nFrameBufferObject.COLOR_ATTACHMENT0 = 0x8ce0;\r\nFrameBufferObject.DEPTH_ATTACHMENT = 0x8d00;\r\nFrameBufferObject.DEPTH_COMPONENT16 = 0x81a5;\r\n\r\n// static cache of glFrameBuffer flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nFrameBufferObject._sDeletedGLFrameBufferCache = new window.Map();\r\n\r\n// static method to delete FrameBuffers\r\nFrameBufferObject.deleteGLFrameBuffer = function(gl, fb) {\r\n if (!FrameBufferObject._sDeletedGLFrameBufferCache.has(gl))\r\n FrameBufferObject._sDeletedGLFrameBufferCache.set(gl, []);\r\n\r\n FrameBufferObject._sDeletedGLFrameBufferCache.get(gl).push(fb);\r\n};\r\n\r\n// static method to flush all the cached glFrameBuffers which need to be deleted in the GL context specified\r\nFrameBufferObject.flushDeletedGLFrameBuffers = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n\r\n if (!FrameBufferObject._sDeletedGLFrameBufferCache.has(gl)) return availableTime;\r\n var deleteList = FrameBufferObject._sDeletedGLFrameBufferCache.get(gl);\r\n if (deleteList.length === 0) return availableTime;\r\n\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteFramebuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nFrameBufferObject.flushAllDeletedGLFrameBuffers = function(gl) {\r\n if (!FrameBufferObject._sDeletedGLFrameBufferCache.has(gl)) return;\r\n var deleteList = FrameBufferObject._sDeletedGLFrameBufferCache.get(gl);\r\n if (deleteList.length === 0) return;\r\n var numBuffers = deleteList.length;\r\n for (var i = numBuffers - 1; i >= 0; i--) {\r\n gl.deleteFramebuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n};\r\n\r\n// static cache of glRenderBuffer flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nFrameBufferObject._sDeletedGLRenderBufferCache = new window.Map();\r\n\r\n// static method to delete RenderBuffers\r\nFrameBufferObject.deleteGLRenderBuffer = function(gl, fb) {\r\n if (!FrameBufferObject._sDeletedGLRenderBufferCache.has(gl))\r\n FrameBufferObject._sDeletedGLRenderBufferCache.set(gl, []);\r\n\r\n FrameBufferObject._sDeletedGLRenderBufferCache.get(gl).push(fb);\r\n};\r\n\r\n// static method to flush all the cached glRenderBuffers which need to be deleted in the GL context specified\r\nFrameBufferObject.flushDeletedGLRenderBuffers = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n\r\n if (!FrameBufferObject._sDeletedGLRenderBufferCache.has(gl)) return availableTime;\r\n\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var deleteList = FrameBufferObject._sDeletedGLRenderBufferCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n\r\n for (var i = numBuffers - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteRenderbuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nFrameBufferObject.flushAllDeletedGLRenderBuffers = function(gl) {\r\n if (!FrameBufferObject._sDeletedGLRenderBufferCache.has(gl)) return;\r\n\r\n var deleteList = FrameBufferObject._sDeletedGLRenderBufferCache.get(gl);\r\n var numBuffers = deleteList.length;\r\n\r\n for (var i = numBuffers - 1; i >= 0; i--) {\r\n gl.deleteRenderbuffer(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n};\r\n\r\nFrameBufferObject.onLostContext = function(gl) {\r\n if (!FrameBufferObject._sDeletedGLFrameBufferCache.has(gl)) return;\r\n\r\n var deleteList = FrameBufferObject._sDeletedGLFrameBufferCache.get(gl);\r\n deleteList.length = 0;\r\n\r\n if (!FrameBufferObject._sDeletedGLRenderBufferCache.has(gl)) return;\r\n\r\n deleteList = FrameBufferObject._sDeletedGLRenderBufferCache.get(gl);\r\n deleteList.length = 0;\r\n};\r\n\r\n/** @lends FrameBufferObject.prototype */\r\nutils.createPrototypeStateAttribute(\r\n FrameBufferObject,\r\n utils.objectInherit(\r\n GLObject.prototype,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'FrameBufferObject',\r\n\r\n cloneType: function() {\r\n return new FrameBufferObject();\r\n },\r\n\r\n invalidate: function() {\r\n if (this._rbo && this._attachments) {\r\n for (var i = 0, l = this._attachments.length; i < l; ++i) {\r\n var attachment = this._attachments[i];\r\n // shared renderbuffer object between camera\r\n // must still be set to null as it's webgl object\r\n // apply will reshare it when creating it.\r\n if (!attachment.texture) {\r\n attachment.renderBufferObject = undefined;\r\n }\r\n }\r\n this._rbo = undefined;\r\n }\r\n this._fbo = undefined;\r\n this._buffers.length = 0;\r\n this._dirty = true;\r\n },\r\n\r\n dirty: function() {\r\n this._buffers.length = 0;\r\n this._dirty = true;\r\n },\r\n\r\n isDirty: function() {\r\n return this._dirty;\r\n },\r\n\r\n setAttachment: function(attachment) {\r\n this._attachments.push(attachment);\r\n },\r\n\r\n getAttachment: function(attachmentType) {\r\n if (!this._attachments) return;\r\n for (var i = 0, l = this._attachments.length; i < l; ++i) {\r\n var attachment = this._attachments[i];\r\n // shared renderbuffer object between camera\r\n // must still be set to null as it's webgl object\r\n // apply will reshare it when creating it.\r\n if (attachment.attachment === attachmentType) {\r\n return attachment;\r\n }\r\n }\r\n return;\r\n },\r\n releaseGLObjects: function() {\r\n if (this._fbo !== undefined && this._gl !== undefined) {\r\n FrameBufferObject.deleteGLFrameBuffer(this._gl, this._fbo);\r\n }\r\n this._fbo = undefined;\r\n\r\n if (this._rbo !== undefined && this._gl !== undefined) {\r\n FrameBufferObject.deleteGLRenderBuffer(this._gl, this._rbo);\r\n }\r\n this.invalidate();\r\n },\r\n\r\n _reportFrameBufferError: function(code) {\r\n switch (code) {\r\n case 0x8cd6:\r\n notify.debug('FRAMEBUFFER_INCOMPLETE_ATTACHMENT');\r\n break;\r\n case 0x8cd7:\r\n notify.debug('FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT');\r\n break;\r\n case 0x8cd9:\r\n notify.debug('FRAMEBUFFER_INCOMPLETE_DIMENSIONS');\r\n break;\r\n case 0x8cdd:\r\n notify.debug('FRAMEBUFFER_UNSUPPORTED');\r\n break;\r\n default:\r\n notify.debug('FRAMEBUFFER unknown error ' + code.toString(16));\r\n }\r\n },\r\n\r\n reset: function() {\r\n this.releaseGLObjects();\r\n this._attachments = [];\r\n },\r\n\r\n getFrameBufferObject: function() {\r\n return this._fbo;\r\n },\r\n\r\n getRenderBufferObject: function() {\r\n return this._rbo;\r\n },\r\n\r\n createFrameBufferObject: function(state) {\r\n this.setGraphicContext(state.getGraphicContext());\r\n this._fbo = this._gl.createFramebuffer();\r\n },\r\n\r\n createRenderBuffer: function(format, width, height) {\r\n var gl = this._gl;\r\n var renderBuffer = gl.createRenderbuffer();\r\n gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);\r\n gl.renderbufferStorage(gl.RENDERBUFFER, format, width, height);\r\n\r\n return renderBuffer;\r\n },\r\n\r\n framebufferRenderBuffer: function(attachment, renderBuffer) {\r\n var gl = this._gl;\r\n gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);\r\n gl.framebufferRenderbuffer(\r\n gl.FRAMEBUFFER,\r\n attachment,\r\n gl.RENDERBUFFER,\r\n renderBuffer\r\n );\r\n\r\n /* develblock:start */\r\n // only visible with webgl-insector enabled\r\n if (gl.rawgl !== undefined) {\r\n notify.log('FBO: renderBuffer: ' + this._fbo.trackedObject.defaultName);\r\n }\r\n /* develblock:end */\r\n },\r\n\r\n framebufferTexture2D: function(state, attachment, textureTarget, texture) {\r\n var gl = this._gl;\r\n\r\n // apply on unit 1 to init it\r\n // make sure we do bind it whatever state stack\r\n // texture is cached\r\n state.applyTextureAttribute(1, texture);\r\n\r\n if (texture.isDirty() || !texture.getTextureObject()) {\r\n // image wasn't ready, texture not allocated due to lack of gpu MEM\r\n return false;\r\n }\r\n\r\n // gl2 vs gl1\r\n var target = gl.DRAW_FRAMEBUFFER || gl.FRAMEBUFFER;\r\n gl.framebufferTexture2D(\r\n target,\r\n attachment,\r\n textureTarget,\r\n texture.getTextureObject().id(),\r\n 0\r\n );\r\n\r\n /* develblock:start */\r\n // only visible with webgl-insector enabled\r\n // allow trace debug (fb<->texture link)\r\n if (gl.rawgl !== undefined) {\r\n notify.log(\r\n 'FBO: texture: ' +\r\n texture.getName() +\r\n ' : ' +\r\n texture.getTextureObject().id().trackedObject.defaultName +\r\n ' fbo: ' +\r\n this._fbo.trackedObject.defaultName\r\n );\r\n }\r\n /* develblock:end */\r\n\r\n return true;\r\n },\r\n\r\n bindFrameBufferObject: function() {\r\n var gl = this._gl;\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);\r\n },\r\n\r\n checkStatus: function() {\r\n var gl = this._gl;\r\n var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\r\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\r\n this._reportFrameBufferError(status);\r\n }\r\n },\r\n\r\n _checkAllowedSize: function(w, h) {\r\n var maxSize = WebglCaps.instance().getWebGLParameter('MAX_RENDERBUFFER_SIZE');\r\n\r\n if (w === 0 || h === 0 || h > maxSize || w > maxSize) {\r\n notify.error(\r\n 'width (' +\r\n w +\r\n ') or height (' +\r\n w +\r\n ') makes frame buffer not bindable. Max RenderBuffer is \"' +\r\n maxSize +\r\n '\"'\r\n );\r\n return false;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n apply: function(state) {\r\n if (!this._gl) this.setGraphicContext(state.getGraphicContext());\r\n var gl = this._gl;\r\n\r\n var attachments = this._attachments;\r\n\r\n // ?\r\n var nbAttachments = attachments.length;\r\n if (nbAttachments === 0 && !this._fbo) {\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n return;\r\n }\r\n\r\n var i = 0;\r\n\r\n // each frame\r\n if (!this.isDirty()) {\r\n for (i = 0; i < nbAttachments; ++i) {\r\n var tex = attachments[i].texture;\r\n if (tex && tex.isDirty()) state.applyTextureAttribute(1, tex);\r\n }\r\n\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);\r\n if (notify.reportWebGLError === true) this.checkStatus();\r\n return;\r\n }\r\n\r\n // if the fbo is created manually, we want to just bind it\r\n if (!this._fbo) this.createFrameBufferObject(state);\r\n\r\n this.bindFrameBufferObject();\r\n\r\n // Check extDrawBuffers extension\r\n var bufs = this._hasMRT ? this._buffers : undefined;\r\n var hasRenderBuffer = false;\r\n\r\n for (i = 0; i < nbAttachments; ++i) {\r\n var attachment = attachments[i];\r\n\r\n // render buffer\r\n if (!attachment.texture) {\r\n if (!this._checkAllowedSize(attachment.width, attachment.height)) {\r\n this.releaseGLObjects();\r\n return;\r\n }\r\n if (attachment.renderBufferObject) {\r\n // shared renderbuffer object between camera\r\n // ie: early-z\r\n this._rbo = attachment.renderBufferObject;\r\n } else {\r\n this._rbo = this.createRenderBuffer(\r\n attachment.format,\r\n attachment.width,\r\n attachment.height\r\n );\r\n // necessary for shared attachment between camera\r\n attachment.renderBufferObject = this._rbo;\r\n }\r\n this.framebufferRenderBuffer(attachment.attachment, this._rbo);\r\n hasRenderBuffer = true;\r\n } else {\r\n // use texture\r\n var texture = attachment.texture;\r\n\r\n if (!this._checkAllowedSize(texture.getWidth(), texture.getHeight())) {\r\n this.releaseGLObjects();\r\n return;\r\n }\r\n\r\n // Not sure is needed to check the attachment.attachment\r\n if (\r\n this._hasMRT &&\r\n attachment.attachment >= gl.COLOR_ATTACHMENT0 &&\r\n attachment.attachment <= gl.COLOR_ATTACHMENT15 &&\r\n bufs.indexOf(attachment.attachment) === -1\r\n ) {\r\n bufs.push(attachment.attachment);\r\n }\r\n\r\n if (!this.framebufferTexture2D(\r\n state,\r\n attachment.attachment,\r\n attachment.textureTarget,\r\n texture\r\n )) {\r\n this.releaseGLObjects();\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (bufs && bufs.length > 0) {\r\n gl.drawBuffers(bufs);\r\n }\r\n\r\n this.checkStatus();\r\n\r\n // set it to null only if used renderbuffer\r\n if (hasRenderBuffer) gl.bindRenderbuffer(gl.RENDERBUFFER, null);\r\n\r\n this._dirty = false;\r\n }\r\n })\r\n ),\r\n 'osg',\r\n 'FrameBufferObject'\r\n);\r\n\r\nexport default FrameBufferObject;","import utils from '../osg/utils';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport AnimationUpdateCallback from './AnimationUpdateCallback';\r\n\r\n/**\r\n * UpdateMatrixTransform\r\n */\r\nvar UpdateMatrixTransform = function() {\r\n AnimationUpdateCallback.call(this);\r\n\r\n // maybe could have a more generic name and used by all AnimationUpdateCallback\r\n this._stackedTransforms = [];\r\n\r\n this._matrix = mat4.create();\r\n\r\n this._dirty = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n UpdateMatrixTransform,\r\n utils.objectInherit(AnimationUpdateCallback.prototype, {\r\n getStackedTransforms: function() {\r\n return this._stackedTransforms;\r\n },\r\n\r\n setMatrix: function(matrix) {\r\n mat4.copy(this._matrix, matrix);\r\n this._dirty = true;\r\n },\r\n\r\n getMatrix: function() {\r\n return this._matrix;\r\n },\r\n\r\n computeChannels: function() {\r\n this._dirty = true;\r\n var matrix = this._matrix;\r\n mat4.identity(matrix);\r\n var transforms = this._stackedTransforms;\r\n\r\n for (var i = 0, l = transforms.length; i < l; i++) {\r\n var transform = transforms[i];\r\n transform.applyToMatrix(matrix);\r\n }\r\n },\r\n\r\n reset: function() {\r\n var stacked = this._stackedTransforms;\r\n for (var i = 0, nbStacked = stacked.length; i < nbStacked; i++) {\r\n stacked[i].resetToDefaultValue();\r\n }\r\n\r\n // computeChannels is not mandatory here as the following frame will call\r\n // this function anyway\r\n this.computeChannels();\r\n },\r\n\r\n update: function(node /*, nv */) {\r\n mat4.copy(node.getMatrix(), this._matrix);\r\n if (this._dirty) {\r\n node.dirtyBound();\r\n this._dirty = false;\r\n }\r\n return true;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'UpdateMatrixTransform'\r\n);\r\n\r\nexport default UpdateMatrixTransform;\r\n","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\nvar Scissor = function(x, y, w, h) {\r\n StateAttribute.call(this);\r\n\r\n this._x = x !== undefined ? x : -1;\r\n this._y = y !== undefined ? y : -1;\r\n this._width = w !== undefined ? w : -1;\r\n\r\n this._height = h !== undefined ? h : -1;\r\n};\r\n\r\nutils.createPrototypeStateAttribute(\r\n Scissor,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Scissor',\r\n\r\n cloneType: function() {\r\n return new Scissor();\r\n },\r\n\r\n setScissor: function(x, y, width, height) {\r\n this._x = x;\r\n this._y = y;\r\n this._width = width;\r\n this._height = height;\r\n },\r\n\r\n x: function() {\r\n return this._x;\r\n },\r\n\r\n y: function() {\r\n return this._y;\r\n },\r\n\r\n width: function() {\r\n return this._width;\r\n },\r\n\r\n height: function() {\r\n return this._height;\r\n },\r\n\r\n apply: function(state) {\r\n state.applyScissor(this);\r\n }\r\n }),\r\n 'osg',\r\n 'Scissor'\r\n);\r\n\r\nexport default Scissor;","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\n/**\r\n * Manage Blending mode\r\n * @class BlendFunc\r\n */\r\nvar BlendFunc = function(sourceRGB, destinationRGB, sourceAlpha, destinationAlpha) {\r\n StateAttribute.call(this);\r\n this._sourceFactor = BlendFunc.DISABLE;\r\n this._destinationFactor = BlendFunc.DISABLE;\r\n this._sourceFactorAlpha = this._sourceFactor;\r\n this._destinationFactorAlpha = this._destinationFactor;\r\n this._separate = false;\r\n if (sourceRGB !== undefined) {\r\n this.setSource(sourceRGB);\r\n }\r\n if (destinationRGB !== undefined) {\r\n this.setDestination(destinationRGB);\r\n }\r\n\r\n if (sourceAlpha !== undefined) {\r\n this.setSourceAlpha(sourceAlpha);\r\n }\r\n if (destinationAlpha !== undefined) {\r\n this.setDestinationAlpha(destinationAlpha);\r\n }\r\n};\r\n\r\nBlendFunc.DISABLE = -1;\r\nBlendFunc.ZERO = 0;\r\nBlendFunc.ONE = 1;\r\nBlendFunc.SRC_COLOR = 0x0300;\r\nBlendFunc.ONE_MINUS_SRC_COLOR = 0x0301;\r\nBlendFunc.SRC_ALPHA = 0x0302;\r\nBlendFunc.ONE_MINUS_SRC_ALPHA = 0x0303;\r\nBlendFunc.DST_ALPHA = 0x0304;\r\nBlendFunc.ONE_MINUS_DST_ALPHA = 0x0305;\r\nBlendFunc.DST_COLOR = 0x0306;\r\nBlendFunc.ONE_MINUS_DST_COLOR = 0x0307;\r\nBlendFunc.SRC_ALPHA_SATURATE = 0x0308;\r\n\r\n/* Separate Blend Functions */\r\nBlendFunc.BLEND_DST_RGB = 0x80c8;\r\nBlendFunc.BLEND_SRC_RGB = 0x80c9;\r\nBlendFunc.BLEND_DST_ALPHA = 0x80ca;\r\nBlendFunc.BLEND_SRC_ALPHA = 0x80cb;\r\nBlendFunc.CONSTANT_COLOR = 0x8001;\r\nBlendFunc.ONE_MINUS_CONSTANT_COLOR = 0x8002;\r\nBlendFunc.CONSTANT_ALPHA = 0x8003;\r\nBlendFunc.ONE_MINUS_CONSTANT_ALPHA = 0x8004;\r\nBlendFunc.BLEND_COLOR = 0x8005;\r\n\r\n/** @lends BlendFunc.prototype */\r\nutils.createPrototypeStateAttribute(\r\n BlendFunc,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n /**\r\n * StateAttribute type of BlendFunc\r\n * @type String\r\n */\r\n attributeType: 'BlendFunc',\r\n /**\r\n * Create an instance of this StateAttribute\r\n */\r\n cloneType: function() /**BlendFunc*/ {\r\n return new BlendFunc();\r\n },\r\n setSource: function(f) {\r\n this.setSourceRGB(f);\r\n this.setSourceAlpha(f);\r\n },\r\n getSource: function() {\r\n return this._sourceFactor;\r\n },\r\n setDestination: function(f) {\r\n this.setDestinationRGB(f);\r\n this.setDestinationAlpha(f);\r\n },\r\n getDestination: function() {\r\n return this._destinationFactor;\r\n },\r\n getSeparate: function() {\r\n return this._separate;\r\n },\r\n checkSeparate: function() {\r\n return (\r\n this._sourceFactor !== this._sourceFactorAlpha ||\r\n this._destinationFactor !== this._destinationFactorAlpha\r\n );\r\n },\r\n setSourceRGB: function(f) {\r\n if (typeof f === 'string') {\r\n this._sourceFactor = BlendFunc[f];\r\n } else {\r\n this._sourceFactor = f;\r\n }\r\n this._separate = this.checkSeparate();\r\n },\r\n getSourceRGB: function() {\r\n return this._sourceFactor;\r\n },\r\n setSourceAlpha: function(f) {\r\n if (typeof f === 'string') {\r\n this._sourceFactorAlpha = BlendFunc[f];\r\n } else {\r\n this._sourceFactorAlpha = f;\r\n }\r\n this._separate = this.checkSeparate();\r\n },\r\n getSourceAlpha: function() {\r\n return this._sourceFactorAlpha;\r\n },\r\n setDestinationRGB: function(f) {\r\n if (typeof f === 'string') {\r\n this._destinationFactor = BlendFunc[f];\r\n } else {\r\n this._destinationFactor = f;\r\n }\r\n this._separate = this.checkSeparate();\r\n },\r\n getDestinationRGB: function() {\r\n return this._destinationFactor;\r\n },\r\n setDestinationAlpha: function(f) {\r\n if (typeof f === 'string') {\r\n this._destinationFactorAlpha = BlendFunc[f];\r\n } else {\r\n this._destinationFactorAlpha = f;\r\n }\r\n this._separate = this.checkSeparate();\r\n },\r\n getDestinationAlpha: function() {\r\n return this._destinationFactorAlpha;\r\n },\r\n\r\n /**\r\n * Apply the mode, must be called in the draw traversal\r\n * @param state\r\n */\r\n apply: function(state) {\r\n state.applyBlendFunc(this);\r\n }\r\n }),\r\n 'osg',\r\n 'BlendFunc'\r\n);\r\n\r\nexport default BlendFunc;","import { mat4 } from '../osg/glMatrix';\r\nimport { quat } from '../osg/glMatrix';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport channelType from './channelType';\r\n\r\nvar target = {};\r\ntarget.InvalidTargetID = -1;\r\n\r\n// defaultValue is used when no channels affect the value\r\nvar createTarget = function(type, value, defaultValue) {\r\n return {\r\n type: type,\r\n id: target.InvalidTargetID, // -1 means no id assigned yet\r\n channels: [],\r\n value: value,\r\n defaultValue: defaultValue\r\n };\r\n};\r\n\r\nvar createQuatTarget = function(defaultValue) {\r\n return createTarget(\r\n channelType.Quat,\r\n quat.copy(quat.create(), defaultValue),\r\n quat.copy(quat.create(), defaultValue)\r\n );\r\n};\r\n\r\nvar createMatrixTarget = function(defaultValue) {\r\n return createTarget(\r\n channelType.Matrix,\r\n mat4.copy(mat4.create(), defaultValue),\r\n mat4.copy(mat4.create(), defaultValue)\r\n );\r\n};\r\n\r\nvar createVec3Target = function(defaultValue) {\r\n return createTarget(\r\n channelType.Vec3,\r\n vec3.copy(vec3.create(), defaultValue),\r\n vec3.copy(vec3.create(), defaultValue)\r\n );\r\n};\r\n\r\nvar createFloatTarget = function(defaultValue) {\r\n return createTarget(channelType.Float, defaultValue, defaultValue);\r\n};\r\n\r\ntarget.createQuatTarget = createQuatTarget;\r\ntarget.createVec3Target = createVec3Target;\r\ntarget.createFloatTarget = createFloatTarget;\r\ntarget.createMatrixTarget = createMatrixTarget;\r\n\r\nexport default target;\r\n","import utils from './utils';\r\nimport StateAttribute from './StateAttribute';\r\n\r\n/**\r\n * Manage CullFace attribute\r\n * @class CullFace\r\n */\r\nvar CullFace = function(mode) {\r\n StateAttribute.call(this);\r\n this.setMode(mode !== undefined ? mode : CullFace.BACK);\r\n};\r\n\r\nCullFace.DISABLE = 0x0;\r\nCullFace.FRONT = 0x0404;\r\nCullFace.BACK = 0x0405;\r\nCullFace.FRONT_AND_BACK = 0x0408;\r\n\r\n/** @lends CullFace.prototype */\r\nutils.createPrototypeStateAttribute(\r\n CullFace,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'CullFace',\r\n\r\n cloneType: function() {\r\n return new CullFace();\r\n },\r\n\r\n setMode: function(mode) {\r\n var value = mode;\r\n if (typeof value === 'string') value = CullFace[value];\r\n this._mode = value;\r\n },\r\n\r\n getMode: function() {\r\n return this._mode;\r\n },\r\n\r\n apply: function(state) {\r\n state.applyCullFace(this);\r\n }\r\n }),\r\n 'osg',\r\n 'CullFace'\r\n);\r\n\r\nexport default CullFace;","import utils from '../osg/utils';\r\nimport Object from '../osg/Object';\r\nimport DatabasePager from '../osgDB/DatabasePager';\r\n\r\nvar Scene = function() {\r\n Object.call(this);\r\n this._databasePager = new DatabasePager();\r\n this._sceneData = undefined;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n Scene,\r\n utils.objectInherit(Object.prototype, {\r\n getSceneData: function() {\r\n return this._sceneData;\r\n },\r\n\r\n setSceneData: function(node) {\r\n this._sceneData = node;\r\n },\r\n\r\n setDatabasePager: function(dbpager) {\r\n this._databasePager = dbpager;\r\n },\r\n\r\n getDatabasePager: function() {\r\n return this._databasePager;\r\n },\r\n\r\n // database pager are not implemented yet here\r\n updateSceneGraph: function(updateVisitor) {\r\n if (this._databasePager)\r\n this._databasePager.updateSceneGraph(updateVisitor.getFrameStamp());\r\n if (this._sceneData) this._sceneData.accept(updateVisitor);\r\n }\r\n }),\r\n 'osgViewer',\r\n 'Scene'\r\n);\r\n\r\nexport default Scene;\r\n","import Timer from './Timer';\r\nimport notify from './notify';\r\n\r\nvar utils = {};\r\n\r\nutils.extend = function() {\r\n // Save a reference to some core methods\r\n var toString = window.Object.prototype.toString;\r\n var hasOwnPropertyFunc = window.Object.prototype.hasOwnProperty;\r\n\r\n var isFunction = function(obj) {\r\n return toString.call(obj) === '[object Function]';\r\n };\r\n var isArray = utils.isArray;\r\n var isPlainObject = function(obj) {\r\n // Must be an Object.\r\n // Because of IE, we also have to check the presence of the constructor property.\r\n // Make sure that DOM nodes and window objects don't pass through, as well\r\n if (!obj || toString.call(obj) !== '[object Object]' || obj.nodeType || obj.setInterval) {\r\n return false;\r\n }\r\n\r\n // Not own constructor property must be Object\r\n if (\r\n obj.constructor &&\r\n !hasOwnPropertyFunc.call(obj, 'constructor') &&\r\n !hasOwnPropertyFunc.call(obj.constructor.prototype, 'isPrototypeOf')\r\n ) {\r\n return false;\r\n }\r\n\r\n // Own properties are enumerated firstly, so to speed up,\r\n // if last one is own, then all properties are own.\r\n\r\n var key;\r\n for (key in obj) {}\r\n\r\n return key === undefined || hasOwnPropertyFunc.call(obj, key);\r\n };\r\n\r\n // copy reference to target object\r\n var target = arguments[0] || {},\r\n i = 1,\r\n length = arguments.length,\r\n deep = false,\r\n options,\r\n name,\r\n src,\r\n copy;\r\n\r\n // Handle a deep copy situation\r\n if (typeof target === 'boolean') {\r\n deep = target;\r\n target = arguments[1] || {};\r\n // skip the boolean and the target\r\n i = 2;\r\n }\r\n\r\n // Handle case when target is a string or something (possible in deep copy)\r\n if (typeof target !== 'object' && !isFunction(target)) {\r\n target = {};\r\n }\r\n\r\n // extend jQuery itself if only one argument is passed\r\n if (length === i) {\r\n target = this;\r\n --i;\r\n }\r\n\r\n for (; i < length; i++) {\r\n // Only deal with non-null/undefined values\r\n if ((options = arguments[i]) !== null) {\r\n // Extend the base object\r\n for (name in options) {\r\n src = target[name];\r\n copy = options[name];\r\n\r\n // Prevent never-ending loop\r\n if (target === copy) {\r\n continue;\r\n }\r\n\r\n // Recurse if we're merging object literal values or arrays\r\n if (deep && copy && (isPlainObject(copy) || isArray(copy))) {\r\n var clone =\r\n src && (isPlainObject(src) || isArray(src)) ? src : isArray(copy) ? [] : {};\r\n\r\n // Never move original objects, clone them\r\n target[name] = utils.extend(deep, clone, copy);\r\n\r\n // Don't bring in undefined values\r\n } else if (copy !== undefined) {\r\n target[name] = copy;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Return the modified object\r\n return target;\r\n};\r\n\r\nutils.objectInherit = function(base /*, extras*/ ) {\r\n function F() {}\r\n F.prototype = base;\r\n var obj = new F();\r\n\r\n // let augment object with multiple arguement\r\n for (var i = 1; i < arguments.length; i++) {\r\n utils.objectMix(obj, arguments[i], false);\r\n }\r\n return obj;\r\n};\r\n\r\nutils.objectMix = function(obj, properties, test) {\r\n for (var key in properties) {\r\n if (!(test && obj[key])) {\r\n obj[key] = properties[key];\r\n }\r\n }\r\n return obj;\r\n};\r\n\r\nutils.objectType = {};\r\nutils.objectType.type = 0;\r\n\r\nutils.arrayDense = function(index, array, createDefaultType) {\r\n var length = array.length;\r\n if (index >= length) {\r\n for (var i = length; i <= index; i++) {\r\n array.push(createDefaultType ? createDefaultType() : null);\r\n }\r\n }\r\n};\r\n\r\nutils.objectLibraryClass = function(object, libName, className) {\r\n object.className = function() {\r\n return className;\r\n };\r\n object.libraryName = function() {\r\n return libName;\r\n };\r\n var libraryClassName = libName + '::' + className;\r\n object.libraryClassName = function() {\r\n return libraryClassName;\r\n };\r\n\r\n return object;\r\n};\r\n\r\nutils.setTypeID = function(classObject) {\r\n var className = classObject.prototype.libraryClassName();\r\n var typeID = utils.generateId(utils.objectType, className);\r\n var getTypeID = function() {\r\n return typeID;\r\n };\r\n classObject.typeID = classObject.prototype.typeID = typeID;\r\n classObject.getTypeID = classObject.prototype.getTypeID = getTypeID;\r\n};\r\n\r\nutils.createPrototypeObject = function(Constructor, prototype, libraryName, className) {\r\n // we need to create an instance of {} if prototype is already used in an object\r\n // else we will override typeID ClassName...\r\n if (prototype.hasOwnProperty('getTypeID')) {\r\n prototype = utils.objectInherit(prototype, {});\r\n }\r\n\r\n if (Constructor.prototype !== prototype) {\r\n Constructor.prototype = prototype;\r\n }\r\n prototype.constructor = Constructor;\r\n\r\n // if the user dont provide library name or class name this class will not have typeID\r\n // and will inherit the typeID from it's parent class if it has one\r\n // so all call to getTypeID will be affected, it's mostly not a probablem for internal class\r\n // but for Node and StateAttribute you have to be aware\r\n if (!libraryName || !className) return;\r\n\r\n utils.objectLibraryClass(prototype, libraryName, className);\r\n utils.setTypeID(Constructor);\r\n};\r\n\r\n// ============== Node ID =================================\r\nutils.generateId = function(typeMap, className) {\r\n if (typeMap[className] !== undefined) {\r\n notify.error(className + ' is already defined, change class name or library name');\r\n return -1;\r\n }\r\n\r\n var index = typeMap.type;\r\n typeMap[index] = className;\r\n typeMap[className] = index;\r\n typeMap.type += 1;\r\n return index;\r\n};\r\n\r\nutils.objectNodeType = {};\r\nutils.objectNodeType.type = 0;\r\n\r\nutils.setNodeTypeID = function(classObject) {\r\n var className = classObject.prototype.libraryClassName();\r\n var typeID = utils.generateId(utils.objectNodeType, className);\r\n var getTypeID = function() {\r\n return typeID;\r\n };\r\n classObject.nodeTypeID = classObject.prototype.nodeTypeID = typeID;\r\n classObject.getNodeTypeID = classObject.prototype.getNodeTypeID = getTypeID;\r\n};\r\n\r\nutils.createPrototypeNode = function(Constructor, prototype, libraryName, className) {\r\n var cullVisitorHelper = require('./cullVisitorHelper').default;\r\n var parentNodeTypeID = prototype.nodeTypeID;\r\n utils.createPrototypeObject(Constructor, prototype, libraryName, className);\r\n\r\n // check the comment in function in utils.createPrototypeObject\r\n if (!libraryName || !className) return;\r\n\r\n utils.setNodeTypeID(Constructor);\r\n var nodeTypeId = Constructor.nodeTypeID;\r\n utils.arrayDense(nodeTypeId, cullVisitorHelper.applyFunctionArray);\r\n cullVisitorHelper.registerApplyFunction(\r\n nodeTypeId,\r\n cullVisitorHelper.getApplyFunction(parentNodeTypeID)\r\n );\r\n};\r\n\r\n// ===============================================\r\n\r\nvar typeMemberIndex = 0;\r\nvar textureTypeMemberIndex = 0;\r\nvar stateAttributeTypeMember = {};\r\nvar textureStateAttributeTypeMember = {};\r\nvar attributeTypeIndex = 0;\r\nvar stateAttributeType = {};\r\n\r\nutils.getStateAttributeTypeNameToTypeId = function() {\r\n return stateAttributeType;\r\n};\r\n\r\nutils.createPrototypeStateAttribute = function(Constructor, prototype, libraryName, className) {\r\n utils.createPrototypeObject(Constructor, prototype, libraryName, className);\r\n var attributeId = utils.getOrCreateStateAttributeTypeId(Constructor);\r\n Constructor.prototype.attributeTypeId = attributeId;\r\n};\r\n\r\nutils.getMaxStateAttributeTypeID = function() {\r\n return attributeTypeIndex;\r\n};\r\n\r\nutils.getOrCreateStateAttributeTypeId = function(Constructor) {\r\n var attributeTypeName = Constructor.prototype.getType();\r\n\r\n if (stateAttributeType[attributeTypeName]) return stateAttributeType[attributeTypeName];\r\n\r\n var typeId = attributeTypeIndex++;\r\n stateAttributeType[attributeTypeName] = typeId;\r\n return typeId;\r\n};\r\n\r\nutils.getOrCreateStateAttributeTypeMemberIndex = function(attribute) {\r\n if (attribute._attributeTypeIndex !== undefined) return attribute._attributeTypeIndex;\r\n var typeMember = attribute.getTypeMember();\r\n attribute._attributeTypeIndex = utils.getOrCreateStateAttributeTypeMemberIndexFromName(\r\n typeMember\r\n );\r\n return attribute._attributeTypeIndex;\r\n};\r\n\r\nutils.getOrCreateStateAttributeTypeMemberIndexFromName = function(typeMemberName) {\r\n var type = stateAttributeTypeMember[typeMemberName];\r\n if (type !== undefined) return type;\r\n\r\n type = typeMemberIndex++;\r\n stateAttributeTypeMember[typeMemberName] = type;\r\n return type;\r\n};\r\n\r\nutils.getOrCreateTextureStateAttributeTypeMemberIndex = function(attribute) {\r\n if (attribute._attributeTypeIndex !== undefined) return attribute._attributeTypeIndex;\r\n var typeMember = attribute.getTypeMember();\r\n attribute._attributeTypeIndex = utils.getOrCreateTextureStateAttributeTypeMemberIndexFromName(\r\n typeMember\r\n );\r\n return attribute._attributeTypeIndex;\r\n};\r\n\r\nutils.getOrCreateTextureStateAttributeTypeMemberIndexFromName = function(typeMemberName) {\r\n var type = textureStateAttributeTypeMember[typeMemberName];\r\n if (type !== undefined) return type;\r\n\r\n type = textureTypeMemberIndex++;\r\n textureStateAttributeTypeMember[typeMemberName] = type;\r\n return type;\r\n};\r\n\r\nutils.getIdFromTypeMember = function(typeMember) {\r\n return stateAttributeTypeMember[typeMember];\r\n};\r\n\r\nutils.getTextureIdFromTypeMember = function(typeMember) {\r\n return textureStateAttributeTypeMember[typeMember];\r\n};\r\n\r\nutils.Int8Array = window.Int8Array;\r\nutils.Uint8Array = window.Uint8Array;\r\nutils.Uint8ClampedArray = window.Uint8ClampedArray;\r\nutils.Int16Array = window.Int16Array;\r\nutils.Uint16Array = window.Uint16Array;\r\nutils.Int32Array = window.Int32Array;\r\nutils.Uint32Array = window.Uint32Array;\r\nutils.Float32Array = window.Float32Array;\r\nutils.Float64Array = window.Float64Array;\r\n\r\nvar times = {};\r\nvar registeredTimers = {};\r\n// we bind the function to notify.console once and for all to avoid costly apply function\r\n\r\nutils.logTime = (\r\n notify.console.time ||\r\n function(name) {\r\n times[name] = Timer.instance().tick();\r\n }\r\n).bind(notify.console);\r\n\r\nutils.logTimeEnd = (\r\n notify.console.timeEnd ||\r\n function(name) {\r\n if (times[name] === undefined) return;\r\n\r\n var duration = Timer.instance().deltaM(times[name], Timer.instance().tick());\r\n\r\n notify.log(name + ': ' + duration + 'ms');\r\n times[name] = undefined;\r\n }\r\n).bind(notify.console);\r\n\r\nutils.time = function(name, logLevel) {\r\n var level = logLevel;\r\n if (level === undefined) level = notify.NOTICE;\r\n if (level > notify.getNotifyLevel()) return;\r\n registeredTimers[name] = 1;\r\n utils.logTime(name);\r\n};\r\n\r\nutils.timeEnd = function(name) {\r\n if (registeredTimers[name] === undefined) return;\r\n utils.logTimeEnd(name);\r\n};\r\n\r\nutils.profile = (notify.console.profile || function() {}).bind(notify.console);\r\nutils.profileEnd = (notify.console.profileEnd || function() {}).bind(notify.console);\r\n\r\nutils.arrayUniq = function(a) {\r\n var len = a.length;\r\n var seen = {};\r\n var out = [];\r\n var j = 0;\r\n for (var i = 0; i < len; i++) {\r\n var item = a[i];\r\n if (seen[item] !== 1) {\r\n seen[item] = 1;\r\n out[j++] = item;\r\n }\r\n }\r\n return out;\r\n};\r\n\r\n// mostly used as an osgDB helper to issue a warning and reject a promise\r\nutils.rejectObject = function(msg, jsonObj) {\r\n if (jsonObj) msg = 'Invalid json ' + msg + ' ' + Object.keys(jsonObj);\r\n notify.warn(msg); // useful for line debugging\r\n return P.reject(msg); // reject with a message to avoid \"undefined\" rejection\r\n};\r\n\r\n\r\nutils.setStateAttributeConfig = function(compilerClass, config) {\r\n compilerClass.stateAttributeConfig = config;\r\n\r\n config.attribute.forEach(utils.getOrCreateStateAttributeTypeMemberIndexFromName);\r\n config.textureAttribute.forEach(utils.getOrCreateTextureStateAttributeTypeMemberIndexFromName);\r\n\r\n compilerClass.validAttributeTypeMember = config.attribute;\r\n compilerClass.validTextureAttributeTypeMember = config.textureAttribute;\r\n}\r\n\r\n\r\nexport default utils;","module.exports = __webpack_public_path__ + \"img/grid.89ba7a31.png\";","import BoundingBox from './BoundingBox';\r\nimport Geometry from './Geometry';\r\nimport { mat4 } from './glMatrix';\r\nimport Transform from './Transform';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport utils from './utils';\r\nimport PooledArray from './PooledArray';\r\nimport PooledResource from './PooledResource';\r\n\r\nvar ComputeBoundsVisitor = function(traversalMode) {\r\n NodeVisitor.call(this, traversalMode);\r\n\r\n // keep a matrix in memory to avoid to create matrix\r\n this._pooledMatrix = new PooledResource(mat4.create);\r\n\r\n // Matrix stack along path traversal\r\n this._matrixStack = new PooledArray();\r\n this._matrixStack.push(mat4.IDENTITY);\r\n\r\n this._bb = new BoundingBox();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ComputeBoundsVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n reset: function() {\r\n this._pooledMatrix.reset();\r\n this._matrixStack.reset();\r\n this._matrixStack.push(mat4.IDENTITY);\r\n this._bb.init();\r\n },\r\n\r\n getBoundingBox: function() {\r\n return this._bb;\r\n },\r\n\r\n // not implemented\r\n //void getPolytope(osg::Polytope& polytope, float margin=0.1) const;\r\n //void getBase(osg::Polytope& polytope, float margin=0.1) const;\r\n\r\n //applyDrawable: function ( drawable ) {},\r\n\r\n applyTransform: function(transform) {\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n mat4.copy(matrix, this._matrixStack.back());\r\n transform.computeLocalToWorldMatrix(matrix, this);\r\n this.pushMatrix(matrix);\r\n this.traverse(transform);\r\n this.popMatrix();\r\n },\r\n\r\n apply: function(node) {\r\n if (node instanceof Transform) {\r\n this.applyTransform(node);\r\n return;\r\n } else if (node instanceof Geometry) {\r\n this.applyBoundingBox(node.getBoundingBox());\r\n return;\r\n }\r\n\r\n this.traverse(node);\r\n },\r\n\r\n pushMatrix: function(matrix) {\r\n this._matrixStack.push(matrix);\r\n },\r\n\r\n popMatrix: function() {\r\n this._matrixStack.pop();\r\n },\r\n\r\n applyBoundingBox: (function() {\r\n var bbOut = new BoundingBox();\r\n\r\n return function(bbox) {\r\n if (bbox.valid()) {\r\n bbox.transformMat4(bbOut, this._matrixStack.back());\r\n this._bb.expandByBoundingBox(bbOut);\r\n }\r\n };\r\n })(),\r\n\r\n getMatrixStack: function() {\r\n return this._matrixStack;\r\n }\r\n }),\r\n 'osg',\r\n 'ComputeBoundsVisitor'\r\n);\r\n\r\nexport default ComputeBoundsVisitor;","import utils from './utils';\r\nimport notify from './notify';\r\nimport Options from './Options';\r\nimport GLObject from './GLObject';\r\nimport StateAttribute from './StateAttribute';\r\n// import ShaderProcessor from 'osgShader/ShaderProcessor';\r\nimport NextShaderProcessor from '../osgShader/NextShaderProcessor';\r\n\r\nimport Timer from './Timer';\r\n\r\nvar shaderStats = Options.getOptionsURL().shaderStats ? {} : undefined;\r\nvar forceSyncCompilation = Options.getOptionsURL().syncCompile;\r\n\r\n// finish should be enough but on chrome it's identical to flush,\r\n// so we use readPixel instead\r\nvar dummy = new Uint8Array(4);\r\nvar glSync = function(gl) {\r\n gl.flush();\r\n gl.finish();\r\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, dummy);\r\n};\r\n\r\n// singleton\r\nvar sp = NextShaderProcessor //new ShaderProcessor();\r\nvar errorCallback;\r\n\r\nvar uniformRegexp = /uniform\\s+\\w+\\s+(\\w+)((\\s)?\\[(.*?)\\])?/g;\r\nvar attributesRegexp = /(in|attribute)\\s+\\w+\\s+(\\w+)\\s*;/g;\r\n\r\nvar getAttributeList = function(shaderText) {\r\n var attributeMap = {};\r\n var r, attr;\r\n while ((r = attributesRegexp.exec(shaderText)) !== null) {\r\n attr = r[2];\r\n attributeMap[attr] = true;\r\n }\r\n\r\n return attributeMap;\r\n};\r\n\r\nvar getUniformList = function(shaderText) {\r\n var uniformMap = {};\r\n var r;\r\n while ((r = uniformRegexp.exec(shaderText)) !== null) {\r\n var uniform = r[1];\r\n uniformMap[uniform] = true;\r\n }\r\n return uniformMap;\r\n};\r\n\r\n/**\r\n * Program encapsulate an vertex and fragment shader\r\n * @class Program\r\n */\r\nvar Program = function(vShader, fShader) {\r\n GLObject.call(this);\r\n StateAttribute.call(this);\r\n this._program = null;\r\n\r\n // used to know if it's a default program\r\n // a default program does nothing but avoid to do some\r\n // useless logic\r\n // if we vertex or fragment shader are set it's not a default\r\n // program anymore\r\n this._nullProgram = true;\r\n\r\n this._vertex = undefined;\r\n this._fragment = undefined;\r\n\r\n this._uniformsCache = undefined;\r\n this._attributesCache = undefined;\r\n // state caches\r\n this._activeUniforms = undefined;\r\n this._foreignUniforms = undefined;\r\n this._trackAttributes = undefined;\r\n\r\n // async compilations\r\n this._asyncCompilation = undefined;\r\n\r\n this._compileClean = undefined;\r\n\r\n if (vShader) this.setVertexShader(vShader);\r\n if (fShader) this.setFragmentShader(fShader);\r\n\r\n this._dirty = true;\r\n};\r\n\r\n// static cache of glPrograms flagged for deletion, which will actually\r\n// be deleted in the correct GL context.\r\nProgram._sDeletedGLProgramCache = new window.Map();\r\n\r\n// static method to delete Program\r\nProgram.deleteGLProgram = function(gl, program) {\r\n if (!Program._sDeletedGLProgramCache.has(gl)) Program._sDeletedGLProgramCache.set(gl, []);\r\n\r\n Program._sDeletedGLProgramCache.get(gl).push(program);\r\n};\r\n\r\n// static method to flush all the cached glPrograms which need to be deleted in the GL context specified\r\nProgram.flushDeletedGLPrograms = function(gl, availableTime) {\r\n // if no time available don't try to flush objects.\r\n if (availableTime <= 0.0) return availableTime;\r\n\r\n if (!Program._sDeletedGLProgramCache.has(gl)) return availableTime;\r\n\r\n var elapsedTime = 0.0;\r\n var beginTime = Timer.instance().tick();\r\n var deleteList = Program._sDeletedGLProgramCache.get(gl);\r\n var numPrograms = deleteList.length;\r\n\r\n for (var i = numPrograms - 1; i >= 0 && elapsedTime < availableTime; i--) {\r\n gl.deleteProgram(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n elapsedTime = Timer.instance().deltaS(beginTime, Timer.instance().tick());\r\n }\r\n\r\n return availableTime - elapsedTime;\r\n};\r\n\r\nProgram.flushAllDeletedGLPrograms = function(gl) {\r\n if (!Program._sDeletedGLProgramCache.has(gl)) return;\r\n\r\n var deleteList = Program._sDeletedGLProgramCache.get(gl);\r\n var numPrograms = deleteList.length;\r\n\r\n for (var i = numPrograms - 1; i >= 0; i--) {\r\n gl.deleteProgram(deleteList[i]);\r\n deleteList.splice(i, 1);\r\n }\r\n};\r\n\r\nProgram.onLostContext = function(gl) {\r\n if (!Program._sDeletedGLProgramCache.has(gl)) return;\r\n var deleteList = Program._sDeletedGLProgramCache.get(gl);\r\n deleteList.length = 0;\r\n return;\r\n};\r\n\r\n/** @lends Program.prototype */\r\nutils.createPrototypeStateAttribute(\r\n Program,\r\n utils.objectInherit(\r\n GLObject.prototype,\r\n utils.objectInherit(StateAttribute.prototype, {\r\n attributeType: 'Program',\r\n\r\n cloneType: function() {\r\n return new Program();\r\n },\r\n\r\n setVertexShader: function(vs) {\r\n this._vertex = vs;\r\n this._nullProgram = false;\r\n vs.setText(sp.processShader(vs.getText()));\r\n },\r\n\r\n setFragmentShader: function(fs) {\r\n this._fragment = fs;\r\n this._nullProgram = false;\r\n fs.setText(sp.processShader(fs.getText()));\r\n },\r\n\r\n getVertexShader: function() {\r\n return this._vertex;\r\n },\r\n getFragmentShader: function() {\r\n return this._fragment;\r\n },\r\n\r\n getProgram: function() {\r\n return this._program;\r\n },\r\n\r\n setActiveUniforms: function(activeUniforms) {\r\n this._activeUniforms = activeUniforms;\r\n },\r\n\r\n getActiveUniforms: function() {\r\n return this._activeUniforms;\r\n },\r\n\r\n setForeignUniforms: function(foreignUniforms) {\r\n this._foreignUniforms = foreignUniforms;\r\n },\r\n\r\n getForeignUniforms: function() {\r\n return this._foreignUniforms;\r\n },\r\n\r\n setUniformsCache: function(uniformsCache) {\r\n this._uniformsCache = uniformsCache;\r\n },\r\n\r\n getUniformsCache: function() {\r\n return this._uniformsCache;\r\n },\r\n\r\n setAttributesCache: function(attributesCache) {\r\n this._attributesCache = attributesCache;\r\n },\r\n\r\n getAttributesCache: function() {\r\n return this._attributesCache;\r\n },\r\n\r\n setTrackAttributes: function(trackAttributes) {\r\n this._trackAttributes = trackAttributes;\r\n },\r\n\r\n getTrackAttributes: function() {\r\n return this._trackAttributes;\r\n },\r\n\r\n releaseGLObjects: function() {\r\n // Call to releaseGLOBjects on shaders\r\n if (this._vertex !== undefined) this._vertex.releaseGLObjects();\r\n if (this._fragment !== undefined) this._fragment.releaseGLObjects();\r\n if (this._program === null) return;\r\n if (this._gl !== undefined) {\r\n Program.deleteGLProgram(this._gl, this._program);\r\n GLObject.removeObject(this._gl, this);\r\n }\r\n this.invalidate();\r\n },\r\n\r\n dirty: function() {\r\n this._program = undefined;\r\n },\r\n\r\n invalidate: function() {\r\n this._cacheUniformId = undefined;\r\n\r\n this._uniformsCache = undefined;\r\n this._attributesCache = undefined;\r\n this._foreignUniforms = undefined;\r\n this._trackAttributes = undefined;\r\n\r\n this._compileClean = undefined;\r\n this._program = undefined;\r\n },\r\n\r\n _rebuildProgramFromSpector: function(\r\n vertexShaderText,\r\n fragmentShaderText,\r\n onCompiled,\r\n onError\r\n ) {\r\n this._dirty = true;\r\n this._vertex.invalidate();\r\n this._fragment.invalidate();\r\n this.invalidate();\r\n this._vertex.setText(vertexShaderText);\r\n this._fragment.setText(fragmentShaderText);\r\n this._program = null;\r\n this._spectorOnCompiled = onCompiled;\r\n this._spectorOnError = onError;\r\n this._compileClean = undefined;\r\n },\r\n\r\n _onErrorToSpector: function(errLink) {\r\n if (!this._spectorOnError) return false;\r\n this._spectorOnError(errLink);\r\n return true;\r\n },\r\n\r\n _onCompilationToSpector: function() {\r\n if (!this._spectorOnCompiled) return;\r\n this._spectorOnCompiled(this._program);\r\n },\r\n\r\n _bindProgramToSpector: function() {\r\n if (!window || !window.spector || this._program.__SPECTOR_rebuildProgram) return;\r\n this._program.__SPECTOR_rebuildProgram = this._rebuildProgramFromSpector.bind(this);\r\n },\r\n\r\n _logDebugShaders: function(gl, errLink) {\r\n if (errLink !== 'Failed to create D3D shaders.\\n') return;\r\n // rawgl trick is for webgl inspector\r\n var debugShader = gl.rawgl !== undefined ? gl.rawgl : gl;\r\n if (debugShader === undefined || debugShader.getExtension !== undefined) return;\r\n debugShader = debugShader.getExtension('WEBGL_debug_shaders');\r\n if (!debugShader) return;\r\n notify.error(debugShader.getTranslatedShaderSource(this._vertex.shader));\r\n notify.error(debugShader.getTranslatedShaderSource(this._fragment.shader));\r\n },\r\n\r\n _activateFailSafe: function(gl) {\r\n var program = gl.createProgram();\r\n this._vertex.failSafe(gl, this._vertex.getText());\r\n this._fragment.failSafe(gl, this._fragment.getText());\r\n this._glAttachAndLink(gl, program, this._vertex, this._fragment);\r\n notify.warn('FailSafe shader Activated ');\r\n this._program = program;\r\n },\r\n\r\n _glAttachAndLink: function(gl, programGL, vertexShader, fragmentShader) {\r\n gl.attachShader(programGL, vertexShader.shader);\r\n gl.attachShader(programGL, fragmentShader.shader);\r\n gl.linkProgram(programGL);\r\n },\r\n\r\n _glShaderCompile: function(gl, shader) {\r\n if (shader.shader) return;\r\n if (shaderStats) {\r\n if (shader === this._vertex) shaderStats.vert = Timer.tick();\r\n else shaderStats.frag = Timer.tick();\r\n }\r\n shader.compile(gl, errorCallback);\r\n return;\r\n },\r\n\r\n _glShaderCompilationResult: function(gl, shader) {\r\n var success = shader.getCompilationResult(gl, errorCallback);\r\n if (shaderStats) {\r\n if (this._asyncCompilation === undefined) glSync(gl);\r\n if (shader === this._vertex) shaderStats.vert = Timer.tick() - shaderStats.vert;\r\n else shaderStats.frag = Timer.tick() - shaderStats.frag;\r\n }\r\n return success;\r\n },\r\n\r\n compile: function() {\r\n var gl = this._gl;\r\n\r\n var fragmentText = this._fragment.getText();\r\n var vertexText = this._vertex.getText();\r\n\r\n this._attributeMap = getAttributeList(vertexText);\r\n this._uniformMap = getUniformList(fragmentText + '\\n' + vertexText);\r\n // compile both vertex even if the first one fail (error reporting)\r\n this._glShaderCompile(gl, this._vertex);\r\n this._glShaderCompile(gl, this._fragment);\r\n },\r\n\r\n getShaderName: function() {\r\n if (this._shaderName) return this._shaderName;\r\n if (!this._fragment || !this._fragment.getText()) return;\r\n var shaderName = this._fragment.getText().match(/^#define\\s+SHADER_NAME\\s+(.*)$/m);\r\n this._shaderName = shaderName && shaderName[1] ? shaderName[1] : '';\r\n return this._shaderName;\r\n },\r\n\r\n getCompilationResultAndLink: function(gl) {\r\n if (this._compileClean) return true;\r\n if (shaderStats) {\r\n shaderStats.vert = 0;\r\n shaderStats.frag = 0;\r\n shaderStats.link = 0;\r\n shaderStats.total = 0;\r\n if (this._asyncCompilation === undefined) glSync(gl);\r\n shaderStats.total = Timer.tick();\r\n notify.log(this.getShaderName() + ' start');\r\n notify.timeStamp(this.getShaderName() + ' start');\r\n }\r\n\r\n this._compileClean = this._glShaderCompilationResult(gl, this._vertex);\r\n this._compileClean =\r\n this._glShaderCompilationResult(gl, this._fragment) && this._compileClean;\r\n\r\n if (shaderStats) {\r\n notify.log(this.getShaderName() + ' compilation');\r\n notify.timeStamp(this.getShaderName() + ' compilation');\r\n }\r\n if (!this._compileClean) return false;\r\n\r\n this._program = gl.createProgram();\r\n // force Vertex to be on 0\r\n if (this._attributeMap.Vertex) gl.bindAttribLocation(this._program, 0, 'Vertex');\r\n this._glAttachAndLink(gl, this._program, this._vertex, this._fragment);\r\n return true;\r\n },\r\n\r\n getAsyncCompiling: function() {\r\n return this._asyncCompilation;\r\n },\r\n\r\n _logShaderStats: function(gl) {\r\n if (this._asyncCompilation === undefined) glSync(gl);\r\n\r\n shaderStats.link = Timer.tick() - shaderStats.link;\r\n if (shaderStats.link) {\r\n shaderStats.total = Timer.tick() - shaderStats.total;\r\n if (this._placeHolder) {\r\n shaderStats.total = shaderStats.vert + shaderStats.frag + shaderStats.link;\r\n }\r\n\r\n var groupName =\r\n (this._placeHolder ? 'Async' : '') +\r\n this.getShaderName() +\r\n ' - ' +\r\n shaderStats.total.toFixed(2) +\r\n 'ms';\r\n\r\n notify.group(groupName);\r\n notify.log('vertex : ' + shaderStats.vert.toFixed(2) + 'ms');\r\n notify.log('fragment : ' + shaderStats.frag.toFixed(2) + 'ms');\r\n notify.log('link : ' + shaderStats.link.toFixed(2) + 'ms');\r\n notify.log('total : ' + shaderStats.total.toFixed(2) + 'ms');\r\n notify.groupEnd(groupName);\r\n }\r\n },\r\n\r\n getLinkResult: function(gl) {\r\n if (this._compileClean) {\r\n if (shaderStats) {\r\n shaderStats.link = Timer.tick();\r\n notify.log(this.getShaderName() + ' link');\r\n notify.timeStamp(this.getShaderName() + ' link');\r\n }\r\n\r\n var compileResult = gl.getProgramParameter(this._program, gl.LINK_STATUS);\r\n\r\n if (shaderStats) {\r\n this._logShaderStats(gl);\r\n }\r\n\r\n if (!compileResult && !gl.isContextLost()) {\r\n var errLink = gl.getProgramInfoLog(this._program);\r\n\r\n notify.errorFold(\r\n errLink,\r\n \"can't link program\\nvertex shader:\\n\" +\r\n this._vertex.text +\r\n '\\n fragment shader:\\n' +\r\n this._fragment.text\r\n );\r\n\r\n this._logDebugShaders(gl, errLink);\r\n if (errorCallback) {\r\n errorCallback(this._vertex.text, this._fragment.text, errLink);\r\n }\r\n this._compileClean = false;\r\n if (this._onErrorToSpector(errLink)) return;\r\n } else {\r\n /*develblock:start*/\r\n this._gl.validateProgram(this._program);\r\n var validationLogProgram = this._gl.getProgramInfoLog(this._program);\r\n if (validationLogProgram && validationLogProgram !== '') {\r\n notify.log(this.getShaderName() + '\\n' + validationLogProgram);\r\n }\r\n /*develblock:end*/\r\n this._onCompilationToSpector(this._program);\r\n }\r\n }\r\n\r\n this._dirty = false;\r\n this._asyncCompilation = -1;\r\n this._placeHolder = undefined;\r\n this._uniformsCache = {};\r\n this._attributesCache = {};\r\n\r\n if (!this._compileClean) {\r\n // Any error, Any\r\n // Pink must die.\r\n this._activateFailSafe(gl);\r\n } else {\r\n this.cacheAttributeList(gl, window.Object.keys(this._attributeMap));\r\n this.cacheUniformList(gl, window.Object.keys(this._uniformMap));\r\n }\r\n this._bindProgramToSpector();\r\n return this._compileClean;\r\n },\r\n\r\n enableAsyncCompilation: function(placeHolder, frameNum) {\r\n this._placeHolder = placeHolder;\r\n this._asyncCompilation = frameNum;\r\n },\r\n\r\n apply: function(state) {\r\n if (this._nullProgram) return;\r\n\r\n if (!this._gl) {\r\n this.setGraphicContext(state.getGraphicContext());\r\n }\r\n\r\n if (this._program && !this._dirty) {\r\n state.applyProgram(this._program);\r\n return;\r\n }\r\n\r\n if (this._placeHolder) {\r\n this._placeHolder.apply(state);\r\n return;\r\n }\r\n\r\n this.compile();\r\n\r\n if (\r\n forceSyncCompilation ||\r\n this._fragment.getText().indexOf('#pragma compilationAsync') === -1\r\n ) {\r\n this.getCompilationResultAndLink(this._gl);\r\n this.getLinkResult(this._gl);\r\n state.applyProgram(this._program);\r\n this._dirty = false;\r\n return;\r\n }\r\n this._asyncCompilation = 1;\r\n },\r\n\r\n cacheUniformList: function(gl, uniformList) {\r\n var map = this._uniformsCache;\r\n for (var i = 0, l = uniformList.length; i < l; i++) {\r\n var uniform = uniformList[i];\r\n var location = gl.getUniformLocation(this._program, uniform);\r\n if (location !== undefined && location !== null) {\r\n if (map[uniform] === undefined) {\r\n map[uniform] = location;\r\n }\r\n }\r\n }\r\n },\r\n\r\n cacheAttributeList: function(gl, attributeList) {\r\n var map = this._attributesCache;\r\n for (var i = 0, l = attributeList.length; i < l; i++) {\r\n var attr = attributeList[i];\r\n var location = gl.getAttribLocation(this._program, attr);\r\n\r\n if (location !== -1 && location !== undefined) {\r\n if (map[attr] === undefined) {\r\n map[attr] = location;\r\n }\r\n }\r\n }\r\n }\r\n })\r\n ),\r\n 'osg',\r\n 'Program'\r\n);\r\n\r\nProgram.registerErrorCallback = function(callback) {\r\n errorCallback = callback;\r\n};\r\n\r\nexport default Program;","import notify from '../osg/notify';\r\n\r\nvar CompilerVertex = {\r\n _createVertexShader: function() {\r\n // Call to specialised inhenrited shader Compiler\r\n var roots = this.declareVertexMain();\r\n var vname = this.getVertexShaderName();\r\n if (vname) roots.push(this.getNode('Define', 'SHADER_NAME').setValue(vname));\r\n\r\n // call the graph compiler itself\r\n var shader = this.createShaderFromGraphs(roots);\r\n\r\n notify.debug(this.getDebugIdentifier());\r\n notify.debug(shader);\r\n\r\n return shader;\r\n },\r\n\r\n declareVertexMain: function() {\r\n // Because of a weird bug on iOS, glPosition should be computed in the vertex shader before some varyings\r\n var roots = [this.declarePointSize(), this.declareVertexPosition()];\r\n\r\n this.declareVertexVaryings(roots);\r\n\r\n return roots;\r\n },\r\n\r\n declarePointSize: function() {\r\n var glPointSize = this.getNode('glPointSize');\r\n\r\n if (!this._pointSizeAttribute || !this._pointSizeAttribute.isEnabled()) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateConstantOne('float'))\r\n .outputs(glPointSize);\r\n return glPointSize;\r\n }\r\n\r\n this.getNode('InlineCode')\r\n .code('%pointSize = min(64.0, max(1.0, -%size / %position.z));')\r\n .inputs({\r\n position: this.getOrCreateViewVertex(),\r\n size: this.getOrCreateUniform('float', 'uPointSize')\r\n })\r\n .outputs({\r\n pointSize: glPointSize\r\n });\r\n\r\n return glPointSize;\r\n },\r\n\r\n declareVertexVaryings: function(roots) {\r\n var varyings = this._varyings;\r\n\r\n if (varyings.vModelVertex) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateModelVertex())\r\n .outputs(varyings.vModelVertex);\r\n }\r\n\r\n if (varyings.vModelNormal) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateModelNormal())\r\n .outputs(varyings.vModelNormal);\r\n }\r\n\r\n if (varyings.vModelTangent) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateModelTangent())\r\n .outputs(varyings.vModelTangent);\r\n }\r\n\r\n if (varyings.vViewVertex) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateViewVertex())\r\n .outputs(varyings.vViewVertex);\r\n }\r\n\r\n if (varyings.vViewNormal) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateViewNormal())\r\n .outputs(varyings.vViewNormal);\r\n }\r\n\r\n if (varyings.vViewTangent) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateViewTangent())\r\n .outputs(varyings.vViewTangent);\r\n }\r\n\r\n if (varyings.vVertexColor) {\r\n this.getNode('InlineCode')\r\n .code('%vcolor = %venabled == 1.0 ? %acolor : vec4(1.0, 1.0, 1.0, 1.0);')\r\n .inputs({\r\n venabled: this.getOrCreateUniform('float', 'uArrayColorEnabled'),\r\n acolor: this.getOrCreateAttribute('vec4', 'Color')\r\n })\r\n .outputs({\r\n vcolor: this.getOrCreateVarying('vec4', 'vVertexColor')\r\n });\r\n }\r\n\r\n for (var keyVarying in varyings) {\r\n var varying = varyings[keyVarying];\r\n roots.push(varying);\r\n\r\n var name = varying.getVariable();\r\n if (name.indexOf('vTexCoord') !== -1) {\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateAttribute('vec2', name.substring(1)))\r\n .outputs(varying);\r\n }\r\n }\r\n },\r\n\r\n declareVertexPosition: function() {\r\n var glPosition = this.getNode('glPosition');\r\n if (this._isBillboard) this.declareVertexTransformBillboard(glPosition);\r\n else this.declareScreenVertex(glPosition);\r\n return glPosition;\r\n },\r\n\r\n declareScreenVertex: function(glPosition) {\r\n this.getNode('MatrixMultPosition')\r\n .inputs({\r\n matrix: this.getOrCreateProjectionMatrix(),\r\n vec: this.getOrCreateViewVertex()\r\n })\r\n .outputs({\r\n vec: glPosition\r\n });\r\n },\r\n\r\n declareVertexTransformBillboard: function(glPosition) {\r\n this.getNode('Billboard')\r\n .inputs({\r\n Vertex: this.getOrCreateAttribute('vec3', 'Vertex'),\r\n ModelViewMatrix: this.getOrCreateUniform('mat4', 'uModelViewMatrix'),\r\n ProjectionMatrix: this.getOrCreateUniform('mat4', 'uProjectionMatrix')\r\n })\r\n .outputs({\r\n result: glPosition\r\n });\r\n },\r\n\r\n getOrCreateBoneMatrix: function() {\r\n // reusable BoneMatrix between Vertex, Normal, Tangent\r\n // Manadatory: scale animations must be uniform scale\r\n var boneMatrix = this._variables.boneMatrix;\r\n if (boneMatrix) return boneMatrix;\r\n boneMatrix = this.createVariable('mat4', 'boneMatrix');\r\n\r\n var inputWeights = this.getOrCreateAttribute('vec4', 'Weights');\r\n var inputBones = this.getOrCreateAttribute('vec4', 'Bones');\r\n var matrixPalette = this.getOrCreateUniform(\r\n 'vec4',\r\n 'uBones',\r\n this._skinningAttribute.getBoneUniformSize()\r\n );\r\n\r\n this.getNode('Skinning')\r\n .inputs({\r\n weights: inputWeights,\r\n bonesIndex: inputBones,\r\n matrixPalette: matrixPalette\r\n })\r\n .outputs({\r\n result: boneMatrix\r\n });\r\n\r\n return boneMatrix;\r\n },\r\n\r\n getTarget: function(inputName, i) {\r\n var type = inputName.indexOf('Tangent') !== -1 ? 'vec4' : 'vec3';\r\n return this.getOrCreateAttribute(type, inputName + '_' + i);\r\n },\r\n\r\n morphTangentApproximation: function(inputVertex, outputVertex) {\r\n var normalizedMorph = this.getOrCreateLocalNormal();\r\n // kind of tricky, here we retrieve the normalized normal after morphing\r\n // if there is no rigging we do not recompute it\r\n if (this._skinningAttribute) {\r\n normalizedMorph = this.createVariable('vec3');\r\n this.getNode('Normalize')\r\n .inputs({\r\n vec: this.getOrCreateMorphNormal()\r\n })\r\n .outputs({\r\n result: normalizedMorph\r\n });\r\n }\r\n\r\n this.getNode('InlineCode')\r\n .code('%out = %tangent.rgb - dot(%tangent.rgb, %normal) * %normal;')\r\n .inputs({\r\n tangent: inputVertex,\r\n normal: normalizedMorph\r\n })\r\n .outputs({\r\n out: outputVertex\r\n });\r\n\r\n return outputVertex;\r\n },\r\n\r\n getTargetWeights: function(inputName) {\r\n var targetWeights = this.getOrCreateUniform('vec4', 'uTargetWeights');\r\n if (inputName.indexOf('Normal') === -1 && inputName.indexOf('Tangent') === -1) {\r\n return targetWeights;\r\n }\r\n\r\n var nWeights = this.getVariable('nTargetWeights');\r\n if (nWeights) return nWeights;\r\n\r\n nWeights = this.createVariable('vec4', 'nTargetWeights');\r\n\r\n var str = '%output = abs(%wts)\\n;';\r\n str += '%output = %wts / max(1.0, %output.x + %output.y + %output.z + %output.w);';\r\n // alternative version that could handle negative weights as well\r\n // var str = '%output = %wts / max(1.0, abs(%wts.x + %wts.y + %wts.z + %wts.w));';\r\n\r\n // normalize weights to avoid negative weight for base normal/tangent\r\n this.getNode('InlineCode')\r\n .code(str)\r\n .inputs({ wts: targetWeights })\r\n .outputs({ output: nWeights });\r\n\r\n return nWeights;\r\n },\r\n\r\n morphTransformVec3: function(inputVertex, outputVertex) {\r\n var inputs = {\r\n vertex: inputVertex,\r\n weights: this.getTargetWeights(inputVertex.getVariable())\r\n };\r\n\r\n var numTargets = this._morphAttribute.getNumTargets();\r\n for (var i = 0; i < numTargets; i++) {\r\n inputs['target' + i] = this.getTarget(inputVertex.getVariable(), i);\r\n }\r\n\r\n this.getNode('Morphing')\r\n .inputs(inputs)\r\n .outputs({\r\n result: outputVertex\r\n });\r\n\r\n return outputVertex;\r\n },\r\n\r\n skinTransformVertex: function(inputVertex, outputVertex) {\r\n this.getNode('MatrixMultPosition')\r\n .setInverse(true)\r\n .inputs({\r\n matrix: this.getOrCreateBoneMatrix(),\r\n vec: inputVertex\r\n })\r\n .outputs({\r\n vec: outputVertex\r\n });\r\n return outputVertex;\r\n },\r\n\r\n skinTransformNormal: function(inputVertex, outputVertex) {\r\n this.getNode('MatrixMultDirection')\r\n .setInverse(true)\r\n .inputs({\r\n matrix: this.getOrCreateBoneMatrix(),\r\n vec: inputVertex\r\n })\r\n .outputs({\r\n vec: outputVertex\r\n });\r\n return outputVertex;\r\n },\r\n\r\n getOrCreateMorphVertex: function() {\r\n var vecOut = this.getVariable('morphVertex');\r\n if (vecOut) return vecOut;\r\n\r\n var inputVertex = this.getOrCreateAttribute('vec3', 'Vertex');\r\n if (!this._morphAttribute || !this._morphAttribute.hasTarget('Vertex')) return inputVertex;\r\n\r\n return this.morphTransformVec3(inputVertex, this.createVariable('vec3', 'morphVertex'));\r\n },\r\n\r\n getOrCreateMorphNormal: function() {\r\n var vecOut = this.getVariable('morphNormal');\r\n if (vecOut) return vecOut;\r\n\r\n var inputNormal = this.getOrCreateAttribute('vec3', 'Normal');\r\n if (!this._morphAttribute || !this._morphAttribute.hasTarget('Normal')) return inputNormal;\r\n\r\n return this.morphTransformVec3(inputNormal, this.createVariable('vec3', 'morphNormal'));\r\n },\r\n\r\n getOrCreateMorphTangent: function() {\r\n var vecOut = this.getVariable('morphTangent');\r\n if (vecOut) return vecOut;\r\n\r\n var inputTangent = this.getOrCreateAttribute('vec4', 'Tangent');\r\n var hasMorphTangent = this._morphAttribute && this._morphAttribute.hasTarget('Tangent');\r\n\r\n if (!hasMorphTangent) return inputTangent;\r\n\r\n return this.morphTransformVec3(inputTangent, this.createVariable('vec3', 'morphTangent'));\r\n\r\n // if ( !hasMorphTangent && !this._morphAttribute && !this._morphAttribute.hasTarget( 'Normal' ) ) return inputTangent;\r\n\r\n // if ( hasMorphTangent ) return this.morphTransformVec3( inputTangent, this.createVariable( 'vec3', 'morphTangent' ) );\r\n\r\n // // Approximate tangent morphing depending of the normal morphing (disabled as we are not sure it's worth it for now)\r\n // return this.morphTangentApproximation( inputTangent, this.createVariable( 'vec3', 'morphTangent' ) );\r\n },\r\n\r\n getOrCreateSkinVertex: function() {\r\n var vecOut = this.getVariable('skinVertex');\r\n if (vecOut) return vecOut;\r\n\r\n var inputVertex = this.getOrCreateMorphVertex();\r\n if (!this._skinningAttribute) return inputVertex;\r\n\r\n return this.skinTransformVertex(inputVertex, this.createVariable('vec3', 'skinVertex'));\r\n },\r\n\r\n getOrCreateSkinNormal: function() {\r\n var vecOut = this.getVariable('skinNormal');\r\n if (vecOut) return vecOut;\r\n\r\n var inputNormal = this.getOrCreateMorphNormal();\r\n if (!this._skinningAttribute) return inputNormal;\r\n\r\n return this.skinTransformNormal(inputNormal, this.createVariable('vec3', 'skinNormal'));\r\n },\r\n\r\n getOrCreateSkinTangent: function() {\r\n var vecOut = this.getVariable('skinTangent');\r\n if (vecOut) return vecOut;\r\n\r\n var inputTangent = this.getOrCreateMorphTangent();\r\n if (!this._skinningAttribute) return inputTangent;\r\n\r\n return this.skinTransformNormal(inputTangent, this.createVariable('vec3', 'skinTangent'));\r\n },\r\n\r\n getOrCreateLocalVertex: function() {\r\n return this.getOrCreateSkinVertex();\r\n },\r\n\r\n getOrCreateLocalNormal: function() {\r\n var vecOut = this.getVariable('localNormal');\r\n if (vecOut) return vecOut;\r\n\r\n var normal = this.getOrCreateSkinNormal();\r\n if (normal === this.getOrCreateAttribute('vec3', 'Normal')) return normal;\r\n\r\n vecOut = this.createVariable('vec3', 'localNormal');\r\n this.getNode('Normalize')\r\n .inputs({\r\n vec: normal\r\n })\r\n .outputs({\r\n result: vecOut\r\n });\r\n\r\n return vecOut;\r\n },\r\n\r\n getOrCreateLocalTangent: function() {\r\n var vecOut = this.getVariable('localTangent');\r\n if (vecOut) return vecOut;\r\n\r\n var inputTangent = this.getOrCreateAttribute('vec4', 'Tangent');\r\n var tangent = this.getOrCreateSkinTangent();\r\n if (tangent === inputTangent) return tangent;\r\n\r\n return this.normalizeAndSetAlpha(\r\n tangent,\r\n inputTangent,\r\n this.createVariable('vec4', 'localTangent')\r\n );\r\n },\r\n\r\n normalizeAndSetAlpha: function(tang3, tang4, vecOut) {\r\n var tangNormalized = this.createVariable('vec3');\r\n this.getNode('Normalize')\r\n .inputs({\r\n vec: tang3\r\n })\r\n .outputs({\r\n result: tangNormalized\r\n });\r\n\r\n this.getNode('SetAlpha')\r\n .inputs({\r\n color: tangNormalized,\r\n alpha: tang4\r\n })\r\n .outputs({\r\n result: vecOut\r\n });\r\n\r\n return vecOut;\r\n }\r\n};\r\n\r\nvar wrapperVertexOnly = function(fn, name) {\r\n return function() {\r\n if (this._fragmentShaderMode) {\r\n this.logError('This function should not be called from fragment shader : ' + name);\r\n }\r\n return fn.apply(this, arguments);\r\n };\r\n};\r\n\r\nfor (var fnName in CompilerVertex) {\r\n CompilerVertex[fnName] = wrapperVertexOnly(CompilerVertex[fnName], fnName);\r\n}\r\n\r\nexport default CompilerVertex;\r\n","import Light from '../osg/Light';\r\nimport notify from '../osg/notify';\r\n\r\nvar CompilerFragment = {\r\n _createFragmentShader: function() {\r\n // Call to specialised inhenrited shader Compiler\r\n var roots = this.createFragmentShaderGraph();\r\n var fname = this.getFragmentShaderName();\r\n if (fname) roots.push(this.getNode('Define', 'SHADER_NAME').setValue(fname));\r\n\r\n var shader = this.createShaderFromGraphs(roots);\r\n\r\n notify.debug(this.getDebugIdentifier());\r\n notify.debug(shader);\r\n\r\n this.cleanAfterFragment();\r\n\r\n return shader;\r\n },\r\n\r\n applyPointSizeCircle: function(color) {\r\n if (\r\n !this._pointSizeAttribute ||\r\n !this._pointSizeAttribute.isEnabled() ||\r\n !this._pointSizeAttribute.isCircleShape()\r\n ) {\r\n return color;\r\n }\r\n\r\n this.getNode('InlineCode')\r\n .code('if (length(2.0 * gl_PointCoord - 1.0) > %radius) discard;')\r\n .inputs({\r\n radius: this.getOrCreateConstantOne('float')\r\n })\r\n .outputs({\r\n output: color\r\n });\r\n\r\n return color;\r\n },\r\n\r\n cleanAfterFragment: function() {\r\n // reset for next\r\n this._variables = {};\r\n this._activeNodeMap = {};\r\n\r\n // clean texture cache variable (for vertex shader re-usage)\r\n for (var keyTexture in this._texturesByName) {\r\n this._texturesByName[keyTexture].variable = undefined;\r\n }\r\n\r\n for (var keyVarying in this._varyings) {\r\n var varying = this._varyings[keyVarying];\r\n varying.reset();\r\n this._activeNodeMap[varying.getID()] = varying;\r\n this._variables[keyVarying] = varying;\r\n }\r\n },\r\n\r\n createDefaultFragmentShaderGraph: function() {\r\n var fofd = this.getOrCreateConstant('vec4', 'fofd').setValue('vec4(1.0, 0.0, 1.0, 0.7)');\r\n var fragCol = this.getNode('glFragColor');\r\n this.getNode('SetFromNode')\r\n .inputs(fofd)\r\n .outputs(fragCol);\r\n return fragCol;\r\n },\r\n\r\n createFragmentShaderGraph: function() {\r\n // shader graph can have multiple output (glPointsize, varyings)\r\n // here named roots all outputs must be pushed inside\r\n var roots = [];\r\n\r\n // no material then return a default shader\r\n if (!this._material) {\r\n roots.push(this.createDefaultFragmentShaderGraph());\r\n return roots;\r\n }\r\n\r\n var finalColor =\r\n this._lights.length > 0 ? this.getLighting() : this.getOrCreateMaterialDiffuseColor();\r\n\r\n var emission = this.getOrCreateMaterialEmission();\r\n if (emission) {\r\n var emit = this.createVariable('vec3');\r\n this.getNode('Add')\r\n .inputs(finalColor, emission)\r\n .outputs(emit);\r\n finalColor = emit;\r\n }\r\n\r\n var textureColor = this.getDiffuseColorFromTextures();\r\n if (textureColor) {\r\n var texColor = this.createVariable('vec3');\r\n this.getNode('Mult')\r\n .inputs(finalColor, textureColor)\r\n .outputs(texColor);\r\n finalColor = texColor;\r\n }\r\n\r\n var alpha = this.getAlpha();\r\n\r\n // premult alpha\r\n finalColor = this.getPremultAlpha(finalColor, alpha);\r\n\r\n var fragColor = this.getNode('glFragColor');\r\n\r\n this.applyPointSizeCircle(fragColor);\r\n\r\n // todo add gamma corrected color, but it would also mean to handle correctly srgb texture\r\n // so it should be done at the same time. see osg.Tetxure to implement srgb\r\n this.getNode('SetAlpha')\r\n .inputs({\r\n color: finalColor,\r\n alpha: alpha\r\n })\r\n .outputs({\r\n result: fragColor\r\n });\r\n\r\n roots.push(fragColor);\r\n\r\n return roots;\r\n },\r\n\r\n getAlpha: function() {\r\n // compute alpha\r\n var alpha = this.createVariable('float');\r\n var textureTexel = this.getFirstValidTexture();\r\n\r\n var inputs = {\r\n color: this.getOrCreateMaterialDiffuseColor()\r\n };\r\n if (textureTexel) inputs.texelAlpha = textureTexel;\r\n\r\n var str = textureTexel ? '%alpha = %color.a * %texelAlpha.a;' : '%alpha = %color.a;';\r\n\r\n // Discard fragments totally transparents when rendering billboards\r\n if (this._isBillboard) {\r\n str += 'if ( %alpha == 0.0) discard;';\r\n }\r\n\r\n this.getNode('InlineCode')\r\n .code(str)\r\n .inputs(inputs)\r\n .outputs({\r\n alpha: alpha\r\n });\r\n\r\n return alpha;\r\n },\r\n\r\n getOrCreateFrontViewTangent: function() {\r\n var out = this._variables.frontViewTangent;\r\n if (out) return out;\r\n out = this.createVariable('vec4', 'frontViewTangent');\r\n\r\n this.getNode('FrontNormal')\r\n .inputs({ normal: this.getOrCreateViewTangent() })\r\n .outputs({ result: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateFrontViewNormal: function() {\r\n var out = this._variables.frontViewNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'frontViewNormal');\r\n\r\n this.getNode('FrontNormal')\r\n .inputs({ normal: this.getOrCreateViewNormal() })\r\n .outputs({ result: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateNormalizedViewEyeDirection: function() {\r\n var out = this._variables.eyeVector;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'eyeVector');\r\n\r\n this.getNode('SetFromNode')\r\n .inputs(this.getOrCreateViewVertex())\r\n .outputs(out);\r\n\r\n this.getNode('Normalize')\r\n .inputs({ vec: out })\r\n .outputs({ result: out });\r\n\r\n this.getNode('Mult')\r\n .inputs(out, this.createVariable('float').setValue('-1.0'))\r\n .outputs(out);\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateNormalizedFrontViewNormal: function() {\r\n var out = this._variables.nFrontViewNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'nFrontViewNormal');\r\n\r\n this.getNode('Normalize')\r\n .inputs({ vec: this.getOrCreateFrontViewNormal() })\r\n .outputs({ result: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateFrontModelNormal: function() {\r\n var out = this._variables.frontModelNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'frontModelNormal');\r\n\r\n this.getNode('FrontNormal')\r\n .inputs({ normal: this.getOrCreateModelNormal() })\r\n .outputs({ result: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateNormalizedFrontModelNormal: function() {\r\n var out = this._variables.nFrontModelNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'nFrontModelNormal');\r\n\r\n this.getNode('Normalize')\r\n .inputs({ vec: this.getOrCreateFrontModelNormal() })\r\n .outputs({ result: out });\r\n\r\n return out;\r\n },\r\n\r\n getPremultAlpha: function(finalColor, alpha) {\r\n if (alpha === undefined) return finalColor;\r\n\r\n var premultAlpha = this.createVariable('vec4');\r\n\r\n this.getNode('PreMultAlpha')\r\n .inputs({ color: finalColor, alpha: alpha })\r\n .outputs({ result: premultAlpha });\r\n\r\n return premultAlpha;\r\n },\r\n\r\n getColorsRGB: function(finalColor) {\r\n var finalSrgbColor = this.createVariable('vec3');\r\n this.getNode('LinearTosRGB')\r\n .inputs({ color: finalColor })\r\n .outputs({ color: finalSrgbColor });\r\n\r\n return finalSrgbColor;\r\n },\r\n\r\n multiplyDiffuseWithVertexColor: function(diffuseColor) {\r\n var vertexColor = this.getOrCreateVarying('vec4', 'vVertexColor');\r\n var vertexColorUniform = this.getOrCreateUniform('float', 'uArrayColorEnabled');\r\n var tmp = this.createVariable('vec4');\r\n\r\n var str = [\r\n '',\r\n '%color = %diffuse;',\r\n 'if ( %hasVertexColor == 1.0)',\r\n ' %color *= %vertexColor;'\r\n ].join('\\n');\r\n\r\n this.getNode('InlineCode')\r\n .code(str)\r\n .inputs({\r\n diffuse: diffuseColor,\r\n hasVertexColor: vertexColorUniform,\r\n vertexColor: vertexColor\r\n })\r\n .outputs({ color: tmp })\r\n .comment('diffuse color = diffuse color * vertex color');\r\n\r\n return tmp;\r\n },\r\n\r\n getDiffuseColorFromTextures: function() {\r\n var texturesInput = [];\r\n var textures = this._texturesByName;\r\n\r\n for (var keyTexture in textures) {\r\n var texture = textures[keyTexture];\r\n\r\n if (texture.shadow) continue;\r\n\r\n texturesInput.push(this.getTextureByName(keyTexture).variable);\r\n }\r\n\r\n // if multi texture multiply them all with diffuse\r\n // but if only one, return the first\r\n if (texturesInput.length > 1) {\r\n var texAccum = this.createVariable('vec3', 'texDiffuseAccum');\r\n\r\n this.getNode('Mult')\r\n .inputs(texturesInput)\r\n .outputs(texAccum);\r\n return texAccum;\r\n } else if (texturesInput.length === 1) {\r\n return texturesInput[0];\r\n }\r\n\r\n return undefined;\r\n },\r\n\r\n getFirstValidTexture: function() {\r\n var textures = this._textures;\r\n for (var i = 0, nb = textures.length; i < nb; ++i) {\r\n var tex = textures[i];\r\n if (tex) return this.getTextureByName(tex.getName()).variable;\r\n }\r\n return undefined;\r\n },\r\n\r\n _getShadowReceiveAttributeFromLightNum: function(array, lightNum) {\r\n // array is shadow textures or shadow receive attributes\r\n for (var i = 0; i < array.length; i++) {\r\n var shadow = array[i];\r\n if (shadow && shadow.getLightNumber() === lightNum) {\r\n return shadow;\r\n }\r\n }\r\n },\r\n\r\n _getShadowTextureFromLightNum: function(array, lightNum) {\r\n // array is shadow textures or shadow receive attributes\r\n for (var i = 0; i < array.length; i++) {\r\n var shadow = array[i];\r\n if (shadow && shadow.hasLightNumber(lightNum)) {\r\n return shadow;\r\n }\r\n }\r\n },\r\n\r\n getInputsFromShadow: function(shadowReceive, shadowTexture, lighted, lightNum) {\r\n var shadowUniforms = shadowReceive.getOrCreateUniforms();\r\n var tUnit = this._shadowsTextures.indexOf(shadowTexture);\r\n var textureUniforms = shadowTexture.getOrCreateUniforms(tUnit);\r\n\r\n var suffix = shadowReceive.getAtlas() ? '_' + lightNum : '';\r\n var inputs = {\r\n lighted: lighted,\r\n normalWorld: this.getOrCreateNormalizedFrontModelNormal(),\r\n vertexWorld: this.getOrCreateModelVertex(),\r\n shadowTexture: this.getOrCreateSampler('sampler2D', 'Texture' + tUnit),\r\n shadowSize: this.getOrCreateUniform(textureUniforms['RenderSize']),\r\n shadowProjection: this.getOrCreateUniform(textureUniforms['Projection' + suffix]),\r\n\r\n shadowViewRight: this.getOrCreateUniform(textureUniforms['ViewRight' + suffix]),\r\n shadowViewUp: this.getOrCreateUniform(textureUniforms['ViewUp' + suffix]),\r\n shadowViewLook: this.getOrCreateUniform(textureUniforms['ViewLook' + suffix]),\r\n\r\n shadowDepthRange: this.getOrCreateUniform(textureUniforms['DepthRange' + suffix]),\r\n shadowBias: this.getOrCreateUniform(shadowUniforms.bias)\r\n };\r\n\r\n if (shadowReceive.getAtlas())\r\n inputs.atlasSize = this.getOrCreateUniform(textureUniforms['MapSize' + suffix]);\r\n if (shadowReceive.getNormalBias())\r\n inputs.normalBias = this.getOrCreateUniform(shadowUniforms.normalBias);\r\n\r\n return inputs;\r\n },\r\n\r\n getOrCreateDistanceShadow: function(num) {\r\n if (!this._computeShadowOutDistance) return undefined;\r\n\r\n var varName = 'shadowDistance' + num;\r\n var distance = this.getVariable(varName);\r\n if (!distance) distance = this.createVariable('float', varName).setValue('0.0');\r\n return distance;\r\n },\r\n\r\n getOrCreateJitterShadow: function() {\r\n return false;\r\n },\r\n\r\n hasLightShadow: function(lightNum) {\r\n var shadowTexture = this._getShadowTextureFromLightNum(this._shadowsTextures, lightNum);\r\n var shadowReceive = this._getShadowReceiveAttributeFromLightNum(this._shadows, lightNum);\r\n return !!shadowTexture && !!shadowReceive;\r\n },\r\n\r\n createShadowingLight: function(light, lighted) {\r\n var lightNum = light.getLightNumber();\r\n var shadowTexture = this._getShadowTextureFromLightNum(this._shadowsTextures, lightNum);\r\n var shadowReceive = this._getShadowReceiveAttributeFromLightNum(this._shadows, lightNum);\r\n if (!shadowTexture || !shadowReceive) return undefined;\r\n\r\n var inputs = this.getInputsFromShadow(shadowReceive, shadowTexture, lighted, lightNum);\r\n\r\n var shadowedOutput = this.createVariable('float');\r\n var outputs = {\r\n result: shadowedOutput\r\n };\r\n\r\n var defines = shadowReceive.getDefines();\r\n\r\n var outDistance = this.getOrCreateDistanceShadow(lightNum);\r\n if (outDistance) {\r\n outputs.outDistance = outDistance;\r\n defines.push('#define _OUT_DISTANCE');\r\n }\r\n\r\n var doJitter = this.getOrCreateJitterShadow(lightNum);\r\n if (doJitter) {\r\n inputs.jitter = doJitter;\r\n }\r\n\r\n this.getNode('ShadowReceive')\r\n .inputs(inputs)\r\n .outputs(outputs)\r\n .addDefines(defines);\r\n\r\n return shadowedOutput;\r\n },\r\n\r\n getOrCreateMaterialNormal: function() {\r\n return this.getOrCreateNormalizedFrontViewNormal();\r\n },\r\n\r\n getOrCreateMaterialDiffuseColor: function() {\r\n var matDiffuse = this.getVariable('materialDiffuseColor');\r\n if (matDiffuse) return matDiffuse;\r\n matDiffuse = this.createVariable('vec4', 'materialDiffuseColor');\r\n\r\n var diffuse = this.getOrCreateUniform(this._material.getOrCreateUniforms().diffuse);\r\n this.getNode('Mult')\r\n .inputs(this.multiplyDiffuseWithVertexColor(diffuse))\r\n .outputs(matDiffuse);\r\n\r\n return matDiffuse;\r\n },\r\n\r\n getOrCreateMaterialEmission: function() {\r\n return this.getOrCreateUniform(this._material.getOrCreateUniforms().emission);\r\n },\r\n\r\n getOrCreateMaterialSpecularColor: function() {\r\n return this.getOrCreateUniform(this._material.getOrCreateUniforms().specular);\r\n },\r\n\r\n getOrCreateMaterialSpecularHardness: function() {\r\n return this.getOrCreateUniform(this._material.getOrCreateUniforms().shininess);\r\n },\r\n\r\n getOrCreateMaterialAmbient: function() {\r\n return this.getOrCreateUniform(this._material.getOrCreateUniforms().ambient);\r\n },\r\n\r\n getLighting: function() {\r\n if (this._lights.length === 0) return undefined;\r\n\r\n var res = this.getLightingSeparate();\r\n var output = this.createVariable('vec3');\r\n this.getNode('Add')\r\n .inputs(res.diffuse, res.specular)\r\n .outputs(output);\r\n\r\n return output;\r\n },\r\n\r\n getLightingSeparate: function() {\r\n if (this._lights.length === 0) return undefined;\r\n\r\n // return contribution of diffuse and specular lights\r\n var diffuseSum = [];\r\n var specularSum = [];\r\n\r\n for (var i = 0; i < this._lights.length; i++) {\r\n var light = this._lights[i];\r\n var outputs = this.getLightSeparate(light);\r\n diffuseSum.push(outputs.diffuseOut);\r\n specularSum.push(outputs.specularOut);\r\n }\r\n\r\n var finalDiffuse;\r\n var finalSpecular;\r\n if (this._lights.length === 1) {\r\n finalDiffuse = diffuseSum[0];\r\n finalSpecular = specularSum[0];\r\n } else {\r\n finalDiffuse = this.createVariable('vec3');\r\n this.getNode('Add')\r\n .inputs(diffuseSum)\r\n .outputs(finalDiffuse);\r\n\r\n finalSpecular = this.createVariable('vec3');\r\n this.getNode('Add')\r\n .inputs(specularSum)\r\n .outputs(finalSpecular);\r\n }\r\n\r\n return {\r\n diffuse: finalDiffuse,\r\n specular: finalSpecular\r\n };\r\n },\r\n\r\n getLightSeparate: function(light) {\r\n var precompute = this.getPrecomputeLight(light);\r\n var outputs = this.getLightWithPrecompute(light, precompute);\r\n\r\n var shadowFactor = this.createShadowingLight(light, outputs.lighted);\r\n if (shadowFactor) {\r\n this.getNode('Mult')\r\n .inputs(outputs.diffuseOut, shadowFactor)\r\n .outputs(outputs.diffuseOut);\r\n this.getNode('Mult')\r\n .inputs(outputs.specularOut, shadowFactor)\r\n .outputs(outputs.specularOut);\r\n }\r\n\r\n var ambient = this.getAmbientLight(light);\r\n if (ambient)\r\n this.getNode('Add')\r\n .inputs(outputs.diffuseOut, ambient)\r\n .outputs(outputs.diffuseOut);\r\n\r\n return {\r\n diffuseOut: outputs.diffuseOut,\r\n specularOut: outputs.specularOut,\r\n // below can be used re-used if needed (sss, etc...)\r\n lighted: outputs.lighted,\r\n attenuation: precompute.attenuation,\r\n eyeLightDir: precompute.eyeLightDir,\r\n dotNL: precompute.dotNL\r\n };\r\n },\r\n\r\n getPrecomputeLight: function(light) {\r\n var lightUniforms = light.getOrCreateUniforms();\r\n\r\n var outputs = {\r\n attenuation: this.createVariable('float'),\r\n eyeLightDir: this.createVariable('vec3'),\r\n dotNL: this.createVariable('float')\r\n };\r\n\r\n var inputs = {\r\n normal: this.getOrCreateMaterialNormal()\r\n };\r\n\r\n var nodeName;\r\n\r\n var lightType = light.getLightType();\r\n if (lightType === Light.POINT) {\r\n nodeName = 'PrecomputePoint';\r\n\r\n inputs.viewVertex = this.getOrCreateViewVertex();\r\n inputs.lightAttenuation = this.getOrCreateUniform(lightUniforms.attenuation);\r\n inputs.lightViewPosition = this.getOrCreateUniform(lightUniforms.viewPosition);\r\n } else if (lightType === Light.SPOT) {\r\n nodeName = 'PrecomputeSpot';\r\n\r\n inputs.viewVertex = this.getOrCreateViewVertex();\r\n inputs.lightViewDirection = this.getOrCreateUniform(lightUniforms.viewDirection);\r\n inputs.lightAttenuation = this.getOrCreateUniform(lightUniforms.attenuation);\r\n inputs.lightSpotCutOff = this.getOrCreateUniform(lightUniforms.spotCutOff);\r\n inputs.lightSpotBlend = this.getOrCreateUniform(lightUniforms.spotBlend);\r\n inputs.lightViewPosition = this.getOrCreateUniform(lightUniforms.viewPosition);\r\n } else {\r\n nodeName = 'PrecomputeSun';\r\n inputs.lightViewDirection = this.getOrCreateUniform(lightUniforms.viewDirection);\r\n }\r\n\r\n this.getNode(nodeName)\r\n .inputs(inputs)\r\n .outputs(outputs);\r\n return outputs;\r\n },\r\n\r\n getLightWithPrecompute: function(light, precompute) {\r\n var lightUniforms = light.getOrCreateUniforms();\r\n\r\n var inputs = {\r\n normal: this.getOrCreateMaterialNormal(),\r\n eyeVector: this.getOrCreateNormalizedViewEyeDirection(),\r\n dotNL: precompute.dotNL,\r\n attenuation: precompute.attenuation,\r\n\r\n materialDiffuse: this.getOrCreateMaterialDiffuseColor(),\r\n materialSpecular: this.getOrCreateMaterialSpecularColor(),\r\n materialShininess: this.getOrCreateMaterialSpecularHardness(),\r\n\r\n lightDiffuse: this.getOrCreateUniform(lightUniforms.diffuse),\r\n lightSpecular: this.getOrCreateUniform(lightUniforms.specular),\r\n eyeLightDir: precompute.eyeLightDir\r\n };\r\n\r\n var nodeName = 'ComputeLightLambertCookTorrance';\r\n if (light.getLightType() === Light.HEMI) {\r\n inputs.lightGround = this.getOrCreateUniform(lightUniforms.ground);\r\n nodeName = 'HemiLight';\r\n }\r\n\r\n var outputs = this.getOutputsFromLight();\r\n this.getNode(nodeName)\r\n .inputs(inputs)\r\n .outputs(outputs);\r\n\r\n return outputs;\r\n },\r\n\r\n getAmbientLight: function(light) {\r\n var ambient = this.createVariable('vec3');\r\n var lightAmbient = this.getOrCreateUniform(light.getOrCreateUniforms().ambient);\r\n var materialAmbient = this.getOrCreateMaterialAmbient();\r\n this.getNode('Mult')\r\n .inputs(materialAmbient, lightAmbient)\r\n .outputs(ambient);\r\n return ambient;\r\n },\r\n\r\n getOutputsFromLight: function() {\r\n var outputs = {\r\n diffuseOut: this.createVariable('vec3'),\r\n specularOut: this.createVariable('vec3'),\r\n lighted: this.createVariable('bool')\r\n };\r\n\r\n // the light glsl function always output this boolean\r\n // even if no shadowmaping (so the variable ends up unused)\r\n outputs.lighted.silenceWarning = true;\r\n\r\n return outputs;\r\n },\r\n\r\n createTextureRGBA: function(texture, textureSampler, texCoord) {\r\n // but we could later implement srgb inside and read differents flag\r\n // as read only in the texture\r\n\r\n var texel = this.createVariable('vec4');\r\n this.getNode('TextureRGBA')\r\n .inputs({ tex: textureSampler, uv: texCoord })\r\n .outputs({ result: texel });\r\n\r\n return texel;\r\n }\r\n};\r\n\r\nvar wrapperFragmentOnly = function(fn, name) {\r\n return function() {\r\n if (!this._fragmentShaderMode) {\r\n this.logError('This function should not be called from vertex shader : ' + name);\r\n }\r\n return fn.apply(this, arguments);\r\n };\r\n};\r\n\r\nfor (var fnName in CompilerFragment) {\r\n CompilerFragment[fnName] = wrapperFragmentOnly(CompilerFragment[fnName], fnName);\r\n}\r\n\r\nexport default CompilerFragment;\r\n","import notify from '../osg/notify';\r\nimport Uniform from '../osg/Uniform';\r\nimport factory from './nodeFactory';\r\nimport utils from '../osg/utils';\r\nimport CompilerVertex from './CompilerVertex';\r\nimport CompilerFragment from './CompilerFragment';\r\nimport NextShaderProcessor from './NextShaderProcessor';\r\n\r\n\r\nvar Compiler = function(attributes, textureAttributes, shaderProcessor) {\r\n this._attributes = attributes;\r\n this._textureAttributes = textureAttributes;\r\n\r\n this._fragmentShaderMode = false; // current context\r\n\r\n this._activeNodeMap = {};\r\n this._compiledNodeMap = {};\r\n this._traversedNodeMap = {};\r\n\r\n this._variables = {};\r\n this._varyings = {};\r\n this._vertexShader = [];\r\n this._fragmentShader = [];\r\n\r\n this._shaderProcessor = NextShaderProcessor// shaderProcessor;\r\n this._texturesByName = {};\r\n\r\n // TODO: Have to handle better textures\r\n // 4 separate loop over texture list: one here, one for declareTexture, 2 for vertexShader (varying decl + varying store)\r\n // (not counting loops done above in shader generator)\r\n\r\n this._shadowsTextures = [];\r\n this._lights = [];\r\n this._shadows = [];\r\n this._textures = [];\r\n this._material = null;\r\n\r\n this._invariantPosition = false;\r\n this._isBillboard = false;\r\n\r\n // Important: if not using Compiler for Both VS and FS Check either of those\r\n // it allow override by custom Processor of some check between the VS & FS pass (varying mostly)\r\n this._customVertexShader = false;\r\n this._customFragmentShader = false;\r\n\r\n // from Attributes to variables to build shader nodes graph from\r\n this.initAttributes();\r\n this.initTextureAttributes();\r\n};\r\n\r\nCompiler.cloneStateAttributeConfig = function(compilerClass) {\r\n return JSON.parse(JSON.stringify(compilerClass.stateAttributeConfig));\r\n};\r\n\r\nCompiler.setStateAttributeConfig = function(compilerClass, config) {\r\n compilerClass.stateAttributeConfig = config;\r\n\r\n config.attribute.forEach(utils.getOrCreateStateAttributeTypeMemberIndexFromName);\r\n config.textureAttribute.forEach(utils.getOrCreateTextureStateAttributeTypeMemberIndexFromName);\r\n\r\n compilerClass.validAttributeTypeMember = config.attribute;\r\n compilerClass.validTextureAttributeTypeMember = config.textureAttribute;\r\n};\r\n\r\nCompiler.setStateAttributeConfig(Compiler, {\r\n attribute: [\r\n 'Light0',\r\n 'ShadowReceive0',\r\n 'Light1',\r\n 'ShadowReceive1',\r\n 'Light2',\r\n 'ShadowReceive2',\r\n 'Light3',\r\n 'ShadowReceive3',\r\n 'Light4',\r\n 'Light5',\r\n 'Light6',\r\n 'Light7',\r\n 'Material',\r\n 'PointSize',\r\n 'Billboard',\r\n 'Morph',\r\n 'Skinning'\r\n ],\r\n textureAttribute: ['Texture']\r\n});\r\n\r\nCompiler.prototype = utils.extend({}, CompilerVertex, CompilerFragment, {\r\n constructor: Compiler,\r\n\r\n createFragmentShader: function() {\r\n this._fragmentShaderMode = true;\r\n return this._createFragmentShader();\r\n },\r\n\r\n createVertexShader: function() {\r\n this._fragmentShaderMode = false;\r\n return this._createVertexShader();\r\n },\r\n\r\n getOrCreateProjectionMatrix: function() {\r\n return this.getOrCreateUniform('mat4', 'uProjectionMatrix');\r\n },\r\n\r\n getCompilerName: function() {\r\n return this._material ? 'CompilerOSGJS' : 'NoMaterialCompilerOSGJS';\r\n },\r\n\r\n getFragmentShaderName: function() {\r\n var compilerName = this.getCompilerName();\r\n\r\n var materialName = this._material && this._material.getName();\r\n if (materialName) {\r\n // escape everything but letter and number\r\n materialName = materialName.replace(/[^a-zA-Z0-9]+/g, '_').slice(0, 20);\r\n compilerName += '(' + materialName + ')';\r\n }\r\n\r\n return compilerName;\r\n },\r\n\r\n getVertexShaderName: function() {\r\n return this.getFragmentShaderName();\r\n },\r\n\r\n getDebugIdentifier: function() {\r\n var vname = this.getVertexShaderName();\r\n var fname = this.getFragmentShaderName();\r\n return vname === fname ? fname : vname + '|' + fname;\r\n },\r\n\r\n logError: function(msg) {\r\n notify.error(this.getDebugIdentifier() + ' : ' + msg);\r\n },\r\n\r\n logWarn: function(msg) {\r\n notify.warn(this.getDebugIdentifier() + ' : ' + msg);\r\n },\r\n\r\n getOrCreateConstantOne: function(type) {\r\n return this.getOrCreateConstant(type, type + 'White').setValue(type + '(1.0)');\r\n },\r\n\r\n getOrCreateConstantZero: function(type) {\r\n return this.getOrCreateConstant(type, type + 'Black').setValue(type + '(0.0)');\r\n },\r\n\r\n initAttributes: function() {\r\n var attributes = this._attributes;\r\n var lights = this._lights;\r\n var shadows = this._shadows;\r\n for (var i = 0, l = attributes.length; i < l; i++) {\r\n var type = attributes[i].className();\r\n\r\n // Test one light at a time\r\n if (type === 'Light') {\r\n // && lights.length === 0) {\r\n lights.push(attributes[i]);\r\n } else if (type === 'Material') {\r\n this._material = attributes[i];\r\n } else if (type === 'ShadowReceiveAttribute') {\r\n shadows.push(attributes[i]);\r\n } else if (type === 'Billboard') {\r\n this._isBillboard = !!attributes[i];\r\n } else if (type === 'SkinningAttribute') {\r\n this._skinningAttribute = attributes[i];\r\n } else if (type === 'MorphAttribute') {\r\n this._morphAttribute = attributes[i];\r\n } else if (type === 'PointSizeAttribute') {\r\n this._pointSizeAttribute = attributes[i];\r\n }\r\n }\r\n },\r\n\r\n initTextureAttributes: function() {\r\n var textureAttributes = this._textureAttributes;\r\n var texturesNum = textureAttributes.length;\r\n this._textures.length = this._shadowsTextures.length = texturesNum;\r\n\r\n for (var j = 0; j < texturesNum; j++) {\r\n var tu = textureAttributes[j];\r\n if (tu === undefined) {\r\n continue;\r\n }\r\n\r\n for (var t = 0, tl = tu.length; t < tl; t++) {\r\n this.registerTextureAttributes(tu[t], j);\r\n }\r\n }\r\n },\r\n\r\n registerTextureAttributes: function(tuTarget, tunit) {\r\n var tType = tuTarget.className();\r\n if (tType === 'Texture') return this.registerTexture(tuTarget, tunit);\r\n if (tType.indexOf('ShadowTexture') !== -1)\r\n return this.registerTextureShadow(tuTarget, tunit);\r\n },\r\n\r\n registerTexture: function(tuTarget, texUnit) {\r\n var tName = tuTarget.getName();\r\n if (!tName) {\r\n tName = 'Texture' + texUnit;\r\n tuTarget.setName(tName);\r\n }\r\n this._textures[texUnit] = tuTarget;\r\n\r\n this._texturesByName[tName] = {\r\n texture: tuTarget,\r\n variable: undefined,\r\n textureUnit: texUnit\r\n };\r\n },\r\n\r\n registerTextureShadow: function(tuTarget, texUnit) {\r\n var tName = tuTarget.getName();\r\n if (!tName) {\r\n tName = 'Texture' + texUnit;\r\n tuTarget.setName(tName);\r\n }\r\n this._shadowsTextures[texUnit] = tuTarget;\r\n\r\n this._texturesByName[tName] = {\r\n texture: tuTarget,\r\n variable: undefined,\r\n textureUnit: texUnit,\r\n shadow: true\r\n };\r\n },\r\n\r\n getTextureByName: function(name) {\r\n var texObj = this._texturesByName[name];\r\n if (!texObj || texObj.variable) return texObj;\r\n\r\n var texture = texObj.texture;\r\n var texCoordUnit = texObj.textureUnit;\r\n\r\n var textureSampler;\r\n\r\n var className = texture.className();\r\n var samplerName = 'Texture' + texCoordUnit;\r\n if (className === 'Texture') {\r\n textureSampler = this.getOrCreateSampler('sampler2D', samplerName);\r\n } else if (className === 'TextureCubeMap') {\r\n textureSampler = this.getOrCreateSampler('samplerCube', samplerName);\r\n } else {\r\n return;\r\n }\r\n\r\n var texCoord = this._fragmentShaderMode\r\n ? this.getOrCreateVarying('vec2', 'vTexCoord' + texCoordUnit)\r\n : this.getOrCreateAttribute('vec2', 'TexCoord' + texCoordUnit);\r\n\r\n texObj.variable = this.createTextureRGBA(texture, textureSampler, texCoord);\r\n\r\n return texObj;\r\n },\r\n\r\n // The Compiler Main Code called on Vertex or Fragment Shader Graph\r\n createShaderFromGraphs: function(roots) {\r\n this._compiledNodeMap = {};\r\n\r\n // list all vars\r\n var variables = [];\r\n for (var keyVariable in this._variables) {\r\n var varNode = this._variables[keyVariable];\r\n var d = varNode.declare();\r\n if (d) {\r\n variables.push(d);\r\n }\r\n }\r\n\r\n // defines and extensions are added by process shader\r\n var extensions = this.evaluateExtensions(roots);\r\n var defines = this.evaluateDefines(roots);\r\n\r\n var shaderStack = [];\r\n shaderStack.push('\\n');\r\n shaderStack.push(this.evaluateGlobalVariableDeclaration(roots));\r\n if (this._invariantPosition && !this._fragmentShaderMode)\r\n shaderStack.push('\\ninvariant gl_Position;');\r\n shaderStack.push('\\n');\r\n shaderStack.push(this.evaluateGlobalFunctionDeclaration(roots));\r\n\r\n shaderStack.push('void main() {');\r\n\r\n // declare variables in main\r\n if (variables.length !== 0) {\r\n shaderStack.push('// vars\\n');\r\n shaderStack.push(variables.join(' '));\r\n shaderStack.push('\\n// end vars\\n');\r\n }\r\n\r\n // make sure we have at least one output\r\n if (roots.length === 0) {\r\n this.logError('shader without any final Node output (need at least one)');\r\n }\r\n\r\n shaderStack.push(this.evaluate(roots));\r\n\r\n shaderStack.push('}');\r\n\r\n // Shader Graph has been outputed an array of string\r\n // we concatenate it to a shader string program\r\n var shaderStr = shaderStack.join('\\n');\r\n\r\n // Process defines, add precision, resolve include pragma\r\n var shader = this._shaderProcessor.processShader(\r\n shaderStr,\r\n defines,\r\n extensions,\r\n this._fragmentShaderMode ? 'fragment' : 'vertex'\r\n );\r\n\r\n /*develblock:start*/\r\n // Check\r\n var compiledNodes = this._compiledNodeMap;\r\n var activeNodes = this._activeNodeMap;\r\n var messages = [];\r\n for (var key in activeNodes) {\r\n if (compiledNodes[key]) continue;\r\n\r\n var node = activeNodes[key];\r\n if (node.silenceWarning) continue;\r\n\r\n var msg = '[' + node.toString() + ']:';\r\n var nodeInputs = node.getInputs();\r\n for (var i = 0; i < nodeInputs.length; ++i) {\r\n var nodeInput = nodeInputs[i];\r\n msg += '\\n - Computed by ' + nodeInput.getType();\r\n\r\n var argOutputs = nodeInput.getOutputs();\r\n for (var keyOutput in argOutputs) {\r\n if (argOutputs[keyOutput] === node) {\r\n msg += ' - as ' + keyOutput;\r\n }\r\n }\r\n }\r\n\r\n messages.push(msg);\r\n }\r\n\r\n if (messages.length) {\r\n this.logWarn('Nodes requested, but not compiled:\\n' + messages.join('\\n\\n'));\r\n }\r\n /*develblock:end*/\r\n\r\n return shader;\r\n },\r\n\r\n _logLookForVariable: function(args, variable) {\r\n var res = [];\r\n for (var key in args) {\r\n if (args[key] === variable) {\r\n res.push(key);\r\n }\r\n }\r\n return res;\r\n },\r\n\r\n getNode: function(/*name, arg1, etc*/) {\r\n var n = factory.getNode.apply(factory, arguments);\r\n if (!n) notify.error('Unknown Node type : ' + arguments[0]);\r\n var cacheID = n.getID();\r\n this._activeNodeMap[cacheID] = n;\r\n return n;\r\n },\r\n\r\n getVariable: function(nameID) {\r\n return this._variables[nameID];\r\n },\r\n\r\n getAttributeType: function(type) {\r\n for (var i = 0; i < this._attributes.length; i++) {\r\n if (this._attributes[i].getType() === type) return this._attributes[i];\r\n }\r\n return undefined;\r\n },\r\n\r\n // TODO: add Precision qualifier\r\n // if doesn't exist create a new on\r\n // if nameID given and var already exist, create a varname +\r\n createVariable: function(type, varname, deepness) {\r\n var nameID = varname;\r\n\r\n if (nameID === undefined) {\r\n var len = window.Object.keys(this._variables).length;\r\n nameID = 'tmp_' + len;\r\n } else if (this._variables[nameID]) {\r\n // create a new variable\r\n // if we want to reuse a variable we should NOT\r\n // call this function in the first place and do the\r\n // test before...\r\n // however for uniform, varying and sampler, we return\r\n // the variable if it already exists, because they are\r\n // meant to be read only\r\n nameID = nameID + deepness;\r\n if (deepness === undefined) {\r\n return this.createVariable(type, varname, 1);\r\n } else if (this._variables[nameID]) {\r\n deepness++;\r\n return this.createVariable(type, varname, deepness);\r\n }\r\n }\r\n\r\n var v = this.getNode('Variable', type, nameID);\r\n this._variables[nameID] = v;\r\n return v;\r\n },\r\n\r\n getOrCreateUniform: function(type, varname, size) {\r\n var nameID = varname;\r\n\r\n // accept uniform as parameter to simplify code\r\n if (type instanceof Uniform) {\r\n var uniform = type;\r\n type = uniform.getType();\r\n nameID = uniform.getName();\r\n } else if (nameID === undefined) {\r\n this.logError('Cannot create unamed Uniform');\r\n }\r\n\r\n var exist = this._variables[nameID];\r\n if (exist) {\r\n if (exist.getType() === type) {\r\n return exist;\r\n }\r\n\r\n /*develblock:start*/\r\n // texture has a particular \"dual\" type of uniform a sampler2D\r\n // a int pointing to the texture unit the sampler2D represents\r\n if (exist.getType() === 'sampler2D' && type !== 'sampler2D') {\r\n this.logError(\r\n 'Same uniform, but different type (' +\r\n type +\r\n ', ' +\r\n exist.getType() +\r\n ', ' +\r\n exist.getVariable() +\r\n ')'\r\n );\r\n }\r\n /*develblock:end*/\r\n }\r\n\r\n var v = this.getNode('Uniform', type, nameID, size);\r\n this._variables[nameID] = v;\r\n\r\n return v;\r\n },\r\n\r\n // make sure we get correct Node\r\n getOrCreateSampler: function(type, varname) {\r\n if (varname === undefined) {\r\n this.logError('No name given for sampler type : ' + type);\r\n }\r\n\r\n var exist = this._variables[varname];\r\n if (exist) {\r\n return exist; // see comment in Variable function\r\n }\r\n\r\n var v = this.getNode('Sampler', type, varname);\r\n this._variables[varname] = v;\r\n\r\n return v;\r\n },\r\n\r\n // make sure we get correct Node\r\n getOrCreateAttribute: function(type, nameID) {\r\n if (this._fragmentShaderMode) {\r\n this.logError('No Vertex Attribute in Fragment Shader');\r\n }\r\n\r\n var exist = this._variables[nameID];\r\n if (exist) {\r\n /*develblock:start*/\r\n if (exist.getType() !== type) {\r\n this.logError('Same attribute, but different type');\r\n }\r\n /*develblock:end*/\r\n\r\n return exist;\r\n }\r\n\r\n var v = this.getNode('Attribute', type, nameID);\r\n this._variables[nameID] = v;\r\n return v;\r\n },\r\n\r\n getOrCreateConstant: function(type, varname) {\r\n var nameID = varname;\r\n if (nameID === undefined) {\r\n // TODO: temp constant ? or enforcing reuse ?\r\n // maybe could parse variable to find other constant\r\n // but would need having scope info\r\n var len = window.Object.keys(this._variables).length;\r\n nameID = 'tmp_' + len;\r\n } else {\r\n var exist = this._variables[nameID];\r\n if (exist) {\r\n /*develblock:start*/\r\n if (exist.getType() !== type) {\r\n this.logError('Same constant name, but different type');\r\n }\r\n /*develblock:end*/\r\n\r\n // see comment in Variable function\r\n return exist;\r\n }\r\n }\r\n\r\n var v = this.getNode('Constant', type, nameID);\r\n this._variables[nameID] = v;\r\n return v;\r\n },\r\n\r\n // make sure we get correct Node\r\n getOrCreateVarying: function(type, nameID) {\r\n if (nameID === undefined) {\r\n this.logError('Error: Mandatory to name varying (as you need to retrieve them)');\r\n }\r\n\r\n var variable = this._variables[nameID];\r\n if (variable) {\r\n if (!this._varyings[nameID]) {\r\n this.logError(\r\n 'Error: requesting a varying not declared with getOrCreateVarying previously'\r\n );\r\n }\r\n\r\n if (variable.getType() !== type) {\r\n this.logError('Error: Same varying, but different type');\r\n }\r\n\r\n return variable;\r\n }\r\n\r\n // if it's not in Varying Cache, but requested from vertex shader it means => error\r\n if (!this._fragmentShaderMode && !this._customFragmentShader) {\r\n this.logError(\r\n 'Error: requesting a varying not declared in Fragment Shader Graph (for Custom Vertex Shader, add this._customFragmentShader to the processor): ' +\r\n nameID +\r\n ' ' +\r\n type\r\n );\r\n }\r\n\r\n variable = this._variables[nameID] = this._varyings[nameID] = this.getNode(\r\n 'Varying',\r\n type,\r\n nameID\r\n );\r\n\r\n return variable;\r\n },\r\n\r\n //////////////////\r\n // TRAVERSE STUFFS\r\n //////////////////\r\n\r\n markNodeAsVisited: function(n) {\r\n var cacheID = n.getID();\r\n if (this._activeNodeMap[cacheID] === n) {\r\n this._compiledNodeMap[cacheID] = n;\r\n } else {\r\n this.logWarn(\r\n 'Node not requested by using Compiler getNode and/or not registered in nodeFactory ' +\r\n n.toString()\r\n );\r\n }\r\n },\r\n\r\n // make sure we traverse once per evaluation of graph\r\n checkOrMarkNodeAsTraversed: function(n) {\r\n var cacheID = n.getID();\r\n if (this._traversedNodeMap[cacheID]) {\r\n return true;\r\n }\r\n this._traversedNodeMap[cacheID] = n;\r\n return false;\r\n },\r\n\r\n // TODO: add a visitor to debug the graph\r\n traverse: function(functor, node) {\r\n if (this.checkOrMarkNodeAsTraversed(node)) return;\r\n\r\n var inputs = node.getInputs();\r\n if (!Array.isArray(inputs)) {\r\n var objectToArray = [];\r\n for (var keyInput in inputs) {\r\n objectToArray.push(inputs[keyInput]);\r\n }\r\n inputs = objectToArray;\r\n }\r\n\r\n for (var i = 0, l = inputs.length; i < l; i++) {\r\n node.checkInputsOutputs();\r\n\r\n var child = inputs[i];\r\n if (child && child !== node) {\r\n this.traverse(functor, child);\r\n }\r\n }\r\n functor.call(functor, node);\r\n\r\n // keep trace we visited\r\n this.markNodeAsVisited(node);\r\n },\r\n\r\n _getAndInitFunctor: function(func) {\r\n this._traversedNodeMap = {};\r\n\r\n var map = {};\r\n var text = [];\r\n func = func.bind(this, map, text);\r\n func._map = map;\r\n func._text = text;\r\n\r\n return func;\r\n },\r\n\r\n _functorEvaluateAndGatherField: function(field, map, text, node) {\r\n var idx = node.getType();\r\n if (idx === undefined || idx === '') {\r\n this.logError('Your node ' + node + ' has no type');\r\n }\r\n\r\n if (!node[field] || map[idx]) return;\r\n map[idx] = true;\r\n\r\n Array.prototype.push.apply(text, node[field]());\r\n },\r\n\r\n // Gather a particular output field\r\n // for now one of\r\n // ['define', 'extensions']\r\n //\r\n // from a nodeGraph\r\n //\r\n // In case a node of same Type have different outputs (shadow with different defines)\r\n // it use ID rather than Type as map index UNIQUE PER TYPE\r\n // TODO: adds includes so that we can remove it from the eval Global Functions ?\r\n evaluateAndGatherField: function(nodes, field) {\r\n var func = this._getAndInitFunctor(this._functorEvaluateAndGatherField.bind(this, field));\r\n\r\n for (var j = 0, jl = nodes.length; j < jl; j++) {\r\n this.traverse(func, nodes[j]);\r\n }\r\n\r\n return func._text;\r\n },\r\n\r\n _functorEvaluateGlobalFunctionDeclaration: function(map, text, node) {\r\n // UNIQUE PER TYPE\r\n var idx = node.getType();\r\n if (idx === undefined || idx === '') {\r\n this.logError('Your node ' + node + ' has no type');\r\n }\r\n\r\n if (!node.globalFunctionDeclaration || map[idx]) return;\r\n map[idx] = true;\r\n\r\n var decl = node.globalFunctionDeclaration();\r\n if (decl) text.push(decl);\r\n },\r\n\r\n // Gather a functions declartions of nodesfrom a nodeGraph\r\n // (for now pragma include done here too. could be done with define/etc...)\r\n // Node of same Type has to share exact same \"node.globalFunctionDeclaration\" output\r\n // as it use Type rather than ID as map index\r\n evaluateGlobalFunctionDeclaration: function(nodes) {\r\n var func = this._getAndInitFunctor(this._functorEvaluateGlobalFunctionDeclaration);\r\n\r\n for (var j = 0, jl = nodes.length; j < jl; j++) {\r\n this.traverse(func, nodes[j]);\r\n }\r\n\r\n return func._text.join('\\n');\r\n },\r\n\r\n _functorEvaluateGlobalVariableDeclaration: function(map, text, node) {\r\n // UNIQUE PER NODE\r\n var idx = node.getID();\r\n if (!node.globalDeclaration || map[idx]) return;\r\n map[idx] = true;\r\n\r\n var decl = node.globalDeclaration();\r\n if (decl) text.push(decl);\r\n },\r\n\r\n // Gather a Variables declarations of nodes from a nodeGraph to be outputted\r\n // outside the VOID MAIN code ( Uniforms, Varying )\r\n // Node of same Type has different output as it use Type rather than ID as map index\r\n evaluateGlobalVariableDeclaration: function(nodes) {\r\n var func = this._getAndInitFunctor(this._functorEvaluateGlobalVariableDeclaration);\r\n\r\n var i = 0;\r\n var nbNodes = nodes.length;\r\n for (i = 0; i < nbNodes; i++) {\r\n this.traverse(func, nodes[i]);\r\n }\r\n\r\n // beautify/formatting with empty line between type of var\r\n var declarations = func._text;\r\n var len = declarations.length;\r\n if (len > 0) {\r\n this.sortDeclarations(declarations);\r\n\r\n var type = declarations[0][0];\r\n for (i = 0; i < len; ++i) {\r\n var iType = declarations[i][0];\r\n if (iType !== type) {\r\n type = iType;\r\n declarations[i - 1] += '\\n';\r\n }\r\n }\r\n }\r\n\r\n return declarations.join('\\n');\r\n },\r\n\r\n sortDeclarations: function(declarations) {\r\n // sort in alphabetical order attr, unif, sample, varying\r\n declarations.sort();\r\n\r\n if (this._fragmentShaderMode) return;\r\n\r\n // making sure Vertex is always coming first (because of webgl warning)\r\n for (var i = 0, len = declarations.length; i < len; ++i) {\r\n var vatt = declarations[i];\r\n\r\n if (vatt[0] !== 'a') break;\r\n\r\n if (vatt.indexOf('Vertex') !== -1) {\r\n declarations.splice(i, 1);\r\n declarations.unshift(vatt);\r\n break;\r\n }\r\n }\r\n },\r\n\r\n _functorEvaluate: function(map, text, node) {\r\n var id = node.getID();\r\n if (map[id]) return;\r\n map[id] = true;\r\n\r\n var shader = node.computeShader();\r\n if (!shader) return;\r\n\r\n var comment = node.getComment && node.getComment();\r\n if (comment) text.push(comment);\r\n text.push(shader);\r\n },\r\n\r\n evaluate: function(nodes) {\r\n var func = this._getAndInitFunctor(this._functorEvaluate);\r\n\r\n for (var j = 0, jl = nodes.length; j < jl; j++) {\r\n this.traverse(func, nodes[j]);\r\n }\r\n\r\n return func._text.join('\\n');\r\n },\r\n\r\n evaluateDefines: function(roots) {\r\n return this.evaluateAndGatherField(roots, 'getDefines');\r\n },\r\n\r\n evaluateExtensions: function(roots) {\r\n return this.evaluateAndGatherField(roots, 'getExtensions');\r\n },\r\n\r\n /////////////////////\r\n // Model space varying\r\n /////////////////////\r\n getOrCreateModelVertex: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec3', 'vModelVertex');\r\n }\r\n\r\n var out = this._variables.modelVertex;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'modelVertex');\r\n\r\n this.getNode('MatrixMultPosition')\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat4', 'uModelMatrix'),\r\n vec: this.getOrCreateLocalVertex()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateModelNormal: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec3', 'vModelNormal');\r\n }\r\n\r\n var out = this._variables.modelNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'modelNormal');\r\n\r\n this.getNode('MatrixMultDirection')\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat3', 'uModelNormalMatrix'),\r\n vec: this.getOrCreateLocalNormal()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateModelTangent: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec4', 'vModelTangent');\r\n }\r\n\r\n var out = this._variables.modelTangent;\r\n if (out) return out;\r\n out = this.createVariable('vec4', 'modelTangent');\r\n\r\n this.getNode('MatrixMultDirection')\r\n .setOverwriteW(false)\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat3', 'uModelNormalMatrix'),\r\n vec: this.getOrCreateLocalTangent()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n },\r\n\r\n /////////////////////\r\n // View space varying\r\n /////////////////////\r\n getOrCreateViewVertex: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec4', 'vViewVertex');\r\n }\r\n\r\n var out = this._variables.viewVertex;\r\n if (out) return out;\r\n out = this.createVariable('vec4', 'viewVertex');\r\n\r\n this.getNode('MatrixMultPosition')\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat4', 'uModelViewMatrix'),\r\n vec: this.getOrCreateLocalVertex()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateViewNormal: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec3', 'vViewNormal');\r\n }\r\n\r\n var out = this._variables.viewNormal;\r\n if (out) return out;\r\n out = this.createVariable('vec3', 'viewNormal');\r\n\r\n this.getNode('MatrixMultDirection')\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat3', 'uModelViewNormalMatrix'),\r\n vec: this.getOrCreateLocalNormal()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n },\r\n\r\n getOrCreateViewTangent: function() {\r\n if (this._fragmentShaderMode) {\r\n return this.getOrCreateVarying('vec4', 'vViewTangent');\r\n }\r\n\r\n var out = this._variables.viewTangent;\r\n if (out) return out;\r\n out = this.createVariable('vec4', 'viewTangent');\r\n\r\n this.getNode('MatrixMultDirection')\r\n .setOverwriteW(false)\r\n .inputs({\r\n matrix: this.getOrCreateUniform('mat3', 'uModelViewNormalMatrix'),\r\n vec: this.getOrCreateLocalTangent()\r\n })\r\n .outputs({ vec: out });\r\n\r\n return out;\r\n }\r\n});\r\n\r\nexport default Compiler;\r\n","import utils from './utils';\r\nimport Node from './Node';\r\nimport NodeVisitor from './NodeVisitor';\r\n\r\n/**\r\n * Switch that can switch on and off separate children\r\n * @class Switch\r\n */\r\nvar Switch = function() {\r\n Node.call(this);\r\n // This list of bools is effectively a bit mask.\r\n this._values = [];\r\n};\r\n\r\n/** @lends Switch.prototype */\r\nutils.createPrototypeNode(\r\n Switch,\r\n utils.objectInherit(Node.prototype, {\r\n addChild: function(node, value) {\r\n Node.prototype.addChild.call(this, node);\r\n\r\n if (value === undefined) value = true;\r\n\r\n if (this.children.length > this._values.length) {\r\n this._values.push(value);\r\n } else {\r\n this._values[this.children.length - 1] = value;\r\n }\r\n return true;\r\n },\r\n\r\n setValue: function(index, value) {\r\n if (index < this._values.length) {\r\n this._values[index] = value;\r\n }\r\n },\r\n\r\n getValue: function(index) {\r\n if (index < this._values.length) {\r\n return this._values[index];\r\n }\r\n },\r\n\r\n setAllChildrenOff: function() {\r\n for (var i = 0; i < this._values.length; ++i) {\r\n this._values[i] = false;\r\n }\r\n },\r\n\r\n setAllChildrenOn: function() {\r\n for (var i = 0; i < this._values.length; ++i) {\r\n this._values[i] = true;\r\n }\r\n },\r\n\r\n traverse: (function() {\r\n return function(visitor) {\r\n var traversalMode = visitor.traversalMode;\r\n\r\n switch (traversalMode) {\r\n case NodeVisitor.TRAVERSE_ALL_CHILDREN:\r\n for (var i = 0; i < this.children.length; ++i) {\r\n this.children[i].accept(visitor);\r\n }\r\n break;\r\n\r\n case NodeVisitor.TRAVERSE_ACTIVE_CHILDREN:\r\n var numChildren = this.children.length;\r\n if (this._values.length < numChildren) numChildren = this._values.length;\r\n\r\n for (i = 0; i < numChildren; ++i) {\r\n if (this._values[i] === true) {\r\n this.children[i].accept(visitor);\r\n }\r\n }\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'Switch'\r\n);\r\n\r\nexport default Switch;","import { mat4 } from './glMatrix';\r\nimport TransformEnums from './transformEnums';\r\n\r\nvar computeLocalToWorld = function(nodePath, ignoreCameras, userMatrix, nodePathIndex) {\r\n var ignoreCamera = ignoreCameras;\r\n var nodePathLength = nodePathIndex !== undefined ? nodePathIndex : nodePath.length;\r\n if (ignoreCamera === undefined) ignoreCamera = true;\r\n\r\n var matrix = userMatrix || mat4.create();\r\n\r\n var j = 0;\r\n\r\n if (ignoreCamera) {\r\n for (j = nodePathLength - 1; j >= 0; j--) {\r\n var camera = nodePath[j];\r\n\r\n if (\r\n camera.className() === 'Camera' &&\r\n (camera.getReferenceFrame() !== TransformEnums.RELATIVE_RF ||\r\n camera.getParents().length === 0)\r\n ) {\r\n break;\r\n }\r\n }\r\n\r\n // because when we break it's to an index - 1\r\n // it works because if nothing camera found j == -1 at the end of the loop\r\n // and if we found a camera we want to start at the camera index + 1\r\n j += 1;\r\n }\r\n\r\n for (var i = j, l = nodePathLength; i < l; i++) {\r\n var node = nodePath[i];\r\n\r\n if (node.computeLocalToWorldMatrix) {\r\n node.computeLocalToWorldMatrix(matrix);\r\n }\r\n }\r\n\r\n return matrix;\r\n};\r\n\r\nexport default {\r\n computeLocalToWorld: computeLocalToWorld\r\n};","import utils from './utils';\r\nimport notify from './notify';\r\nimport Object from './Object';\r\nimport osgMath from './math';\r\nimport PooledResource from './PooledResource';\r\nimport PooledArray from './PooledArray';\r\nimport PooledMap from './PooledMap';\r\n\r\nvar createPositionAttribute = function() {\r\n return [null, null];\r\n};\r\n\r\n/**\r\n * RenderBin base class. Renderbin contains geometries to be rendered as a group,\r\n * renderbins are rendered once each. They can improve efficiency or\r\n * use different rendering algorithms.\r\n * A renderBin can contain further renderBins producing a tree hierarchy of renderBins.\r\n *\r\n * https://github.com/openscenegraph/osg/blob/master/include/osgUtil/RenderBin#L27-L32\r\n */\r\nvar RenderBin = function(sortMode) {\r\n Object.call(this);\r\n\r\n this._renderStage = undefined;\r\n this._parent = undefined;\r\n this._binNum = 0;\r\n this._sorted = false;\r\n this._sortMode = sortMode !== undefined ? sortMode : RenderBin.defaultSortMode;\r\n this._drawCallback = undefined;\r\n this._leafs = [];\r\n this._pooledPositionedAttribute = new PooledResource(createPositionAttribute);\r\n this._positionedAttribute = new PooledArray();\r\n this._stateGraphList = new PooledArray();\r\n this._bins = new PooledMap();\r\n RenderBin.prototype.init.call(this, sortMode);\r\n};\r\n\r\nRenderBin.SORT_BY_STATE = 0;\r\nRenderBin.SORT_BACK_TO_FRONT = 1;\r\nRenderBin.SORT_FRONT_TO_BACK = 2;\r\n\r\n// change it at runtime for default RenderBin if needed\r\nRenderBin.defaultSortMode = RenderBin.SORT_BY_STATE;\r\n\r\nvar createRenderBin = function() {\r\n return new RenderBin();\r\n};\r\nvar pooledRenderBin = new PooledResource(createRenderBin);\r\n\r\nRenderBin.BinPrototypes = {\r\n RenderBin: function() {\r\n return pooledRenderBin.getOrCreateObject().init();\r\n },\r\n DepthSortedBin: function() {\r\n return pooledRenderBin.getOrCreateObject().init(RenderBin.SORT_BACK_TO_FRONT);\r\n }\r\n};\r\n\r\nvar sortBackToFrontFunction = function(a, b) {\r\n return b._depth - a._depth;\r\n};\r\n\r\nvar sortFrontToBackFunction = function(a, b) {\r\n return a._depth - b._depth;\r\n};\r\n\r\nvar sortBinNumberFunction = function(a, b) {\r\n return a._binNum - b._binNum;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n RenderBin,\r\n utils.objectInherit(Object.prototype, {\r\n init: function(sortMode) {\r\n this._renderStage = undefined;\r\n this._parent = undefined;\r\n this._binNum = 0;\r\n this._sortMode = sortMode !== undefined ? sortMode : RenderBin.defaultSortMode;\r\n this._drawCallback = undefined;\r\n RenderBin.prototype._initInternal.call(this);\r\n return this;\r\n },\r\n _initInternal: function() {\r\n this._bins.reset();\r\n this._stateGraphList.reset();\r\n this._positionedAttribute.reset();\r\n this._pooledPositionedAttribute.reset();\r\n this._leafs.length = 0;\r\n this._sorted = false;\r\n },\r\n _createRenderBin: function(binName) {\r\n // default render bin constructor\r\n var renderBinConstructor = RenderBin.BinPrototypes.RenderBin;\r\n\r\n if (binName && RenderBin.BinPrototypes[binName])\r\n renderBinConstructor = RenderBin.BinPrototypes[binName];\r\n\r\n return renderBinConstructor();\r\n },\r\n\r\n addPositionAttribute: function(m, attribute) {\r\n var pa = this._pooledPositionedAttribute.getOrCreateObject();\r\n pa[0] = m;\r\n pa[1] = attribute;\r\n this._positionedAttribute.push(pa);\r\n },\r\n\r\n getStateGraphList: function() {\r\n return this._stateGraphList;\r\n },\r\n\r\n getPositionedAttribute: function() {\r\n return this._positionedAttribute;\r\n },\r\n\r\n copyLeavesFromStateGraphListToRenderLeafList: function() {\r\n this._leafs.length = 0;\r\n var detectedNaN = false;\r\n\r\n var stateGraphList = this._stateGraphList.getArray();\r\n var stateGraphListLength = this._stateGraphList.getLength();\r\n for (var i = 0; i < stateGraphListLength; i++) {\r\n var leafs = stateGraphList[i]._leafs;\r\n var leafsArray = leafs.getArray();\r\n var leafsArrayLength = leafs.getLength();\r\n for (var j = 0; j < leafsArrayLength; j++) {\r\n var leaf = leafsArray[j];\r\n if (osgMath.isNaN(leaf._depth)) {\r\n detectedNaN = true;\r\n } else {\r\n this._leafs.push(leaf);\r\n }\r\n }\r\n }\r\n\r\n if (detectedNaN) {\r\n notify.debug(\r\n 'warning: RenderBin::copyLeavesFromStateGraphListToRenderLeafList() detected NaN depth values, database may be corrupted.'\r\n );\r\n }\r\n // empty the render graph list to prevent it being drawn along side the render leaf list (see drawImplementation.)\r\n this._stateGraphList.reset();\r\n },\r\n\r\n getSortMode: function() {\r\n return this._sortMode;\r\n },\r\n\r\n sortBackToFront: function() {\r\n this.copyLeavesFromStateGraphListToRenderLeafList();\r\n this._leafs.sort(sortBackToFrontFunction);\r\n },\r\n\r\n sortFrontToBack: function() {\r\n this.copyLeavesFromStateGraphListToRenderLeafList();\r\n this._leafs.sort(sortFrontToBackFunction);\r\n },\r\n\r\n sortImplementation: function() {\r\n var SortMode = RenderBin;\r\n switch (this._sortMode) {\r\n case SortMode.SORT_BACK_TO_FRONT:\r\n this.sortBackToFront();\r\n break;\r\n case SortMode.SORT_FRONT_TO_BACK:\r\n this.sortFrontToBack();\r\n break;\r\n case SortMode.SORT_BY_STATE:\r\n // do nothing\r\n break;\r\n }\r\n },\r\n\r\n sort: function() {\r\n if (this._sorted) return;\r\n\r\n var binsKeys = this._bins.getKeys();\r\n var binsMap = this._bins.getMap();\r\n var binsKeysArray = binsKeys.getArray();\r\n var binsKeysArrayLength = binsKeys.getLength();\r\n for (var i = 0; i < binsKeysArrayLength; i++) {\r\n var keyBin = binsKeysArray[i];\r\n binsMap[keyBin].sort();\r\n }\r\n this.sortImplementation();\r\n\r\n this._sorted = true;\r\n },\r\n\r\n setParent: function(parent) {\r\n this._parent = parent;\r\n },\r\n\r\n getParent: function() {\r\n return this._parent;\r\n },\r\n\r\n getBinNumber: function() {\r\n return this._binNum;\r\n },\r\n\r\n findOrInsert: function(binNum, binName) {\r\n var bins = this._bins.getMap();\r\n var bin = bins[binNum];\r\n\r\n if (!bin) {\r\n bin = this._createRenderBin(binName);\r\n bin._parent = this;\r\n bin._binNum = binNum;\r\n bin._renderStage = this._renderStage;\r\n this._bins.set(binNum, bin);\r\n }\r\n return bin;\r\n },\r\n\r\n getStage: function() {\r\n return this._renderStage;\r\n },\r\n\r\n addStateGraph: function(sg) {\r\n this._stateGraphList.push(sg);\r\n },\r\n\r\n reset: function() {\r\n RenderBin.prototype._initInternal.call(this);\r\n },\r\n\r\n draw: function(state, previousRenderLeaf) {\r\n var previousLeaf = previousRenderLeaf;\r\n // use callback drawImplementation if exist\r\n if (this._drawCallback && this._drawCallback.drawImplementation) {\r\n previousLeaf = this._drawCallback.drawImplementation(this, state, previousLeaf);\r\n } else {\r\n previousLeaf = this.drawImplementation(state, previousLeaf);\r\n }\r\n\r\n return previousLeaf;\r\n },\r\n\r\n applyPositionedAttribute: function(state, positionedAttributes) {\r\n // the idea is to set uniform 'globally' in uniform map.\r\n var elements = positionedAttributes.getArray();\r\n var length = positionedAttributes.getLength();\r\n for (var index = 0, l = length; index < l; index++) {\r\n var element = elements[index];\r\n // add or set uniforms in state\r\n var stateAttribute = element[1];\r\n var matrix = element[0];\r\n state.setGlobalDefaultAttribute(stateAttribute);\r\n stateAttribute.apply(state);\r\n stateAttribute.applyPositionedUniform(matrix, state);\r\n state.haveAppliedAttribute(stateAttribute);\r\n }\r\n },\r\n\r\n drawImplementation: function(state, previousRenderLeaf) {\r\n var previousLeaf = previousRenderLeaf;\r\n\r\n var binsArray = [];\r\n\r\n var bins = this._bins.getMap();\r\n var binsKeys = this._bins.getKeys();\r\n var binsKeysLength = binsKeys.getLength();\r\n var binsKeysArray = binsKeys.getArray();\r\n for (var i = 0; i < binsKeysLength; i++) {\r\n var keyBin = binsKeysArray[i];\r\n binsArray.push(bins[keyBin]);\r\n }\r\n binsArray.sort(sortBinNumberFunction);\r\n\r\n var current = 0;\r\n var end = binsArray.length;\r\n\r\n var bin;\r\n // draw pre bins\r\n for (; current < end; current++) {\r\n bin = binsArray[current];\r\n if (bin.getBinNumber() > 0) {\r\n break;\r\n }\r\n previousLeaf = bin.draw(state, previousLeaf);\r\n }\r\n\r\n // draw leafs\r\n previousLeaf = this.drawLeafs(state, previousLeaf);\r\n\r\n // draw post bins\r\n for (; current < end; current++) {\r\n bin = binsArray[current];\r\n previousLeaf = bin.draw(state, previousLeaf);\r\n }\r\n return previousLeaf;\r\n },\r\n\r\n drawLeafs: function(state, previousRenderLeaf) {\r\n var stateList = this._stateGraphList.getArray();\r\n var stateListLength = this._stateGraphList.getLength();\r\n var leafs = this._leafs;\r\n var previousLeaf = previousRenderLeaf;\r\n var leaf;\r\n\r\n // draw fine grained ordering.\r\n for (var d = 0, dl = leafs.length; d < dl; d++) {\r\n leaf = leafs[d];\r\n leaf.render(state, previousLeaf);\r\n previousLeaf = leaf;\r\n }\r\n\r\n // draw coarse grained ordering.\r\n for (var i = 0, l = stateListLength; i < l; i++) {\r\n var sg = stateList[i];\r\n var leafArray = sg._leafs.getArray();\r\n var leafArrayLength = sg._leafs.getLength();\r\n for (var j = 0; j < leafArrayLength; j++) {\r\n leaf = leafArray[j];\r\n leaf.render(state, previousLeaf);\r\n previousLeaf = leaf;\r\n }\r\n }\r\n return previousLeaf;\r\n }\r\n }),\r\n 'osg',\r\n 'RenderBin'\r\n);\r\n\r\nRenderBin.reset = function() {\r\n pooledRenderBin.reset();\r\n};\r\n\r\nRenderBin.clean = function() {\r\n pooledRenderBin.clean();\r\n};\r\n\r\nexport default RenderBin;","import utils from './utils';\r\nimport PooledArray from './PooledArray';\r\nimport PooledMap from './PooledMap';\r\nimport PooledResource from './PooledResource';\r\n\r\nvar StateGraph = function() {\r\n this._depth = 0;\r\n this._children = new PooledMap();\r\n this._leafs = new PooledArray();\r\n this._stateset = undefined;\r\n this._parent = undefined;\r\n};\r\n\r\nvar createStateGraph = function() {\r\n return new StateGraph();\r\n};\r\n\r\nStateGraph.pooledStateGraph = new PooledResource(createStateGraph);\r\nStateGraph.statsNbMoveStateGraph = 0;\r\n\r\nStateGraph.reset = function() {\r\n StateGraph.pooledStateGraph.reset();\r\n StateGraph.statsNbMoveStateGraph = 0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n StateGraph, {\r\n clean: function() {\r\n this._leafs.reset();\r\n this._children.reset();\r\n this._depth = 0;\r\n this._stateset = undefined;\r\n this._parent = undefined;\r\n },\r\n getStateSet: function() {\r\n return this._stateset;\r\n },\r\n getLeafs: function() {\r\n return this._leafs;\r\n },\r\n getParent: function() {\r\n return this._parent;\r\n },\r\n findOrInsert: function(stateset) {\r\n // nb call per frame as example: 22 (shadowmap) 55 (pbr) to 512 (performance)\r\n // it's called by node that have a stateSet\r\n var stateSetID = stateset.getInstanceID();\r\n var childrenMap = this._children.getMap();\r\n var sg = childrenMap[stateSetID];\r\n if (!sg) {\r\n sg = StateGraph.pooledStateGraph.getOrCreateObject();\r\n sg.clean();\r\n\r\n sg._parent = this;\r\n sg._depth = this._depth + 1;\r\n sg._stateset = stateset;\r\n this._children.set(stateSetID, sg);\r\n }\r\n\r\n return sg;\r\n }\r\n },\r\n 'osg',\r\n 'StateGraph'\r\n);\r\n\r\nStateGraph.moveStateGraph = (function() {\r\n var stack = new PooledArray();\r\n var stackArray = stack.getArray();\r\n return function(state, sgCurrentArg, sgNewArg) {\r\n StateGraph.statsNbMoveStateGraph++;\r\n // nb call per frame: 3 (pbr) 10 (shadowmap) 1(performance)\r\n\r\n stack.reset();\r\n var sgNew = sgNewArg;\r\n var sgCurrent = sgCurrentArg;\r\n var i, l;\r\n if (sgNew === sgCurrent || sgNew === undefined) return;\r\n\r\n if (sgCurrent === undefined) {\r\n // push stateset from sgNew to root, and apply\r\n // stateset from root to sgNew\r\n do {\r\n if (sgNew._stateset !== undefined) {\r\n stack.push(sgNew._stateset);\r\n }\r\n sgNew = sgNew._parent;\r\n } while (sgNew);\r\n\r\n for (i = stack._length - 1, l = 0; i >= l; --i) {\r\n state.pushStateSet(stackArray[i]);\r\n }\r\n return;\r\n } else if (sgCurrent._parent === sgNew._parent) {\r\n // first handle the typical case which is two state groups\r\n // are neighbours.\r\n\r\n // state has changed so need to pop old state.\r\n if (sgCurrent._stateset !== undefined) {\r\n state.popStateSet();\r\n }\r\n // and push new state.\r\n if (sgNew._stateset !== undefined) {\r\n state.pushStateSet(sgNew._stateset);\r\n }\r\n return;\r\n }\r\n\r\n // need to pop back up to the same depth as the new state group.\r\n while (sgCurrent._depth > sgNew._depth) {\r\n if (sgCurrent._stateset !== undefined) {\r\n state.popStateSet();\r\n }\r\n sgCurrent = sgCurrent._parent;\r\n }\r\n\r\n // use return path to trace back steps to sgNew.\r\n stack.reset();\r\n\r\n // need to pop back up to the same depth as the curr state group.\r\n while (sgNew._depth > sgCurrent._depth) {\r\n if (sgNew._stateset !== undefined) {\r\n stack.push(sgNew._stateset);\r\n }\r\n sgNew = sgNew._parent;\r\n }\r\n\r\n // now pop back up both parent paths until they agree.\r\n\r\n // DRT - 10/22/02\r\n // should be this to conform with above case where two StateGraph\r\n // nodes have the same parent\r\n while (sgCurrent !== sgNew) {\r\n if (sgCurrent._stateset !== undefined) {\r\n state.popStateSet();\r\n }\r\n sgCurrent = sgCurrent._parent;\r\n\r\n if (sgNew._stateset !== undefined) {\r\n stack.push(sgNew._stateset);\r\n }\r\n sgNew = sgNew._parent;\r\n }\r\n\r\n for (i = stack._length - 1, l = 0; i >= l; --i) {\r\n state.pushStateSet(stackArray[i]);\r\n }\r\n };\r\n})();\r\n\r\nexport default StateGraph;","import StateGraph from './StateGraph';\r\n\r\n// just use inline function, it's faster than having the test in the code\r\nvar applyUniformCache = [\r\n // apply just modelview and projection\r\n function(state, modelview, model, view, projection) {\r\n state.applyModelViewMatrix(modelview, model);\r\n state.applyProjectionMatrix(projection);\r\n },\r\n\r\n // apply model\r\n function(state, modelview, model, view, projection) {\r\n var gl = state.getGraphicContext();\r\n var matrixModelViewChanged = state.applyModelViewMatrix(modelview, model);\r\n state.applyProjectionMatrix(projection);\r\n\r\n if (matrixModelViewChanged) {\r\n var modelMatrix = state._modelMatrix;\r\n modelMatrix.setMatrix4(model);\r\n modelMatrix.apply(gl, this.modelUniform);\r\n }\r\n },\r\n\r\n // apply view\r\n function(state, modelview, model, view, projection) {\r\n var gl = state.getGraphicContext();\r\n var matrixModelViewChanged = state.applyModelViewMatrix(modelview, model);\r\n state.applyProjectionMatrix(projection);\r\n\r\n if (matrixModelViewChanged) {\r\n var viewMatrix = state._viewMatrix;\r\n viewMatrix.setMatrix4(view);\r\n viewMatrix.apply(gl, this.viewUniform);\r\n }\r\n },\r\n\r\n // applyModelAndViewUniform\r\n function(state, modelview, model, view, projection) {\r\n var gl = state.getGraphicContext();\r\n var matrixModelViewChanged = state.applyModelViewMatrix(modelview, model);\r\n state.applyProjectionMatrix(projection);\r\n\r\n if (matrixModelViewChanged) {\r\n var modelMatrix = state._modelMatrix;\r\n modelMatrix.setMatrix4(model);\r\n modelMatrix.apply(gl, this.modelUniform);\r\n\r\n var viewMatrix = state._viewMatrix;\r\n viewMatrix.setMatrix4(view);\r\n viewMatrix.apply(gl, this.viewUniform);\r\n }\r\n }\r\n];\r\n\r\nvar CacheUniformApply = function(state, program) {\r\n this.modelUniform = program._uniformsCache[state._modelMatrix.getName()];\r\n this.viewUniform = program._uniformsCache[state._viewMatrix.getName()];\r\n\r\n var cacheIndex = 0;\r\n if (this.modelUniform) cacheIndex = 1;\r\n if (this.viewUniform) cacheIndex |= 2;\r\n\r\n this.apply = applyUniformCache[cacheIndex];\r\n};\r\n\r\nvar RenderLeaf = function() {\r\n this._parent = undefined;\r\n this._geometry = undefined;\r\n this._depth = 0.0;\r\n\r\n this._projection = undefined;\r\n this._view = undefined;\r\n this._model = undefined;\r\n this._modelView = undefined;\r\n};\r\n\r\nRenderLeaf.prototype = {\r\n reset: function() {\r\n this._parent = undefined;\r\n this._geometry = undefined;\r\n this._depth = 0.0;\r\n\r\n this._projection = undefined;\r\n this._view = undefined;\r\n this._model = undefined;\r\n this._modelView = undefined;\r\n },\r\n\r\n init: function(parent, geom, projection, view, modelView, model, depth) {\r\n this._parent = parent;\r\n this._geometry = geom;\r\n this._depth = depth;\r\n\r\n this._projection = projection;\r\n this._view = view;\r\n this._model = model;\r\n this._modelView = modelView;\r\n },\r\n\r\n drawGeometry: (function() {\r\n return function(state) {\r\n var program = state.getLastProgramApplied();\r\n var programInstanceID = program.getInstanceID();\r\n var cache = state.getCacheUniformsApplyRenderLeaf();\r\n var obj = cache[programInstanceID];\r\n\r\n if (!obj) {\r\n obj = new CacheUniformApply(state, program);\r\n cache[programInstanceID] = obj;\r\n }\r\n\r\n obj.apply(state, this._modelView, this._model, this._view, this._projection);\r\n\r\n this._geometry.drawImplementation(state);\r\n };\r\n })(),\r\n\r\n render: (function() {\r\n var idLastDraw = 0;\r\n var lastStateSetStackSize = -1;\r\n\r\n return function(state, previousLeaf) {\r\n var prevRenderGraph;\r\n var prevRenderGraphParent;\r\n var curRenderGraph = this._parent;\r\n var curRenderGraphParent = curRenderGraph._parent;\r\n var curRenderGraphStateSet = curRenderGraph._stateset;\r\n\r\n // When rendering a RenderLeaf we try to limit the state change\r\n // to do that Graph of State is created during the culling pass.\r\n // this graph contains nodes of StateGraph type see the class StateGraph\r\n //\r\n // So to limit switching of StateSet we check where are the common parent\r\n // between previous RenderLeaf and this current.\r\n //\r\n // There are 3 cases when there is a prev / current render leaf\r\n //\r\n //\r\n // pRG: previousRenderGraph\r\n // cRG: currentRenderGraph\r\n // pRL: previousRenderLeaf\r\n // cRL: currentRenderLeaf\r\n // each RG contains a StateSet\r\n //\r\n // A B C\r\n // +-----+ +-----+ +-----+ +-----+\r\n // | pRG | | cRG | +--+ RG +--+ | RG |\r\n // +--+--+ +--+--+ | +-----+ | +--+--+\r\n // | | | | |\r\n // +--v--+ +--v--+ +--v--+ +--v--+ +--v--+\r\n // | pRG | | cRG | | pRG | | cRG | +--+ RG +--+\r\n // +--+--+ +--+--+ +--+--+ +--+--+ | +-----+ |\r\n // | | | | | |\r\n // +--v--+ +--v--+ +--v--+ +--v--+ +--v--+ +--v--+\r\n // | pRL | | cRL | | pRL | | cRL | | pRL | | cRL |\r\n // +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\r\n //\r\n //\r\n // Case A\r\n // no common parent StateGraphNode we need to\r\n // popStateSet until we find the common parent and then\r\n // pushStateSet from the common parent to the current\r\n // RenderLeaf\r\n //\r\n // Case B\r\n // common parent StateGraphNode so we apply the current stateSet\r\n //\r\n // Case C\r\n // the StateGraphNode is common to the previous RenderLeaf so we dont need\r\n // to do anything except if we used an insertStateSet\r\n //\r\n\r\n if (previousLeaf !== undefined) {\r\n // apply state if required.\r\n prevRenderGraph = previousLeaf._parent;\r\n prevRenderGraphParent = prevRenderGraph._parent;\r\n\r\n if (prevRenderGraphParent !== curRenderGraphParent) {\r\n // Case A\r\n StateGraph.moveStateGraph(state, prevRenderGraphParent, curRenderGraphParent);\r\n\r\n state.applyStateSet(curRenderGraphStateSet);\r\n } else if (curRenderGraph !== prevRenderGraph) {\r\n // Case B\r\n state.applyStateSet(curRenderGraphStateSet);\r\n } else {\r\n // Case C\r\n\r\n // in osg we call apply but actually we dont need\r\n // except if the stateSetStack changed.\r\n // for example if insert/remove StateSet has been used\r\n if (state._stateSetStackChanged(idLastDraw, lastStateSetStackSize)) {\r\n state.applyStateSet(curRenderGraphStateSet);\r\n }\r\n }\r\n } else {\r\n StateGraph.moveStateGraph(state, undefined, curRenderGraphParent);\r\n state.applyStateSet(curRenderGraphStateSet);\r\n }\r\n\r\n state._setStateSetsDrawID(++idLastDraw);\r\n lastStateSetStackSize = state.getStateSetStackSize();\r\n\r\n this.drawGeometry(state);\r\n };\r\n })()\r\n};\r\n\r\nexport default RenderLeaf;","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport IntersectFunctor from '../osgUtil/IntersectFunctor';\r\n\r\nvar LineSegmentIntersection = function() {\r\n IntersectFunctor.Intersection.call(this);\r\n\r\n this._localIntersectionNormal = vec3.clone(vec3.ONE);\r\n\r\n // index of vertex\r\n this._i1 = -1;\r\n this._i2 = -1;\r\n this._i3 = -1;\r\n\r\n // barycentric coordinates\r\n this._r1 = 0.0;\r\n this._r2 = 0.0;\r\n this._r3 = 0.0;\r\n};\r\n\r\n// Settings are needed.\r\nvar LineSegmentIntersectFunctor = function() {\r\n IntersectFunctor.call(this);\r\n\r\n this._threshold = 0.0; // only used for lines and points\r\n this._d = vec3.create();\r\n this._length = 0;\r\n this._invLength = 0;\r\n\r\n this._start = vec3.create();\r\n this._end = vec3.create();\r\n this._dInvX = vec3.create();\r\n this._dInvY = vec3.create();\r\n this._dInvZ = vec3.create();\r\n this._hit = false;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n LineSegmentIntersectFunctor,\r\n utils.objectInherit(IntersectFunctor.prototype, {\r\n set: function(start, end, threshold) {\r\n this._start = start;\r\n this._end = end;\r\n vec3.sub(this._d, end, start);\r\n\r\n this._length = vec3.length(this._d);\r\n this._invLength = this._length !== 0.0 ? 1.0 / this._length : 0.0;\r\n\r\n vec3.scale(this._d, this._d, this._invLength);\r\n if (this._d[0] !== 0.0) vec3.scale(this._dInvX, this._d, 1.0 / this._d[0]);\r\n if (this._d[1] !== 0.0) vec3.scale(this._dInvY, this._d, 1.0 / this._d[1]);\r\n if (this._d[2] !== 0.0) vec3.scale(this._dInvZ, this._d, 1.0 / this._d[2]);\r\n\r\n if (threshold !== undefined) this._threshold = threshold;\r\n },\r\n\r\n enter: function(bbox, s, e) {\r\n var min = bbox._min;\r\n var xmin = min[0];\r\n var ymin = min[1];\r\n var zmin = min[2];\r\n\r\n var max = bbox._max;\r\n var xmax = max[0];\r\n var ymax = max[1];\r\n var zmax = max[2];\r\n\r\n var invX = this._dInvX;\r\n var invY = this._dInvY;\r\n var invZ = this._dInvZ;\r\n\r\n if (s[0] <= e[0]) {\r\n // trivial reject of segment wholely outside.\r\n if (e[0] < xmin) return false;\r\n if (s[0] > xmax) return false;\r\n\r\n if (s[0] < xmin) {\r\n // clip s to xMin.\r\n vec3.scaleAndAdd(s, s, invX, xmin - s[0]);\r\n }\r\n\r\n if (e[0] > xmax) {\r\n // clip e to xMax.\r\n vec3.scaleAndAdd(e, s, invX, xmax - s[0]);\r\n }\r\n } else {\r\n if (s[0] < xmin) return false;\r\n if (e[0] > xmax) return false;\r\n\r\n if (e[0] < xmin) {\r\n // clip s to xMin.\r\n vec3.scaleAndAdd(e, s, invX, xmin - s[0]);\r\n }\r\n\r\n if (s[0] > xmax) {\r\n // clip e to xMax.\r\n vec3.scaleAndAdd(s, s, invX, xmax - s[0]);\r\n }\r\n }\r\n\r\n // compare s and e against the yMin to yMax range of bb.\r\n if (s[1] <= e[1]) {\r\n // trivial reject of segment wholely outside.\r\n if (e[1] < ymin) return false;\r\n if (s[1] > ymax) return false;\r\n\r\n if (s[1] < ymin) {\r\n // clip s to yMin.\r\n vec3.scaleAndAdd(s, s, invY, ymin - s[1]);\r\n }\r\n\r\n if (e[1] > ymax) {\r\n // clip e to yMax.\r\n vec3.scaleAndAdd(e, s, invY, ymax - s[1]);\r\n }\r\n } else {\r\n if (s[1] < ymin) return false;\r\n if (e[1] > ymax) return false;\r\n\r\n if (e[1] < ymin) {\r\n // clip s to yMin.\r\n vec3.scaleAndAdd(e, s, invY, ymin - s[1]);\r\n }\r\n\r\n if (s[1] > ymax) {\r\n // clip e to yMax.\r\n vec3.scaleAndAdd(s, s, invY, ymax - s[1]);\r\n }\r\n }\r\n\r\n // compare s and e against the zMin to zMax range of bb.\r\n if (s[2] <= e[2]) {\r\n // trivial reject of segment wholely outside.\r\n if (e[2] < zmin) return false;\r\n if (s[2] > zmax) return false;\r\n\r\n if (s[2] < zmin) {\r\n // clip s to zMin.\r\n vec3.scaleAndAdd(s, s, invZ, zmin - s[2]);\r\n }\r\n\r\n if (e[2] > zmax) {\r\n // clip e to zMax.\r\n vec3.scaleAndAdd(e, s, invZ, zmax - s[2]);\r\n }\r\n } else {\r\n if (s[2] < zmin) return false;\r\n if (e[2] > zmax) return false;\r\n\r\n if (e[2] < zmin) {\r\n // clip s to zMin.\r\n vec3.scaleAndAdd(e, s, invZ, zmin - s[2]);\r\n }\r\n\r\n if (s[2] > zmax) {\r\n // clip e to zMax.\r\n vec3.scaleAndAdd(s, s, invZ, zmax - s[2]);\r\n }\r\n }\r\n\r\n return true;\r\n },\r\n\r\n intersectPoint: (function() {\r\n var tmp = vec3.create();\r\n var dir = vec3.create();\r\n\r\n return function(v0, p0) {\r\n // https://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistPointSegment.h\r\n var st = this._start;\r\n\r\n vec3.sub(tmp, v0, st);\r\n vec3.sub(dir, this._end, st);\r\n // compute ratio (projection on line)\r\n var r = vec3.dot(tmp, dir) * this._invLength * this._invLength;\r\n\r\n // compute distance to segment\r\n var distToSegmentSqr = 1.0;\r\n if (r < 0.0) distToSegmentSqr = vec3.sqrLen(tmp);\r\n else if (r > 1.0) distToSegmentSqr = vec3.sqrDist(v0, this._end);\r\n else distToSegmentSqr = vec3.sqrLen(vec3.scaleAndAdd(tmp, tmp, dir, -r));\r\n\r\n if (distToSegmentSqr > this._threshold * this._threshold) {\r\n return;\r\n }\r\n\r\n var intersection = this.initIntersection(new LineSegmentIntersection());\r\n intersection._i1 = p0;\r\n intersection._r1 = 1.0;\r\n\r\n vec3.scaleAndAdd(intersection._localIntersectionPoint, st, dir, r);\r\n intersection._ratio = r;\r\n };\r\n })(),\r\n\r\n intersectLine: (function() {\r\n var u = vec3.create();\r\n var v = vec3.create();\r\n var w = vec3.create();\r\n\r\n var closest0 = vec3.create();\r\n var closest1 = vec3.create();\r\n\r\n return function(v0, v1, p0, p1) {\r\n // https://www.geometrictools.com/GTEngine/Samples/Geometrics/DistanceSegments3/DistanceSegments3.cpp\r\n var epsilon = 0.00000001;\r\n vec3.sub(u, v1, v0);\r\n vec3.sub(v, this._end, this._start);\r\n vec3.sub(w, v0, this._start);\r\n var a = vec3.dot(u, u);\r\n var b = vec3.dot(u, v);\r\n var c = vec3.dot(v, v);\r\n var d = vec3.dot(u, w);\r\n var e = vec3.dot(v, w);\r\n var D = a * c - b * b;\r\n var sN;\r\n var tN;\r\n var sD = D;\r\n var tD = D;\r\n\r\n // compute the line parameters of the two closest points\r\n if (D < epsilon) {\r\n // the lines are almost parallel\r\n sN = 0.0; // force using point P0 on segment S1\r\n sD = 1.0; // to prevent possible division by 0.0 later\r\n tN = e;\r\n tD = c;\r\n } else {\r\n // get the closest points on the infinite lines\r\n sN = b * e - c * d;\r\n tN = a * e - b * d;\r\n if (sN < 0.0) {\r\n // sc < 0 => the s=0 edge is visible\r\n sN = 0.0;\r\n tN = e;\r\n tD = c;\r\n } else if (sN > sD) {\r\n // sc > 1 => the s=1 edge is visible\r\n sN = sD;\r\n tN = e + b;\r\n tD = c;\r\n }\r\n }\r\n\r\n if (tN < 0.0) {\r\n // tc < 0 => the t=0 edge is visible\r\n tN = 0.0;\r\n // recompute sc for this edge\r\n if (-d < 0.0) sN = 0.0;\r\n else if (-d > a) sN = sD;\r\n else {\r\n sN = -d;\r\n sD = a;\r\n }\r\n } else if (tN > tD) {\r\n // tc > 1 => the t=1 edge is visible\r\n tN = tD;\r\n // recompute sc for this edge\r\n if (-d + b < 0.0) sN = 0;\r\n else if (-d + b > a) sN = sD;\r\n else {\r\n sN = -d + b;\r\n sD = a;\r\n }\r\n }\r\n // finally do the division to get sc and tc\r\n var sc = Math.abs(sN) < epsilon ? 0.0 : sN / sD;\r\n var tc = Math.abs(tN) < epsilon ? 0.0 : tN / tD;\r\n\r\n // get the difference of the two closest points\r\n vec3.scaleAndAdd(closest0, v0, u, sc);\r\n vec3.scaleAndAdd(closest1, this._start, v, tc);\r\n\r\n var sqrDistance = vec3.sqrDist(closest0, closest1);\r\n if (sqrDistance > this._threshold * this._threshold) {\r\n return;\r\n }\r\n\r\n var intersection = this.initIntersection(new LineSegmentIntersection());\r\n intersection._i1 = p0;\r\n intersection._i2 = p1;\r\n intersection._r1 = 1.0 - tc;\r\n intersection._r2 = tc;\r\n\r\n vec3.copy(intersection._localIntersectionPoint, closest1);\r\n intersection._ratio = tc;\r\n };\r\n })(),\r\n\r\n intersectTriangle: (function() {\r\n var normal = vec3.create();\r\n var e2 = vec3.create();\r\n var e1 = vec3.create();\r\n var tvec = vec3.create();\r\n var pvec = vec3.create();\r\n var qvec = vec3.create();\r\n var epsilon = 1e-20;\r\n\r\n return function(v0, v1, v2, p0, p1, p2) {\r\n var d = this._d;\r\n\r\n vec3.sub(e2, v2, v0);\r\n vec3.sub(e1, v1, v0);\r\n vec3.cross(pvec, d, e2);\r\n\r\n var det = vec3.dot(pvec, e1);\r\n if (det > -epsilon && det < epsilon) return;\r\n var invDet = 1.0 / det;\r\n\r\n vec3.sub(tvec, this._start, v0);\r\n\r\n var u = vec3.dot(pvec, tvec) * invDet;\r\n if (u < 0.0 || u > 1.0) return;\r\n\r\n vec3.cross(qvec, tvec, e1);\r\n\r\n var v = vec3.dot(qvec, d) * invDet;\r\n if (v < 0.0 || u + v > 1.0) return;\r\n\r\n var t = vec3.dot(qvec, e2) * invDet;\r\n\r\n if (t < epsilon || t > this._length) return;\r\n\r\n var r0 = 1.0 - u - v;\r\n var r1 = u;\r\n var r2 = v;\r\n var r = t * this._invLength;\r\n\r\n var interX = v0[0] * r0 + v1[0] * r1 + v2[0] * r2;\r\n var interY = v0[1] * r0 + v1[1] * r1 + v2[1] * r2;\r\n var interZ = v0[2] * r0 + v1[2] * r1 + v2[2] * r2;\r\n\r\n vec3.cross(normal, e1, e2);\r\n vec3.normalize(normal, normal);\r\n\r\n var intersection = this.initIntersection(new LineSegmentIntersection());\r\n intersection._i1 = p0;\r\n intersection._i2 = p1;\r\n intersection._i3 = p2;\r\n intersection._r1 = r0;\r\n intersection._r2 = r1;\r\n intersection._r3 = r2;\r\n\r\n vec3.set(intersection._localIntersectionPoint, interX, interY, interZ);\r\n vec3.copy(intersection._localIntersectionNormal, normal);\r\n intersection._ratio = r;\r\n\r\n // http://gamedev.stackexchange.com/questions/54505/negative-scale-in-matrix-4x4\r\n // https://en.wikipedia.org/wiki/Determinant#Orientation_of_a_basis\r\n // you can't exactly extract scale of a matrix but the determinant will tell you\r\n // if the orientation is preserved\r\n intersection._backface = mat4.determinant(intersection._matrix) * det < 0;\r\n };\r\n })(),\r\n\r\n operatorPoint: function(p0) {\r\n if (this._threshold <= 0.0) return;\r\n IntersectFunctor.prototype.operatorPoint.call(this, p0);\r\n },\r\n\r\n operatorLine: function(p0, p1) {\r\n if (this._threshold <= 0.0) return;\r\n IntersectFunctor.prototype.operatorLine.call(this, p0, p1);\r\n }\r\n }),\r\n 'osgUtil',\r\n 'LineSegmentIntersectFunctor'\r\n);\r\n\r\nexport default LineSegmentIntersectFunctor;\r\n","import intersectionEnums from '../osgUtil/intersectionEnums';\r\n\r\nvar Intersector = function() {\r\n this._intersections = [];\r\n this._primitiveMask = intersectionEnums.ALL_PRIMITIVES;\r\n this._intersectionLimit = intersectionEnums.NO_LIMIT;\r\n};\r\n\r\nIntersector.prototype = {\r\n reset: function() {\r\n this._intersections.length = 0;\r\n },\r\n\r\n enter: function(node) {\r\n if (this.reachedLimit()) return false;\r\n return !node.isCullingActive() || this.intersectNode(node);\r\n },\r\n\r\n intersectNode: function(node) {\r\n return (\r\n this.intersectBoundingSphere(node.getBoundingSphere()) ||\r\n this.intersectBoundingBox(node.getBoundingBox())\r\n );\r\n },\r\n\r\n intersectBoundingSphere: function(/*bsphere*/) {\r\n return false;\r\n },\r\n\r\n intersectBoundingBox: function(/*bsphere*/) {\r\n return false;\r\n },\r\n\r\n getIntersections: function() {\r\n return this._intersections;\r\n },\r\n\r\n setIntersectionLimit: function(limit) {\r\n this._intersectionLimit = limit;\r\n },\r\n\r\n getIntersectionLimit: function() {\r\n return this._intersectionLimit;\r\n },\r\n\r\n setPrimitiveMask: function(primitiveMask) {\r\n this._primitiveMask = primitiveMask;\r\n },\r\n\r\n getPrimitiveMask: function() {\r\n return this._primitiveMask;\r\n },\r\n\r\n reachedLimit: function() {\r\n return (\r\n this._intersectionLimit === intersectionEnums.LIMIT_ONE &&\r\n this._intersections.length > 0\r\n );\r\n },\r\n\r\n setCurrentTransformation: function(/*matrix*/) {},\r\n\r\n intersect: function(/*iv, node*/) {}\r\n};\r\n\r\nexport default Intersector;\r\n","module.exports = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAER0lEQVR4AezYQUgdxx/AcRukRAM1HrSCkB4tOSQhLxRC2iQYL2JLRIKKnnJoexAphtJbeOmtF2slIr3UsyAxgQZD/qf/IYb/IW1e0cMLheag8uAdtJGmNH/f81NYloEl+4xxTdNCv3OZmZ2d/e7s7G9mt+5f9o6jrnvoqbt61e017flEp20JuPrXCxQkaXmVAl2u6UrUNMGmExrNA2Pp52QXGLYJWDcQanvgdpTtA24I5xiwDtg0nE2gU4JwT71wM8peBG4J9y5JZxaBOSjIWwaWdiGwBMvyCsBcFoEStKnTagPo31lAP2xoVacNKGURWIX2KDsGlDWnC0SezcrCjGwHVrMIzMJMlK1XBCbiTBAIFE1AUX10ZAaYzSJwDqpyUaFbIE0g0B3V51SBc9lew0VYjAsLgLI5eWejujZD8uaUAQvCieHULALHVGEwKnQom3SqRtNTJpV1RPlBoOrYywu85VCiPAIrGqLCwZ16C8cbrAAjwsM0a1XJnM6dBPr8BH4MK9xJj4AhoZkDckZNmXfHvCmjcg4Ixw0BPHIyGsVFAQzXEvhUAA+877hHUHElNDpiXMnzlIw7ElpdUYkVjKhKsllLYBue+E3gPjzTFzc4bNqW2myZdjgM5jMBVTPatSkAXWkCF+Cegxp96XcAlXD589a8mDXng0IFsCgX1+WBa2kCecIRR8zahjD4l1XsjorL4UGwYjBcotXyziPAY++Gig/84Ptw+W27ZzsoDGmIc/XGbADrtebACvzf15riijc0xoNf8XJUnE903a0oMFBL4EOAsk+E18pha16etTAdOywILOnaKQ6c9D+AgjNx5bS9MR2HpjJAWf9uImGPIjAZT8cte2MrjguTwITm3a8FRcQxf9zeGY/XCFDc/WLUBuU46JbsnVI8k8pA204CLcbccCtOYSuXk42csLUUer9hTEtS4KrnyEcHRmVjNI5xKVwVBHqRJKx+U7IxFYejVHrFAndhXp+LQoof2LxszIsmVaLnPvPAXbHAU2hMnY93ZONOaq+NwFOxwEM4kdJwX0YgJZ0AHooFrsOm224Kydl9nANnEz3ftglcFwsctfUa3oItR4XX8LSCJPsfB5IUnJaMhJr06I3TK4mEofceTX/ztaDZxCtZDXcp0K8MlB2UfT/QZANYdOzFAl2WABZ07MuO6D2/CnzmzZ0EBgCKukNl9j1hi29VAVb01hZYhw1j6uOKBkPZdsUhHfdfgY/TBbpgWWuoGLSS8btgzHfeDv1d8hiopAtcg3xcyFncpy+jJ74ID77RfeBCzREoaNNuRpVA9m/Dn10U7hLy6XNgU5KqEdm/jgH/cUbOL2kjENKwQHhvs/8fuPSc72rtONBpTsmqWef28Q/JIZ8T+MNHr+Mf0Tu+cs8D3+j4R/0l+3P0Hyek/0gp/ceK6T9aPlTmC+g/Y0L/OSP6z5rRdd5wxM2c0mbumP4QAJ9CBEfGUf7qAAAAAElFTkSuQmCC\"","import Depth from './Depth';\r\nimport BlendFunc from './BlendFunc';\r\nimport CullFace from './CullFace';\r\nimport FrontFace from './FrontFace';\r\n// To avoid to apply duplicate states we cache them and apply them only\r\n// when there is a draw commands it means when calling state.drawGeometry\r\n// called from Geometry.drawImplementation or state.clear\r\n\r\n// Here what it does:\r\n// state.applyCullFaceAttribute(cullFaceDisableAttribute);\r\n// state.applyCullFaceAttribute(cullFaceEnableAttribute);\r\n// state.applyCullFaceAttribute(cullFaceDisableAttribute);\r\n// state.applyCullFaceAttribute(cullFaceEnableAttribute);\r\n// state.drawGeometry()\r\n\r\n// in this case only the cullFaceEnableAttribute will be applied not the previous one\r\n\r\n// Internal implementation use 2 buffers:\r\n// - buffer, it contains the required field that will be applied when executing a draw command\r\n// - state, that contains the last state appied to webgl, it's used to compare if a\r\n// change happend from the incoming attribute\r\n\r\nvar createStateBlendFunc = function() {\r\n return {\r\n buffer: {\r\n separate: false,\r\n enable: false,\r\n sourceFactor: BlendFunc.ONE,\r\n destinationFactor: BlendFunc.ZERO,\r\n sourceFactorAlpha: BlendFunc.ONE,\r\n destinationFactorAlpha: BlendFunc.ZERO\r\n },\r\n state: {\r\n separate: undefined,\r\n enable: false,\r\n sourceFactor: undefined,\r\n destinationFactor: undefined,\r\n sourceFactorAlpha: undefined,\r\n destinationFactorAlpha: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateDepth = function() {\r\n return {\r\n buffer: {\r\n func: Depth.LESS,\r\n enable: false,\r\n near: 0.0,\r\n far: 1.0\r\n },\r\n state: {\r\n func: undefined,\r\n enable: false,\r\n near: undefined,\r\n far: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateFrontFace = function() {\r\n return {\r\n buffer: {\r\n mode: FrontFace.CCW\r\n },\r\n state: {\r\n mode: undefined\r\n },\r\n changed: true\r\n };\r\n}\r\n\r\nvar createStateCullFace = function() {\r\n return {\r\n buffer: {\r\n enable: false,\r\n mode: CullFace.BACK\r\n },\r\n state: {\r\n enable: false,\r\n mode: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateScissor = function() {\r\n return {\r\n buffer: {\r\n enable: false,\r\n x: 0,\r\n y: 0,\r\n width: 640,\r\n height: 480\r\n },\r\n state: {\r\n enable: false,\r\n x: undefined,\r\n y: undefined,\r\n width: undefined,\r\n height: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateColorMask = function() {\r\n return {\r\n buffer: {\r\n red: true,\r\n green: true,\r\n blue: true,\r\n alpha: true\r\n },\r\n state: {\r\n red: undefined,\r\n green: undefined,\r\n blue: undefined,\r\n alpha: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateViewport = function() {\r\n return {\r\n buffer: {\r\n x: 0,\r\n y: 0,\r\n width: 640,\r\n height: 480\r\n },\r\n state: {\r\n x: undefined,\r\n y: undefined,\r\n width: undefined,\r\n height: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateDepthMask = function() {\r\n return {\r\n state: { value: true },\r\n buffer: { value: undefined },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateClearDepth = function() {\r\n return {\r\n buffer: { value: 1.0 },\r\n state: { value: undefined },\r\n changed: true\r\n };\r\n};\r\n\r\nvar createStateClearColor = function() {\r\n return {\r\n buffer: {\r\n red: 0.0,\r\n green: 0.0,\r\n blue: 0.0,\r\n alpha: 0.0\r\n },\r\n state: {\r\n red: undefined,\r\n green: undefined,\r\n blue: undefined,\r\n alpha: undefined\r\n },\r\n changed: true\r\n };\r\n};\r\n\r\nvar StateCache = function() {\r\n this._stateClearColor = createStateClearColor();\r\n this._stateClearDepth = createStateClearDepth();\r\n this._stateDepthMask = createStateDepthMask();\r\n this._stateViewport = createStateViewport();\r\n this._stateColorMask = createStateColorMask();\r\n this._stateScissor = createStateScissor();\r\n this._stateDepth = createStateDepth();\r\n this._stateFrontFace = createStateFrontFace();\r\n this._stateCullFace = createStateCullFace();\r\n this._stateBlendFunc = createStateBlendFunc();\r\n};\r\n\r\nStateCache.prototype = {\r\n clearColor: function(array) {\r\n var data = this._stateClearColor;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.red = array[0];\r\n buffer.green = array[1];\r\n buffer.blue = array[2];\r\n buffer.alpha = array[3];\r\n\r\n if (\r\n state.red !== array[0] ||\r\n state.green !== array[1] ||\r\n state.blue !== array[2] ||\r\n state.alpha !== array[3]\r\n ) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyClearColor: function(gl) {\r\n var data = this._stateClearColor;\r\n var state = data.state;\r\n var buffer = data.buffer;\r\n data.changed = false;\r\n state.red = buffer.red;\r\n state.green = buffer.green;\r\n state.blue = buffer.blue;\r\n state.alpha = buffer.alpha;\r\n gl.clearColor(state.red, state.green, state.blue, state.alpha);\r\n },\r\n\r\n clearDepth: function(value) {\r\n var data = this._stateClearDepth;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.value = value;\r\n\r\n if (state.value !== value) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyClearDepth: function(gl) {\r\n var data = this._stateClearDepth;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n state.value = buffer.value;\r\n gl.clearDepth(state.value);\r\n },\r\n\r\n depthMask: function(value) {\r\n var data = this._stateDepthMask;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.value = value;\r\n\r\n if (state.value !== value) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyDepthMask: function(gl) {\r\n var data = this._stateDepthMask;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n state.value = buffer.value;\r\n gl.depthMask(state.value);\r\n },\r\n\r\n applyViewportAttribute: function(attribute) {\r\n this.viewport(attribute._x, attribute._y, attribute._width, attribute._height);\r\n },\r\n\r\n viewport: function(x, y, width, height) {\r\n var data = this._stateViewport;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.x = x;\r\n buffer.y = y;\r\n buffer.width = width;\r\n buffer.height = height;\r\n\r\n if (state.x !== x || state.y !== y || state.width !== width || state.height !== height) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyViewport: function(gl) {\r\n var data = this._stateViewport;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n state.x = buffer.x;\r\n state.y = buffer.y;\r\n state.width = buffer.width;\r\n state.height = buffer.height;\r\n gl.viewport(state.x, state.y, state.width, state.height);\r\n },\r\n\r\n applyColorMaskAttribute: function(attribute) {\r\n var data = this._stateColorMask;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.red = attribute._red;\r\n buffer.green = attribute._green;\r\n buffer.blue = attribute._blue;\r\n buffer.alpha = attribute._alpha;\r\n\r\n if (\r\n state.red !== attribute._red ||\r\n state.green !== attribute._green ||\r\n state.blue !== attribute._blue ||\r\n state.alpha !== attribute._alpha\r\n ) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyColorMask: function(gl) {\r\n var data = this._stateColorMask;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n state.red = buffer.red;\r\n state.green = buffer.green;\r\n state.blue = buffer.blue;\r\n state.alpha = buffer.alpha;\r\n gl.colorMask(state.red, state.green, state.blue, state.alpha);\r\n },\r\n\r\n applyScissorAttribute: function(attribute) {\r\n var enable = attribute._x !== -1;\r\n var data = this._stateScissor;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.enable = enable;\r\n buffer.x = attribute._x;\r\n buffer.y = attribute._y;\r\n buffer.width = attribute._width;\r\n buffer.height = attribute._height;\r\n\r\n if (\r\n state.enable !== enable ||\r\n state.x !== attribute._x ||\r\n state.y !== attribute._y ||\r\n state.width !== attribute._width ||\r\n state.height !== attribute._height\r\n ) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyScissor: function(gl) {\r\n var data = this._stateScissor;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n if (state.enable !== buffer.enable) {\r\n state.enable = buffer.enable;\r\n if (state.enable) {\r\n gl.enable(gl.SCISSOR_TEST);\r\n } else {\r\n gl.disable(gl.SCISSOR_TEST);\r\n }\r\n }\r\n\r\n if (!state.enable) return;\r\n\r\n if (\r\n state.x !== buffer.x ||\r\n state.y !== buffer.y ||\r\n state.width !== buffer.width ||\r\n state.height !== buffer.height\r\n ) {\r\n state.x = buffer.x;\r\n state.y = buffer.y;\r\n state.width = buffer.width;\r\n state.height = buffer.height;\r\n gl.scissor(state.x, state.y, state.width, state.height);\r\n }\r\n },\r\n\r\n applyFrontFaceAttribute: function(attribute) {\r\n var data = this._stateFrontFace;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.mode = attribute._mode;\r\n\r\n if (state.mode !== attribute._mode) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyFrontFace: function(gl) {\r\n var data = this._stateFrontFace;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n if (state.mode !== buffer.mode) {\r\n state.mode = buffer.mode;\r\n gl.frontFace(state.mode);\r\n }\r\n },\r\n\r\n applyCullFaceAttribute: function(attribute) {\r\n var data = this._stateCullFace;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n var enable = attribute._mode !== CullFace.DISABLE;\r\n data.changed = false;\r\n\r\n buffer.enable = enable;\r\n buffer.mode = attribute._mode;\r\n\r\n if (state.enable !== enable || state.mode !== attribute._mode) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyCullFace: function(gl) {\r\n var data = this._stateCullFace;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n if (state.enable !== buffer.enable) {\r\n state.enable = buffer.enable;\r\n if (state.enable) {\r\n gl.enable(gl.CULL_FACE);\r\n } else {\r\n gl.disable(gl.CULL_FACE);\r\n }\r\n }\r\n\r\n if (!state.enable) return;\r\n\r\n if (state.mode !== buffer.mode) {\r\n state.mode = buffer.mode;\r\n gl.cullFace(state.mode);\r\n }\r\n },\r\n\r\n applyDepthAttribute: function(attribute) {\r\n var enable = attribute._func !== Depth.DISABLE;\r\n var data = this._stateDepth;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n buffer.enable = enable;\r\n buffer.func = attribute._func;\r\n buffer.far = attribute._far;\r\n buffer.near = attribute._near;\r\n\r\n if (\r\n state.enable !== enable ||\r\n state.func !== attribute._func ||\r\n state.near !== attribute._near ||\r\n state.far !== attribute._far\r\n ) {\r\n data.changed = true;\r\n }\r\n\r\n this.depthMask(attribute._writeMask);\r\n },\r\n\r\n applyDepth: function(gl) {\r\n var data = this._stateDepth;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n if (state.enable !== buffer.enable) {\r\n state.enable = buffer.enable;\r\n if (state.enable) {\r\n gl.enable(gl.DEPTH_TEST);\r\n } else {\r\n gl.disable(gl.DEPTH_TEST);\r\n }\r\n }\r\n\r\n if (!state.enable) return;\r\n\r\n if (state.func !== buffer.func) {\r\n state.func = buffer.func;\r\n gl.depthFunc(state.func);\r\n }\r\n\r\n if (state.near !== buffer.near || state.far !== buffer.far) {\r\n state.far = buffer.far;\r\n state.near = buffer.near;\r\n gl.depthRange(state.near, state.far);\r\n }\r\n },\r\n\r\n applyBlendFuncAttribute: function(attribute) {\r\n var data = this._stateBlendFunc;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n var enable =\r\n attribute._sourceFactor !== BlendFunc.DISABLE &&\r\n attribute._destinationFactor !== BlendFunc.DISABLE;\r\n data.changed = false;\r\n\r\n buffer.enable = enable;\r\n buffer.separate = attribute._separate;\r\n buffer.sourceFactor = attribute._sourceFactor;\r\n buffer.destinationFactor = attribute._destinationFactor;\r\n buffer.sourceFactorAlpha = attribute._sourceFactorAlpha;\r\n buffer.destinationFactorAlpha = attribute._destinationFactorAlpha;\r\n\r\n if (\r\n state.enable !== enable ||\r\n state.sourceFactor !== attribute._sourceFactor ||\r\n state.destinationFactor !== attribute._destinationFactor ||\r\n state.sourceFactorAlpha !== attribute._sourceFactorAlpha ||\r\n state.destinationFactorAlpha !== attribute._destinationFactorAlpha\r\n ) {\r\n data.changed = true;\r\n }\r\n },\r\n\r\n applyBlendFunc: function(gl) {\r\n var data = this._stateBlendFunc;\r\n var buffer = data.buffer;\r\n var state = data.state;\r\n data.changed = false;\r\n\r\n if (state.enable !== buffer.enable) {\r\n state.enable = buffer.enable;\r\n if (state.enable) {\r\n gl.enable(gl.BLEND);\r\n } else {\r\n gl.disable(gl.BLEND);\r\n }\r\n }\r\n\r\n if (!state.enable) return;\r\n\r\n state.separate = buffer.separate;\r\n if (state.separate) {\r\n if (\r\n state.sourceFactor !== buffer.sourceFactor ||\r\n state.destinationFactor !== buffer.destinationFactor ||\r\n state.sourceFactorAlpha !== buffer.sourceFactorAlpha ||\r\n state.destinationFactorAlpha !== buffer.destinationFactorAlpha\r\n ) {\r\n state.sourceFactor = buffer.sourceFactor;\r\n state.destinationFactor = buffer.destinationFactor;\r\n state.sourceFactorAlpha = buffer.sourceFactorAlpha;\r\n state.destinationFactorAlpha = buffer.destinationFactorAlpha;\r\n gl.blendFuncSeparate(\r\n state.sourceFactor,\r\n state.destinationFactor,\r\n state.sourceFactorAlpha,\r\n state.destinationFactorAlpha\r\n );\r\n }\r\n } else if (\r\n state.sourceFactor !== buffer.sourceFactor ||\r\n state.destinationFactor !== buffer.destinationFactor\r\n ) {\r\n state.sourceFactor = buffer.sourceFactor;\r\n state.destinationFactor = buffer.destinationFactor;\r\n gl.blendFunc(state.sourceFactor, state.destinationFactor);\r\n }\r\n },\r\n\r\n applyClearStates: function(gl) {\r\n if (this._stateDepthMask.changed) {\r\n this.applyDepthMask(gl);\r\n }\r\n if (this._stateScissor.changed) {\r\n this.applyScissor(gl);\r\n }\r\n if (this._stateClearColor.changed) {\r\n this.applyClearColor(gl);\r\n }\r\n if (this._stateClearDepth.changed) {\r\n this.applyClearDepth(gl);\r\n }\r\n if (this._stateColorMask.changed) {\r\n this.applyColorMask(gl);\r\n }\r\n },\r\n\r\n applyDrawStates: function(gl) {\r\n if (this._stateViewport.changed) {\r\n this.applyViewport(gl);\r\n }\r\n if (this._stateScissor.changed) {\r\n this.applyScissor(gl);\r\n }\r\n if (this._stateDepth.changed) {\r\n this.applyDepth(gl);\r\n }\r\n if (this._stateDepthMask.changed) {\r\n this.applyDepthMask(gl);\r\n }\r\n if (this._stateFrontFace.changed) {\r\n this.applyFrontFace(gl);\r\n }\r\n if (this._stateCullFace.changed) {\r\n this.applyCullFace(gl);\r\n }\r\n if (this._stateBlendFunc.changed) {\r\n this.applyBlendFunc(gl);\r\n }\r\n if (this._stateColorMask.changed) {\r\n this.applyColorMask(gl);\r\n }\r\n },\r\n\r\n clear: function(gl, mask) {\r\n this.applyClearStates(gl);\r\n gl.clear(mask);\r\n },\r\n\r\n drawGeometry: function(gl) {\r\n this.applyDrawStates(gl);\r\n }\r\n};\r\n\r\nexport default StateCache;","import { mat4 } from './glMatrix';\r\nimport { mat3 } from './glMatrix';\r\nimport notify from './notify';\r\nimport Object from './Object';\r\nimport Program from './Program';\r\nimport StateAttribute from './StateAttribute';\r\nimport PooledArray from './PooledArray';\r\nimport StackObjectPairPool from './StackObjectPairPool';\r\nimport Uniform from './Uniform';\r\nimport utils from './utils';\r\nimport WebGLCaps from './WebGLCaps';\r\nimport StateCache from './StateCache';\r\n\r\nvar checkUniformCache = [\r\n undefined,\r\n function uniformCheck1(uniformArray, cacheArray) {\r\n if (uniformArray[0] === cacheArray[0]) return true;\r\n cacheArray[0] = uniformArray[0];\r\n return false;\r\n },\r\n\r\n function uniformCheck2(uniformArray, cacheArray) {\r\n if (uniformArray[0] === cacheArray[0] && uniformArray[1] === cacheArray[1]) return true;\r\n cacheArray[0] = uniformArray[0];\r\n cacheArray[1] = uniformArray[1];\r\n return false;\r\n },\r\n\r\n function uniformCheck3(uniformArray, cacheArray) {\r\n if (\r\n uniformArray[0] === cacheArray[0] &&\r\n uniformArray[1] === cacheArray[1] &&\r\n uniformArray[2] === cacheArray[2]\r\n )\r\n return true;\r\n cacheArray[0] = uniformArray[0];\r\n cacheArray[1] = uniformArray[1];\r\n cacheArray[2] = uniformArray[2];\r\n return false;\r\n },\r\n\r\n function uniformCheck4(uniformArray, cacheArray) {\r\n if (\r\n uniformArray[0] === cacheArray[0] &&\r\n uniformArray[1] === cacheArray[1] &&\r\n uniformArray[2] === cacheArray[2] &&\r\n uniformArray[3] === cacheArray[3]\r\n )\r\n return true;\r\n cacheArray[0] = uniformArray[0];\r\n cacheArray[1] = uniformArray[1];\r\n cacheArray[2] = uniformArray[2];\r\n cacheArray[3] = uniformArray[3];\r\n return false;\r\n }\r\n];\r\n\r\nvar State = function(shaderGeneratorProxy) {\r\n Object.call(this);\r\n\r\n this._excludeUniforms = {\r\n uProjectionMatrix: true,\r\n uModelMatrix: true,\r\n uViewMatrix: true,\r\n uModelViewMatrix: true,\r\n uModelNormalMatrix: true,\r\n uModelViewNormalMatrix: true,\r\n uArrayColorEnabled: true\r\n };\r\n\r\n this._graphicContext = undefined;\r\n this._shaderGeneratorProxy = shaderGeneratorProxy;\r\n\r\n if (shaderGeneratorProxy === undefined) console.break();\r\n\r\n this._currentVAO = null;\r\n this._currentIndexVBO = null;\r\n\r\n this._stateSets = new PooledArray();\r\n this._shaderGeneratorNames = new StackObjectPairPool();\r\n this._uniforms = {};\r\n\r\n this._textureAttributeArrayList = [];\r\n this._attributeArray = [];\r\n\r\n this._projectionMatrix = Uniform.createMatrix4(mat4.create(), 'uProjectionMatrix');\r\n this._modelMatrix = Uniform.createMatrix4(mat4.create(), 'uModelMatrix');\r\n this._viewMatrix = Uniform.createMatrix4(mat4.create(), 'uViewMatrix');\r\n this._modelViewMatrix = Uniform.createMatrix4(mat4.create(), 'uModelViewMatrix');\r\n this._modelNormalMatrix = Uniform.createMatrix3(mat3.create(), 'uModelNormalMatrix');\r\n this._modelViewNormalMatrix = Uniform.createMatrix3(mat3.create(), 'uModelViewNormalMatrix');\r\n\r\n // track uniform for color array enabled\r\n var arrayColorEnable = new StackObjectPairPool();\r\n arrayColorEnable._globalDefault = Uniform.createFloat1(0.0, 'uArrayColorEnabled');\r\n\r\n this._uniforms.ArrayColorEnabled = arrayColorEnable;\r\n\r\n this._previousColorAttribPair = {};\r\n this._vertexAttribMap = {};\r\n this._vertexAttribMap._disable = [];\r\n this._vertexAttribMap._keys = [];\r\n\r\n this._frameStamp = undefined;\r\n\r\n // we dont use Map because in this use case with a few entries\r\n // {} is faster\r\n this._programCommonUniformsCache = {};\r\n\r\n // keep pointer on the last applied modelview and projection matrix\r\n this._lastAppliedModelViewMatrix = undefined;\r\n this._lastAppliedProjectionMatrix = undefined;\r\n\r\n // keep track of last applied program\r\n this._program = undefined;\r\n // inject a default program to initialize the stack Program\r\n var program = new Program();\r\n this.applyAttribute(program);\r\n\r\n // cache programAttribute access\r\n this._programType = utils.getOrCreateStateAttributeTypeMemberIndex(program);\r\n this._programAttribute = this._attributeArray[this._programType];\r\n\r\n this._numPushStateSet = 0;\r\n this._numApply = 0;\r\n\r\n this._programUniformCache = [];\r\n this._cacheUniformId = 0;\r\n\r\n // gl states cache\r\n this._stateCache = new StateCache();\r\n\r\n this.resetStats();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n State,\r\n utils.objectInherit(Object.prototype, {\r\n // excludeUniforms is a list of uniforms that will not be applied or checked automatically when applying a program\r\n // you should not add you uniforms in this list until you really know what you are doing.\r\n // The use case of the exclusions is because the RenderLeaf.drawGeometry will apply them without UniformStack and\r\n // it should be applied automatically because you will apply them RenderLeaf.drawGeometry.\r\n // If you are writing a custom renderStage or overriding RenderLeaf.drawGeometry and add new uniform and custom\r\n // behavior then it can make sense to add uniforms here.\r\n // To make it work you should add your uniforms before the rendering (usually before viewer.run())\r\n getExcludeUniforms: function() {\r\n return this._excludeUniforms;\r\n },\r\n\r\n resetCaches: function() {\r\n this._currentVAO = null;\r\n this._currentIndexVBO = null;\r\n\r\n this._previousColorAttribPair = {};\r\n this._vertexAttribMap = {};\r\n this._vertexAttribMap._disable = [];\r\n this._vertexAttribMap._keys = [];\r\n\r\n this._programCommonUniformsCache = {};\r\n },\r\n\r\n applyColorMask: function(attribute) {\r\n this._stateCache.applyColorMaskAttribute(attribute);\r\n },\r\n\r\n applyBlendFunc: function(attribute) {\r\n this._stateCache.applyBlendFuncAttribute(attribute);\r\n },\r\n\r\n applyCullFace: function(attribute) {\r\n this._stateCache.applyCullFaceAttribute(attribute);\r\n },\r\n\r\n applyFrontFace: function(attribute) {\r\n this._stateCache.applyFrontFaceAttribute(attribute);\r\n },\r\n\r\n applyDepth: function(attribute) {\r\n this._stateCache.applyDepthAttribute(attribute);\r\n },\r\n\r\n applyViewport: function(attribute) {\r\n this._stateCache.applyViewportAttribute(attribute);\r\n },\r\n\r\n applyScissor: function(attribute) {\r\n this._stateCache.applyScissorAttribute(attribute);\r\n },\r\n\r\n viewport: function(x, y, width, height) {\r\n this._stateCache.viewport(x, y, width, height);\r\n },\r\n\r\n depthMask: function(value) {\r\n this._stateCache.depthMask(value);\r\n },\r\n\r\n clearDepth: function(value) {\r\n this._stateCache.clearDepth(value);\r\n },\r\n\r\n clearColor: function(value) {\r\n this._stateCache.clearColor(value);\r\n },\r\n\r\n clear: function(mask) {\r\n this._stateCache.clear(this._graphicContext, mask);\r\n },\r\n\r\n drawGeometry: function(geom) {\r\n this._stateCache.drawGeometry(this._graphicContext, geom);\r\n },\r\n\r\n getCacheUniformsApplyRenderLeaf: function() {\r\n return this._programCommonUniformsCache;\r\n },\r\n\r\n setGraphicContext: function(graphicContext) {\r\n this._graphicContext = graphicContext;\r\n this._extVAO = WebGLCaps.instance(graphicContext).getWebGLExtension(\r\n 'OES_vertex_array_object'\r\n );\r\n },\r\n\r\n getGraphicContext: function() {\r\n return this._graphicContext;\r\n },\r\n\r\n getShaderGeneratorProxy: function() {\r\n return this._shaderGeneratorProxy;\r\n },\r\n\r\n pushCheckOverride: function(stack, object, maskValue) {\r\n var result = this._evaluateOverrideObjectOnStack(stack, object, maskValue);\r\n // override and protected case\r\n if (result !== object) stack.push(result, stack._back.value);\r\n else stack.push(object, maskValue);\r\n },\r\n\r\n _evaluateOverrideObjectOnStack: function(stack, object, maskValue) {\r\n var back = stack._back;\r\n // object can be a Uniform, an Attribute, or a shader generator name\r\n if (stack._length === 0) {\r\n return object;\r\n } else if (\r\n back.value & StateAttribute.OVERRIDE &&\r\n !(maskValue & StateAttribute.PROTECTED)\r\n ) {\r\n return back.object;\r\n } else {\r\n return object;\r\n }\r\n },\r\n\r\n pushStateSet: function(stateset) {\r\n this._numPushStateSet++;\r\n this._stateSets.push(stateset);\r\n\r\n this.pushAttributeMap(\r\n this._attributeArray,\r\n stateset._attributeArray,\r\n stateset._activeAttribute\r\n );\r\n\r\n var textureAttributeArrayList = stateset._textureAttributeArrayList;\r\n var activeTextureUnits = stateset._activeTextureAttributeUnit;\r\n var activeTextureAttribute = stateset._activeTextureAttribute;\r\n\r\n for (var i = 0, l = activeTextureUnits.length; i < l; i++) {\r\n var unit = activeTextureUnits[i];\r\n var _attributeArray = textureAttributeArrayList[unit];\r\n\r\n var textureUnitAttributeArray = this.getOrCreateTextureAttributeArray(unit);\r\n this.pushAttributeMap(\r\n textureUnitAttributeArray,\r\n _attributeArray,\r\n activeTextureAttribute\r\n );\r\n }\r\n\r\n if (stateset.hasUniform())\r\n this.pushUniformsList(this._uniforms, stateset.getUniformList());\r\n\r\n var generatorPair = stateset.getShaderGeneratorPair();\r\n if (generatorPair)\r\n this.pushCheckOverride(\r\n this._shaderGeneratorNames,\r\n generatorPair.getShaderGeneratorName(),\r\n generatorPair.getValue()\r\n );\r\n },\r\n\r\n getStateSetStackSize: function() {\r\n return this._stateSets.getLength();\r\n },\r\n\r\n insertStateSet: (function() {\r\n var tmpStack = new PooledArray();\r\n var tmpStackArray = tmpStack.getArray();\r\n return function(pos, stateSet) {\r\n tmpStack.reset();\r\n var length = this.getStateSetStackSize();\r\n while (length > pos) {\r\n tmpStack.push(this._stateSets.back());\r\n this.popStateSet();\r\n length--;\r\n }\r\n\r\n this.pushStateSet(stateSet);\r\n\r\n for (var i = tmpStack._length - 1; i >= 0; i--) {\r\n this.pushStateSet(tmpStackArray[i]);\r\n }\r\n };\r\n })(),\r\n\r\n removeStateSet: (function() {\r\n var tmpStack = new PooledArray();\r\n var tmpStackArray = tmpStack.getArray();\r\n return function(pos) {\r\n var length = this.getStateSetStackSize();\r\n if (pos >= length) {\r\n notify.warn('Warning State:removeStateSet ' + pos + ' out of range');\r\n return;\r\n }\r\n\r\n tmpStack.reset();\r\n\r\n // record the StateSet above the one we intend to remove\r\n while (length - 1 > pos) {\r\n tmpStack.push(this._stateSets.back());\r\n this.popStateSet();\r\n length--;\r\n }\r\n\r\n // remove the intended StateSet as well\r\n this.popStateSet();\r\n\r\n // push back the original ones that were above the remove StateSet\r\n for (var i = tmpStack._length - 1; i >= 0; i--) {\r\n this.pushStateSet(tmpStackArray[i]);\r\n }\r\n };\r\n })(),\r\n\r\n // needed because we use a cache during the frame to avoid\r\n // applying uniform or operation. At each frame we need to\r\n // invalidate those informations\r\n resetCacheFrame: function() {\r\n this._lastAppliedModelViewMatrix = this._lastAppliedProjectionMatrix = undefined;\r\n },\r\n\r\n resetStats: function() {\r\n this._numApply = 0;\r\n this._numPushStateSet = 0;\r\n },\r\n\r\n // apply program if needed\r\n applyProgram: function(program) {\r\n if (this._program === program) return;\r\n this._program = program;\r\n this.getGraphicContext().useProgram(program);\r\n },\r\n\r\n applyModelViewMatrix: (function() {\r\n var normal = mat3.create();\r\n\r\n return function StateApplyModelViewMatrix(matrix, matrixModel) {\r\n if (this._lastAppliedModelViewMatrix === matrix) return false;\r\n\r\n var program = this.getLastProgramApplied();\r\n var uniformCache = program.getUniformsCache();\r\n var mu = this._modelViewMatrix;\r\n var mul = uniformCache.uModelViewMatrix;\r\n var gc = this.getGraphicContext();\r\n if (mul) {\r\n mu.setMatrix4(matrix);\r\n mu.apply(gc, mul);\r\n }\r\n\r\n var sendNormal;\r\n if (this._lastAppliedModelViewMatrix) {\r\n // check if we need to push normal\r\n // test rotation component, if not diff\r\n // we dont need to send normal\r\n var m2 = this._lastAppliedModelViewMatrix;\r\n for (var i = 0; i < 11; i++) {\r\n if (matrix[i] !== m2[i]) {\r\n sendNormal = true;\r\n break;\r\n }\r\n }\r\n } else {\r\n sendNormal = true;\r\n }\r\n\r\n if (sendNormal) {\r\n mu = this._modelViewNormalMatrix;\r\n mul = uniformCache.uModelViewNormalMatrix;\r\n if (mul) {\r\n mat3.normalFromMat4(normal, matrix);\r\n mu.setMatrix3(normal);\r\n mu.apply(gc, mul);\r\n }\r\n\r\n mul = uniformCache.uModelNormalMatrix;\r\n if (mul) {\r\n mat3.normalFromMat4(normal, matrixModel);\r\n mu.setMatrix3(normal);\r\n mu.apply(gc, mul);\r\n }\r\n }\r\n\r\n this._lastAppliedModelViewMatrix = matrix;\r\n return true;\r\n };\r\n })(),\r\n\r\n applyProjectionMatrix: function(matrix) {\r\n if (this._lastAppliedProjectionMatrix === matrix) return;\r\n\r\n this._lastAppliedProjectionMatrix = matrix;\r\n var program = this.getLastProgramApplied();\r\n var mu = this._projectionMatrix;\r\n\r\n var mul = program.getUniformsCache()[mu.getName()];\r\n if (mul) {\r\n mu.setMatrix4(matrix);\r\n mu.apply(this.getGraphicContext(), mul);\r\n }\r\n },\r\n\r\n getCurrentShaderGeneratorStateSet: function(stateset) {\r\n var programStack = this._programAttribute;\r\n var stateSetProgramPair = stateset._attributeArray[this._programType];\r\n\r\n if (\r\n (programStack._length !== 0 && programStack._back.value !== StateAttribute.OFF) ||\r\n (stateSetProgramPair && stateSetProgramPair.getValue() !== StateAttribute.OFF)\r\n )\r\n return undefined;\r\n\r\n var stateSetGeneratorPair = stateset.getShaderGeneratorPair();\r\n var generatorStack = this._shaderGeneratorNames;\r\n var generator;\r\n\r\n if (stateSetGeneratorPair) {\r\n var maskValue = stateSetGeneratorPair.getValue();\r\n var stateSetGenerator = stateSetGeneratorPair.getShaderGeneratorName();\r\n generator = this._evaluateOverrideObjectOnStack(\r\n this._shaderGeneratorNames,\r\n stateSetGenerator,\r\n maskValue\r\n );\r\n } else if (generatorStack._length) {\r\n generator = generatorStack._back.object;\r\n }\r\n\r\n // no custom program look into the stack of ShaderGenerator name\r\n // what we should use to generate a program\r\n var last = generator;\r\n var shaderGenerator = this._shaderGeneratorProxy.getShaderGenerator(last);\r\n return shaderGenerator;\r\n },\r\n\r\n _applyAttributeMapStateSet: function(_attributeArray, stateSetAttributeArray) {\r\n var max =\r\n _attributeArray.length > stateSetAttributeArray.length ?\r\n _attributeArray.length :\r\n stateSetAttributeArray.length;\r\n\r\n for (var i = 0, l = max; i < l; i++) {\r\n var attribute;\r\n var attributeId = i;\r\n\r\n var attributeStack =\r\n attributeId < _attributeArray.length ? _attributeArray[attributeId] : undefined;\r\n\r\n var stateSetAttributePair =\r\n attributeId < stateSetAttributeArray.length ?\r\n stateSetAttributeArray[attributeId] :\r\n undefined;\r\n\r\n var hasStateAttributeStack = !!attributeStack;\r\n var hasStateAttributeStackChanged =\r\n hasStateAttributeStack && attributeStack._changed;\r\n\r\n if (!stateSetAttributePair && !hasStateAttributeStackChanged) continue;\r\n\r\n var stateSetAttribute = stateSetAttributePair ?\r\n stateSetAttributePair.getAttribute() :\r\n undefined;\r\n\r\n if (!hasStateAttributeStack) {\r\n attributeStack = this._createAttributeStack(\r\n _attributeArray,\r\n attributeId,\r\n stateSetAttribute.cloneType()\r\n );\r\n attributeStack._changed = true;\r\n this._applyAttributeStack(stateSetAttribute, attributeStack);\r\n } else if (stateSetAttribute) {\r\n var maskValue = stateSetAttributePair.getValue();\r\n attribute = this._evaluateOverrideObjectOnStack(\r\n attributeStack,\r\n stateSetAttribute,\r\n maskValue\r\n );\r\n if (attribute !== stateSetAttribute) {\r\n // override\r\n\r\n if (attributeStack._changed) {\r\n this._applyAttributeStack(attribute, attributeStack);\r\n attributeStack._changed = false;\r\n }\r\n } else if (this._applyAttributeStack(attribute, attributeStack)) {\r\n attributeStack._changed = true;\r\n }\r\n } else if (attributeStack._length) {\r\n attributeStack._changed = false;\r\n this._applyAttributeStack(attributeStack._back.object, attributeStack);\r\n } else {\r\n attributeStack._changed = false;\r\n this._applyAttributeStack(attributeStack._globalDefault, attributeStack);\r\n }\r\n }\r\n },\r\n\r\n _applyTextureAttributeMapListStateSet: function(\r\n _textureAttributeArrayList,\r\n stateSetTextureAttributeArrayList\r\n ) {\r\n var _textureAttributeArray;\r\n var stateSetTextureAttributeLength, stateTextureAttributeLength;\r\n // very interesting JIT optimizer behavior\r\n // max texture is supposed to be the max of activeTexture or stateSet texture list\r\n // if the loop is fix, for example max value that could be 16. It's faster than using the max of textureUnit of State and StateSet even if the value is 8 for example\r\n var maxTexture = 16;\r\n for (var i = 0, l = maxTexture; i < l; i++) {\r\n var textureUnit = i;\r\n\r\n _textureAttributeArray =\r\n textureUnit < _textureAttributeArrayList.length ?\r\n _textureAttributeArrayList[textureUnit] :\r\n undefined;\r\n var stateSetTextureAttributeArray =\r\n textureUnit < stateSetTextureAttributeArrayList.length ?\r\n stateSetTextureAttributeArrayList[textureUnit] :\r\n undefined;\r\n\r\n if (!_textureAttributeArray && !stateSetTextureAttributeArray) continue;\r\n\r\n stateSetTextureAttributeLength = stateTextureAttributeLength = 0;\r\n if (!_textureAttributeArray) {\r\n _textureAttributeArray = this.getOrCreateTextureAttributeArray(textureUnit);\r\n stateSetTextureAttributeLength = stateSetTextureAttributeArray.length;\r\n } else {\r\n stateTextureAttributeLength = _textureAttributeArray.length;\r\n if (stateSetTextureAttributeArray)\r\n stateSetTextureAttributeLength = stateSetTextureAttributeArray.length;\r\n }\r\n\r\n var lt =\r\n stateTextureAttributeLength > stateSetTextureAttributeLength ?\r\n stateTextureAttributeLength :\r\n stateSetTextureAttributeLength;\r\n for (var j = 0; j < lt; j++) {\r\n var attributeId = j;\r\n\r\n var attributeStack =\r\n attributeId < stateTextureAttributeLength ?\r\n _textureAttributeArray[attributeId] :\r\n undefined;\r\n\r\n var stateSetAttributePair =\r\n stateSetTextureAttributeArray &&\r\n attributeId < stateSetTextureAttributeArray.length ?\r\n stateSetTextureAttributeArray[attributeId] :\r\n undefined;\r\n var hasStateAttributeStack = !!attributeStack;\r\n var hasStateAttributeStackChanged =\r\n hasStateAttributeStack && attributeStack._changed;\r\n var attribute;\r\n\r\n if (!stateSetAttributePair && !hasStateAttributeStackChanged) continue;\r\n\r\n var stateSetAttribute = stateSetAttributePair ?\r\n stateSetAttributePair.getAttribute() :\r\n undefined;\r\n\r\n if (!hasStateAttributeStack) {\r\n attribute = stateSetAttributePair.getAttribute();\r\n attributeStack = this._createAttributeStack(\r\n _textureAttributeArray,\r\n attributeId,\r\n attribute.cloneType()\r\n );\r\n attributeStack._changed = true;\r\n this._applyTextureAttribute(textureUnit, attribute, attributeStack);\r\n } else if (stateSetAttribute) {\r\n var maskValue = stateSetAttributePair.getValue();\r\n attribute = this._evaluateOverrideObjectOnStack(\r\n attributeStack,\r\n stateSetAttribute,\r\n maskValue\r\n );\r\n if (attribute !== stateSetAttribute) {\r\n // override\r\n\r\n if (attributeStack._changed) {\r\n this._applyTextureAttribute(textureUnit, attribute, attributeStack);\r\n attributeStack._changed = false;\r\n }\r\n } else if (\r\n this._applyTextureAttribute(textureUnit, attribute, attributeStack)\r\n ) {\r\n attributeStack._changed = true;\r\n }\r\n } else if (attributeStack._length) {\r\n attributeStack._changed = false;\r\n this._applyTextureAttribute(\r\n textureUnit,\r\n attributeStack._back.object,\r\n attributeStack\r\n );\r\n } else {\r\n attributeStack._changed = false;\r\n this._applyTextureAttribute(\r\n textureUnit,\r\n attributeStack._globalDefault,\r\n attributeStack\r\n );\r\n }\r\n }\r\n }\r\n },\r\n\r\n applyStateSet: function(stateset) {\r\n this._numApply++;\r\n\r\n var previousProgram = this.getLastProgramApplied();\r\n\r\n // needed before calling applyAttributeMap because\r\n // we cache needed StateAttribute from the compiler\r\n this._currentShaderGenerator = this.getCurrentShaderGeneratorStateSet(stateset);\r\n\r\n this._applyAttributeMapStateSet(this._attributeArray, stateset._attributeArray);\r\n this._applyTextureAttributeMapListStateSet(\r\n this._textureAttributeArrayList,\r\n stateset._textureAttributeArrayList\r\n );\r\n\r\n var lastApplied;\r\n if (this._currentShaderGenerator) {\r\n // no custom program look into the stack of ShaderGenerator name\r\n // what we should use to generate a program\r\n var generatedProgram = this._currentShaderGenerator.getOrCreateProgram(this);\r\n this.applyAttribute(generatedProgram);\r\n lastApplied = generatedProgram;\r\n\r\n // will cache uniform and apply them with the program\r\n this._applyGeneratedProgramUniforms(generatedProgram, stateset);\r\n } else {\r\n lastApplied = this.getLastProgramApplied();\r\n // custom program so we will iterate on uniform from the program and apply them\r\n // but in order to be able to use Attribute in the state graph we will check if\r\n // our program want them. It must be defined by the user\r\n this._applyCustomProgramUniforms(lastApplied, stateset);\r\n }\r\n\r\n // reset reference of last applied matrix\r\n if (previousProgram !== lastApplied) {\r\n this._lastAppliedModelViewMatrix = undefined;\r\n this._lastAppliedProjectionMatrix = undefined;\r\n }\r\n },\r\n\r\n popAllStateSets: function() {\r\n while (this._stateSets._length) {\r\n this.popStateSet();\r\n }\r\n },\r\n\r\n popStateSet: function() {\r\n if (!this._stateSets._length) return;\r\n\r\n var stateset = this._stateSets.pop();\r\n\r\n this.popAttributeMap(\r\n this._attributeArray,\r\n stateset._attributeArray,\r\n stateset._activeAttribute\r\n );\r\n\r\n var textureAttributeArrayList = stateset._textureAttributeArrayList;\r\n var activeTextureUnits = stateset._activeTextureAttributeUnit;\r\n var activeTextureAttribute = stateset._activeTextureAttribute;\r\n\r\n for (var i = 0, l = activeTextureUnits.length; i < l; i++) {\r\n var unit = activeTextureUnits[i];\r\n var _attributeArray = textureAttributeArrayList[unit];\r\n var textureUnitAttributeArray = this._textureAttributeArrayList[unit];\r\n this.popAttributeMap(\r\n textureUnitAttributeArray,\r\n _attributeArray,\r\n activeTextureAttribute\r\n );\r\n }\r\n\r\n if (stateset.hasUniform())\r\n this.popUniformsList(this._uniforms, stateset.getUniformList());\r\n\r\n if (stateset.getShaderGeneratorPair()) {\r\n this._shaderGeneratorNames.pop();\r\n }\r\n },\r\n\r\n _createAttributeStack: function(_attributeArray, typeIndex, globalDefault) {\r\n utils.arrayDense(typeIndex, _attributeArray);\r\n var attributeStack = new StackObjectPairPool();\r\n attributeStack._globalDefault = globalDefault;\r\n\r\n _attributeArray[typeIndex] = attributeStack;\r\n\r\n return attributeStack;\r\n },\r\n\r\n haveAppliedAttribute: function(attribute) {\r\n if (!attribute) return;\r\n\r\n var attributeArray = this._attributeArray;\r\n var index = utils.getOrCreateStateAttributeTypeMemberIndex(attribute);\r\n var attributeStack = index < attributeArray.length ? attributeArray[index] : undefined;\r\n if (!attributeStack) {\r\n attributeStack = this._createAttributeStack(\r\n attributeArray,\r\n index,\r\n attribute.cloneType()\r\n );\r\n }\r\n attributeStack._lastApplied = attribute;\r\n attributeStack._changed = true;\r\n },\r\n\r\n applyAttribute: function(attribute) {\r\n var index = utils.getOrCreateStateAttributeTypeMemberIndex(attribute);\r\n\r\n var attributeArray = this._attributeArray;\r\n var attributeStack = index < attributeArray.length ? attributeArray[index] : undefined;\r\n if (!attributeStack) {\r\n attributeStack = this._createAttributeStack(\r\n attributeArray,\r\n index,\r\n attribute.cloneType()\r\n );\r\n }\r\n\r\n attributeStack._changed = true;\r\n this._applyAttributeStack(attribute, attributeStack);\r\n },\r\n\r\n _applyAttributeStack: function(attribute, attributeStack) {\r\n if (attributeStack._lastApplied === attribute) return false;\r\n\r\n if (attribute.apply) attribute.apply(this);\r\n\r\n attributeStack._lastApplied = attribute;\r\n return true;\r\n },\r\n\r\n _applyTextureAttribute: function(unit, attribute, attributeStack) {\r\n if (attributeStack._lastApplied === attribute) return false;\r\n\r\n attributeStack._lastApplied = attribute;\r\n\r\n if (!attribute.apply) return true;\r\n\r\n var gl = this.getGraphicContext();\r\n gl.activeTexture(gl.TEXTURE0 + unit);\r\n\r\n // there is a texture we bind it.\r\n attribute.apply(this, unit);\r\n\r\n return true;\r\n },\r\n\r\n applyTextureAttribute: function(unit, attribute) {\r\n var index = utils.getOrCreateTextureStateAttributeTypeMemberIndex(attribute);\r\n var textureUnitAttributeArray = this.getOrCreateTextureAttributeArray(unit);\r\n var attributeStack = textureUnitAttributeArray[index];\r\n\r\n if (!attributeStack)\r\n attributeStack = this._createAttributeStack(\r\n textureUnitAttributeArray,\r\n index,\r\n attribute.cloneType()\r\n );\r\n\r\n attributeStack._changed = true;\r\n this._applyTextureAttribute(unit, attribute, attributeStack);\r\n },\r\n\r\n getLastProgramApplied: function() {\r\n return this._programAttribute._lastApplied;\r\n },\r\n\r\n applyDefault: function() {\r\n this.popAllStateSets();\r\n\r\n this._currentShaderGenerator = undefined;\r\n\r\n this.applyAttributeMap(this._attributeArray);\r\n this.applyTextureAttributeMapList(this._textureAttributeArrayList);\r\n },\r\n\r\n applyAttributeMap: function(_attributeArray) {\r\n var attributeStack;\r\n for (var i = 0, l = _attributeArray.length; i < l; i++) {\r\n attributeStack = _attributeArray[i];\r\n if (!attributeStack) continue;\r\n\r\n var attribute;\r\n if (attributeStack._length) attribute = attributeStack._back.object;\r\n else attribute = attributeStack._globalDefault;\r\n\r\n if (!attributeStack._changed) continue;\r\n\r\n if (attributeStack._lastApplied !== attribute) {\r\n if (attribute.apply) attribute.apply(this);\r\n\r\n attributeStack._lastApplied = attribute;\r\n }\r\n\r\n attributeStack._changed = false;\r\n }\r\n },\r\n\r\n pushUniformsList: function(uniformMap, stateSetUniformMap) {\r\n /*jshint bitwise: false */\r\n var name;\r\n var uniform;\r\n\r\n for (var key in stateSetUniformMap) {\r\n var uniformPair = stateSetUniformMap[key];\r\n uniform = uniformPair.getUniform();\r\n name = uniform.getName();\r\n if (!uniformMap[name]) {\r\n this._createAttributeStack(uniformMap, name, uniform);\r\n }\r\n\r\n this.pushCheckOverride(uniformMap[name], uniform, uniformPair.getValue());\r\n }\r\n /*jshint bitwise: true */\r\n },\r\n\r\n popUniformsList: function(uniformMap, stateSetUniformMap) {\r\n for (var key in stateSetUniformMap) {\r\n uniformMap[key].pop();\r\n }\r\n },\r\n\r\n applyTextureAttributeMapList: function(textureAttributeArrayList) {\r\n var gl = this._graphicContext;\r\n var textureAttributeArray;\r\n\r\n for (\r\n var textureUnit = 0, l = textureAttributeArrayList.length; textureUnit < l; textureUnit++\r\n ) {\r\n textureAttributeArray = textureAttributeArrayList[textureUnit];\r\n if (!textureAttributeArray) continue;\r\n\r\n for (var i = 0, lt = textureAttributeArray.length; i < lt; i++) {\r\n var attributeStack = textureAttributeArray[i];\r\n\r\n // skip if not stack or not changed in stack\r\n if (!attributeStack) continue;\r\n\r\n var attribute;\r\n if (attributeStack._length) attribute = attributeStack._back.object;\r\n else attribute = attributeStack._globalDefault;\r\n\r\n if (!attributeStack._changed) continue;\r\n\r\n // if the the stack has changed but the last applied attribute is the same\r\n // then we dont need to apply it again\r\n if (attributeStack._lastApplied !== attribute) {\r\n gl.activeTexture(gl.TEXTURE0 + textureUnit);\r\n attribute.apply(this, textureUnit);\r\n\r\n attributeStack._lastApplied = attribute;\r\n }\r\n\r\n attributeStack._changed = false;\r\n }\r\n }\r\n },\r\n\r\n setGlobalDefaultAttribute: function(attribute) {\r\n var index = utils.getOrCreateStateAttributeTypeMemberIndex(attribute);\r\n if (index >= this._attributeArray.length || !this._attributeArray[index]) {\r\n this._createAttributeStack(this._attributeArray, index, attribute);\r\n } else {\r\n this._attributeArray[index]._globalDefault = attribute;\r\n }\r\n },\r\n\r\n getGlobalDefaultAttribute: function(typeMember) {\r\n var _attributeArray = this._attributeArray;\r\n var index = utils.getIdFromTypeMember(typeMember);\r\n if (index === undefined || index >= _attributeArray.length) return undefined;\r\n return _attributeArray[index] ? _attributeArray[index]._globalDefault : undefined;\r\n },\r\n\r\n setGlobalDefaultTextureAttribute: function(unit, attribute) {\r\n var attributeArray = this.getOrCreateTextureAttributeArray(unit);\r\n var index = utils.getOrCreateTextureStateAttributeTypeMemberIndex(attribute);\r\n\r\n if (index >= attributeArray.length || !attributeArray[index]) {\r\n this._createAttributeStack(attributeArray, index, attribute);\r\n } else {\r\n attributeArray[index]._globalDefault = attribute;\r\n }\r\n },\r\n\r\n getGlobalDefaultTextureAttribute: function(unit, typeMember) {\r\n var attributeArray = this.getOrCreateTextureAttributeArray(unit);\r\n var index = utils.getTextureIdFromTypeMember(typeMember);\r\n if (index === undefined || index >= attributeArray.length) return undefined;\r\n return attributeArray[index] ? attributeArray[index]._globalDefault : undefined;\r\n },\r\n\r\n getOrCreateTextureAttributeArray: function(unit) {\r\n utils.arrayDense(unit, this._textureAttributeArrayList);\r\n\r\n if (!this._textureAttributeArrayList[unit]) this._textureAttributeArrayList[unit] = [];\r\n return this._textureAttributeArrayList[unit];\r\n },\r\n\r\n pushAttributeMap: function(_attributeArray, stateSetAttributeArray, validAttributeArray) {\r\n /*jshint bitwise: false */\r\n var attributeStack;\r\n var stateSetAttributeArrayLength = stateSetAttributeArray.length;\r\n var _attributeArrayLength = _attributeArray.length;\r\n for (var i = 0, l = validAttributeArray.length; i < l; i++) {\r\n var index = validAttributeArray[i];\r\n var attributePair =\r\n index < stateSetAttributeArrayLength ?\r\n stateSetAttributeArray[index] :\r\n undefined;\r\n var attribute = attributePair.getAttribute();\r\n\r\n attributeStack = index < _attributeArrayLength ? _attributeArray[index] : undefined;\r\n if (!attributeStack) {\r\n attributeStack = this._createAttributeStack(\r\n _attributeArray,\r\n index,\r\n attribute.cloneType()\r\n );\r\n }\r\n\r\n this.pushCheckOverride(attributeStack, attribute, attributePair.getValue());\r\n attributeStack._changed = true;\r\n }\r\n },\r\n\r\n popAttributeMap: function(_attributeArray, stateSetAttributeArray, activeAttribute) {\r\n for (var i = 0, l = activeAttribute.length; i < l; i++) {\r\n var index = activeAttribute[i];\r\n var attributeStack = _attributeArray[index];\r\n\r\n attributeStack.pop();\r\n attributeStack._changed = true;\r\n }\r\n },\r\n\r\n setIndexArray: function(array) {\r\n var gl = this._graphicContext;\r\n\r\n if (this._currentIndexVBO !== array) {\r\n array.bind(gl);\r\n this._currentIndexVBO = array;\r\n }\r\n\r\n if (array.isDirty()) {\r\n array.compile(gl);\r\n }\r\n },\r\n\r\n lazyDisablingOfVertexAttributes: function() {\r\n var keys = this._vertexAttribMap._keys;\r\n for (var i = 0, l = keys.length; i < l; i++) {\r\n var attr = keys[i];\r\n if (this._vertexAttribMap[attr]) {\r\n this._vertexAttribMap._disable[attr] = true;\r\n }\r\n }\r\n },\r\n\r\n enableVertexColor: function() {\r\n var program = this._programAttribute._lastApplied;\r\n\r\n if (!program.getUniformsCache().uArrayColorEnabled ||\r\n !program.getAttributesCache().Color\r\n )\r\n return; // no color uniform or attribute used, exit\r\n\r\n // update uniform\r\n var uniform = this._uniforms.ArrayColorEnabled._globalDefault;\r\n\r\n var previousColorEnabled = this._previousColorAttribPair[program.getInstanceID()];\r\n\r\n if (!previousColorEnabled) {\r\n uniform.setFloat(1.0);\r\n uniform.apply(\r\n this.getGraphicContext(),\r\n program.getUniformsCache().uArrayColorEnabled\r\n );\r\n this._previousColorAttribPair[program.getInstanceID()] = true;\r\n }\r\n },\r\n\r\n disableVertexColor: function() {\r\n var program = this._programAttribute._lastApplied;\r\n\r\n if (!program.getUniformsCache().uArrayColorEnabled ||\r\n !program.getAttributesCache().Color\r\n )\r\n return; // no color uniform or attribute used, exit\r\n\r\n // update uniform\r\n var uniform = this._uniforms.ArrayColorEnabled._globalDefault;\r\n\r\n var previousColorEnabled = this._previousColorAttribPair[program.getInstanceID()];\r\n\r\n if (previousColorEnabled) {\r\n uniform.setFloat(0.0);\r\n uniform.apply(\r\n this.getGraphicContext(),\r\n program.getUniformsCache().uArrayColorEnabled\r\n );\r\n this._previousColorAttribPair[program.getInstanceID()] = false;\r\n }\r\n },\r\n\r\n applyDisablingOfVertexAttributes: function() {\r\n var keys = this._vertexAttribMap._keys;\r\n for (var i = 0, l = keys.length; i < l; i++) {\r\n if (this._vertexAttribMap._disable[keys[i]] === true) {\r\n var attr = keys[i];\r\n this._graphicContext.disableVertexAttribArray(attr);\r\n this._vertexAttribMap._disable[attr] = false;\r\n this._vertexAttribMap[attr] = false;\r\n }\r\n }\r\n },\r\n\r\n clearVertexAttribCache: function() {\r\n var vertexAttribMap = this._vertexAttribMap;\r\n var keys = vertexAttribMap._keys;\r\n for (var i = 0, l = keys.length; i < l; i++) {\r\n var attr = keys[i];\r\n vertexAttribMap[attr] = undefined;\r\n vertexAttribMap._disable[attr] = false;\r\n }\r\n\r\n this._vertexAttribMap._disable.length = 0;\r\n this._vertexAttribMap._keys.length = 0;\r\n },\r\n\r\n /**\r\n * set a vertex array object.\r\n * return true if binded the vao and false\r\n * if was already binded\r\n */\r\n setVertexArrayObject: function(vao) {\r\n if (this._currentVAO === vao) return false;\r\n\r\n this._currentVAO = vao;\r\n\r\n if (vao) {\r\n vao.bind(this._graphicContext);\r\n } else {\r\n // disable cache to force a re enable of array\r\n this._graphicContext.bindVertexArray(null);\r\n this.clearVertexAttribCache();\r\n }\r\n\r\n // disable currentIndexVBO to force to bind indexArray from Geometry\r\n // if there is a change of vao\r\n this._currentIndexVBO = undefined;\r\n\r\n return true;\r\n },\r\n\r\n setVertexAttribArray: function(attrib, array, normalize) {\r\n var vertexAttribMap = this._vertexAttribMap;\r\n vertexAttribMap._disable[attrib] = false;\r\n var gl = this._graphicContext;\r\n var binded = false;\r\n\r\n if (array.isDirty()) {\r\n array.bind(gl);\r\n array.compile(gl);\r\n binded = true;\r\n }\r\n\r\n var currentArray = vertexAttribMap[attrib];\r\n if (currentArray !== array) {\r\n if (!binded) {\r\n array.bind(gl);\r\n }\r\n\r\n if (!currentArray) {\r\n gl.enableVertexAttribArray(attrib);\r\n\r\n // can be === false (so undefined check is important)\r\n if (currentArray === undefined) vertexAttribMap._keys.push(attrib);\r\n }\r\n\r\n vertexAttribMap[attrib] = array;\r\n gl.vertexAttribPointer(\r\n attrib,\r\n array.getItemSize(),\r\n array.getType(),\r\n normalize,\r\n 0,\r\n 0\r\n );\r\n }\r\n },\r\n\r\n _getActiveUniformsFromProgramAttributes: function(program, activeUniformsList) {\r\n var _attributeArrayStack = this._attributeArray;\r\n\r\n var attributeKeys = program.getTrackAttributes().attributeKeys;\r\n\r\n if (attributeKeys.length > 0) {\r\n for (var i = 0, l = attributeKeys.length; i < l; i++) {\r\n var key = attributeKeys[i];\r\n var index = this.typeMember[key];\r\n var attributeStack = _attributeArrayStack[index];\r\n if (!attributeStack) {\r\n continue;\r\n }\r\n\r\n // we just need the uniform list and not the attribute itself\r\n var attribute = attributeStack._globalDefault;\r\n if (!attribute.getOrCreateUniforms) {\r\n continue;\r\n }\r\n\r\n var uniformMap = attribute.getOrCreateUniforms();\r\n for (var keyUniform in uniformMap) {\r\n activeUniformsList.push(uniformMap[keyUniform]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _getActiveUniformsFromProgramTextureAttributes: function(program, activeUniformsList) {\r\n var textureAttributeKeysList = program.getTrackAttributes().textureAttributeKeys;\r\n if (!textureAttributeKeysList) return;\r\n\r\n for (var unit = 0, nbUnit = textureAttributeKeysList.length; unit < nbUnit; unit++) {\r\n var textureAttributeKeys = textureAttributeKeysList[unit];\r\n if (!textureAttributeKeys) continue;\r\n\r\n var unitTextureAttributeList = this._textureAttributeArrayList[unit];\r\n if (!unitTextureAttributeList) continue;\r\n\r\n for (var i = 0, l = textureAttributeKeys.length; i < l; i++) {\r\n var key = textureAttributeKeys[i];\r\n\r\n var attributeStack = unitTextureAttributeList[key];\r\n if (!attributeStack) {\r\n continue;\r\n }\r\n // we just need the uniform list and not the attribute itself\r\n var attribute = attributeStack._globalDefault;\r\n if (!attribute.getOrCreateUniforms) {\r\n continue;\r\n }\r\n var uniformMap = attribute.getOrCreateUniforms();\r\n for (var keyUniform in uniformMap) {\r\n activeUniformsList.push(uniformMap[keyUniform]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _cacheUniformsForCustomProgram: function(program, activeUniformsList) {\r\n this._getActiveUniformsFromProgramAttributes(program, activeUniformsList);\r\n\r\n this._getActiveUniformsFromProgramTextureAttributes(program, activeUniformsList);\r\n\r\n var gl = this._graphicContext;\r\n\r\n // now we have a list on uniforms we want to track but we will filter them to use only what is needed by our program\r\n // not that if you create a uniforms whith the same name of a tracked attribute, and it will override it\r\n var uniformsFinal = {};\r\n\r\n for (var i = 0, l = activeUniformsList.length; i < l; i++) {\r\n var u = activeUniformsList[i];\r\n var uniformName = u.getName();\r\n var loc = gl.getUniformLocation(program._program, uniformName);\r\n if (loc !== undefined && loc !== null) {\r\n uniformsFinal[uniformName] = u;\r\n }\r\n }\r\n program.trackUniforms = uniformsFinal;\r\n },\r\n\r\n _applyCustomProgramUniforms: (function() {\r\n var activeUniformsList = [];\r\n\r\n return function(program, stateset) {\r\n // custom program so we will iterate on uniform from the program and apply them\r\n // but in order to be able to use Attribute in the state graph we will check if\r\n // our program want them. It must be defined by the user\r\n\r\n // first time we see attributes key, so we will keep a list of uniforms from attributes\r\n activeUniformsList.length = 0;\r\n\r\n // fill the program with cached active uniforms map from attributes and texture attributes\r\n if (\r\n program.getTrackAttributes() !== undefined &&\r\n program.trackUniforms === undefined\r\n ) {\r\n this._cacheUniformsForCustomProgram(program, activeUniformsList);\r\n }\r\n\r\n var programUniformMap = program.getUniformsCache();\r\n var uniformMapStack = this._uniforms;\r\n\r\n var programTrackUniformMap;\r\n if (program.trackUniforms) programTrackUniformMap = program.trackUniforms;\r\n\r\n var uniform;\r\n for (var uniformName in programUniformMap) {\r\n var location = programUniformMap[uniformName];\r\n var uniformStack = uniformMapStack[uniformName];\r\n\r\n var hasStateSetUniformPair = stateset && stateset.uniforms[uniformName];\r\n\r\n if (!uniformStack && !hasStateSetUniformPair) {\r\n if (programTrackUniformMap === undefined) {\r\n this._checkErrorUniform(uniformName);\r\n continue;\r\n }\r\n\r\n uniform = programTrackUniformMap[uniformName];\r\n } else if (hasStateSetUniformPair) {\r\n var stateSetUniformPair = stateset.uniforms[uniformName];\r\n var maskValue = stateSetUniformPair.getValue();\r\n var stateSetUniform = stateSetUniformPair.getUniform();\r\n if (uniformStack)\r\n uniform = this._evaluateOverrideObjectOnStack(\r\n uniformStack,\r\n stateSetUniform,\r\n maskValue\r\n );\r\n else uniform = stateSetUniform;\r\n } else if (uniformStack._length) {\r\n uniform = uniformStack._back.object;\r\n } else {\r\n uniform = uniformStack._globalDefault;\r\n }\r\n\r\n uniform.apply(this._graphicContext, location);\r\n }\r\n };\r\n })(),\r\n\r\n _checkErrorUniform: function(uniformName) {\r\n var unit = uniformName.substr(7);\r\n if (this._textureAttributeArrayList[unit] && uniformName === 'Texture' + unit) {\r\n return;\r\n }\r\n\r\n if (this._excludeUniforms[uniformName]) {\r\n return;\r\n }\r\n\r\n this._excludeUniforms[uniformName] = 1; // avoid multiple spammy errors\r\n\r\n notify.error('Uniform not in the scene hierarchy : ' + uniformName);\r\n },\r\n\r\n _computeForeignUniforms: function(programUniformMap, activeUniformMap) {\r\n var foreignUniforms = [];\r\n\r\n for (var keyUniform in programUniformMap) {\r\n var location = programUniformMap[keyUniform];\r\n\r\n // filter 'standard' uniform matrix that will be applied for all shader\r\n if (location !== undefined && activeUniformMap[keyUniform] === undefined) {\r\n if (!this._excludeUniforms[keyUniform]) {\r\n foreignUniforms.push(keyUniform);\r\n }\r\n }\r\n }\r\n\r\n return foreignUniforms;\r\n },\r\n\r\n _removeUniformsNotRequiredByProgram: function(activeUniformMap, programUniformMap) {\r\n for (var keyUniform in activeUniformMap) {\r\n var location = programUniformMap[keyUniform];\r\n if (location === undefined || location === null) {\r\n delete activeUniformMap[keyUniform];\r\n }\r\n }\r\n },\r\n\r\n _cacheUniformsForGeneratedProgram: function(program) {\r\n var shaderUniforms = program.getUniformsCache(); // declared in the shader\r\n var stateSetUniforms = program.getActiveUniforms(); // present in last stateset\r\n\r\n var foreignUniforms = this._computeForeignUniforms(shaderUniforms, stateSetUniforms);\r\n program.setForeignUniforms(foreignUniforms);\r\n\r\n // remove uniforms listed by attributes (getActiveUniforms) but not required by the program\r\n this._removeUniformsNotRequiredByProgram(stateSetUniforms, shaderUniforms);\r\n },\r\n\r\n _copyUniformEntry: function(uniform) {\r\n var internalArray = uniform.getInternalArray();\r\n var cacheData;\r\n if (internalArray.length < 16) {\r\n cacheData = new internalArray.constructor(internalArray.length);\r\n }\r\n\r\n return cacheData;\r\n },\r\n\r\n _initUniformCache: function(program) {\r\n var activeUniformMap = program.getActiveUniforms();\r\n\r\n var foreignUniformKeys = program.getForeignUniforms();\r\n var uniformMapStack = this._uniforms;\r\n\r\n var cacheForeignUniforms = [];\r\n var cacheActiveUniforms = [];\r\n\r\n var i, l, cache, name, cacheData, uniform;\r\n\r\n program._cacheUniformId = this._cacheUniformId++;\r\n this._programUniformCache[program._cacheUniformId] = {};\r\n\r\n if (foreignUniformKeys.length) {\r\n cache = cacheForeignUniforms;\r\n for (i = 0, l = foreignUniformKeys.length; i < l; i++) {\r\n name = foreignUniformKeys[i];\r\n var uniStack = uniformMapStack[name];\r\n if (uniStack) {\r\n uniform = uniStack._globalDefault;\r\n cacheData = this._copyUniformEntry(uniform);\r\n cache.push(cacheData);\r\n }\r\n }\r\n }\r\n\r\n for (var keyUniform in activeUniformMap) {\r\n uniform = activeUniformMap[keyUniform];\r\n cacheData = this._copyUniformEntry(uniform);\r\n cacheActiveUniforms.push(cacheData);\r\n }\r\n\r\n this._programUniformCache[program._cacheUniformId].foreign = cacheForeignUniforms;\r\n this._programUniformCache[program._cacheUniformId].active = cacheActiveUniforms;\r\n },\r\n\r\n _checkCacheAndApplyUniform: function(\r\n uniform,\r\n cacheArray,\r\n indexCache,\r\n programUniformMap,\r\n nameUniform\r\n ) {\r\n var isCached;\r\n var internalArray = uniform.getInternalArray();\r\n var uniformArrayLength = internalArray.length;\r\n if (uniformArrayLength <= 4) {\r\n var uniformCache = cacheArray[indexCache];\r\n isCached = checkUniformCache[uniformArrayLength](internalArray, uniformCache);\r\n } else {\r\n isCached = false;\r\n }\r\n\r\n if (!isCached) {\r\n var location = programUniformMap[nameUniform];\r\n uniform.apply(this._graphicContext, location);\r\n }\r\n },\r\n\r\n // note that about TextureAttribute that need uniform on unit we would need to improve\r\n // the current uniformList ...\r\n\r\n // when we apply the shader for the first time, we want to compute the active uniforms for this shader and the list of uniforms not extracted from attributes called foreignUniforms\r\n _applyGeneratedProgramUniforms: function(program, stateset) {\r\n var uniformMapStack = this._uniforms;\r\n var uniform, uniformName, uniformStack, i;\r\n\r\n var foreignUniformKeys = program.getForeignUniforms();\r\n if (!foreignUniformKeys) {\r\n this._cacheUniformsForGeneratedProgram(program);\r\n foreignUniformKeys = program.getForeignUniforms();\r\n\r\n // be sure to create a stack for foreign uniform for this program\r\n // it's needed to do it here because of the cache of uniform\r\n if (stateset) {\r\n var stateSetUniforms = stateset.uniforms;\r\n for (i = 0; i < foreignUniformKeys.length; i++) {\r\n uniformName = foreignUniformKeys[i];\r\n\r\n // already exist\r\n if (uniformMapStack[uniformName]) continue;\r\n\r\n // does not exist check to initialize with stateSet uniforms\r\n if (!stateSetUniforms[uniformName]) continue;\r\n\r\n uniform = stateSetUniforms[uniformName].getUniform();\r\n this._createAttributeStack(uniformMapStack, uniformName, uniform);\r\n }\r\n }\r\n\r\n this._initUniformCache(program);\r\n }\r\n\r\n var programUniformMap = program.getUniformsCache();\r\n var activeUniformMap = program.getActiveUniforms();\r\n\r\n var cacheUniformsActive = this._programUniformCache[program._cacheUniformId].active;\r\n var cacheUniformsForeign = this._programUniformCache[program._cacheUniformId].foreign;\r\n\r\n // apply active uniforms\r\n // caching uniforms from attribtues make it impossible to overwrite uniform with a custom uniform instance not used in the attributes\r\n var indexCache = 0;\r\n for (var keyUniform in activeUniformMap) {\r\n uniform = activeUniformMap[keyUniform];\r\n this._checkCacheAndApplyUniform(\r\n uniform,\r\n cacheUniformsActive,\r\n indexCache,\r\n programUniformMap,\r\n keyUniform\r\n );\r\n indexCache++; // TODO not good, for in ordered consistency, etc...\r\n }\r\n\r\n // apply now foreign uniforms, it's uniforms needed by the program but not contains in attributes used to generate this program\r\n indexCache = 0;\r\n var nbForeigns = foreignUniformKeys.length;\r\n for (i = 0; i < nbForeigns; i++) {\r\n uniformName = foreignUniformKeys[i];\r\n\r\n uniformStack = uniformMapStack[uniformName];\r\n var hasStateSetUniformPair = stateset && stateset.uniforms[uniformName];\r\n\r\n if (!hasStateSetUniformPair && !uniformStack) {\r\n this._checkErrorUniform(uniformName);\r\n continue;\r\n }\r\n\r\n if (hasStateSetUniformPair) {\r\n var stateSetUniformPair = stateset.uniforms[uniformName];\r\n var maskValue = stateSetUniformPair.getValue();\r\n var stateSetUniform = stateSetUniformPair.getUniform();\r\n uniform = this._evaluateOverrideObjectOnStack(\r\n uniformStack,\r\n stateSetUniform,\r\n maskValue\r\n );\r\n } else if (uniformStack._length) {\r\n uniform = uniformStack._back.object;\r\n } else {\r\n uniform = uniformStack._globalDefault;\r\n this._checkErrorUniform(uniformName);\r\n }\r\n\r\n this._checkCacheAndApplyUniform(\r\n uniform,\r\n cacheUniformsForeign,\r\n indexCache,\r\n programUniformMap,\r\n uniformName\r\n );\r\n indexCache++;\r\n }\r\n },\r\n\r\n // Use to detect changes in RenderLeaf between call to avoid to applyStateSet\r\n _setStateSetsDrawID: function(id) {\r\n var values = this._stateSets.getArray();\r\n for (var i = 0, nbStateSets = this._stateSets.length; i < nbStateSets; i++) {\r\n values[i].setDrawID(id);\r\n }\r\n },\r\n\r\n _stateSetStackChanged: function(id, nbLast) {\r\n var values = this._stateSets.getArray();\r\n var nbStateSets = this._stateSets.length;\r\n if (nbLast !== nbStateSets) return true;\r\n\r\n for (var i = 0; i < nbStateSets; i++) {\r\n if (id !== values[i].getDrawID()) return true;\r\n }\r\n\r\n return false;\r\n }\r\n }),\r\n 'osg',\r\n 'State'\r\n);\r\n\r\nexport default State;","/**\r\n * DrawArrayLengths manage rendering primitives\r\n * @class DrawArrayLengths\r\n */\r\nvar DrawArrayLengths = function(mode, first, array) {\r\n this._mode = mode;\r\n this._first = first;\r\n this._arrayLengths = array.slice(0);\r\n};\r\n\r\n/** @lends DrawArrayLengths.prototype */\r\nDrawArrayLengths.prototype = {\r\n draw: function(state) {\r\n var gl = state.getGraphicContext();\r\n var mode = this._mode;\r\n var first = this._first;\r\n var array = this._arrayLengths;\r\n for (var i = 0, l = array.length; i < l; i++) {\r\n var count = array[i];\r\n gl.drawArrays(mode, first, count);\r\n first += count;\r\n }\r\n },\r\n getMode: function() {\r\n return this._mode;\r\n },\r\n getNumIndices: function() {\r\n var count = 0;\r\n var array = this._arrayLengths;\r\n for (var i = 0, l = array.length; i < l; i++) {\r\n count += array[i];\r\n }\r\n return count;\r\n },\r\n getCount: function() {\r\n return this.getNumIndices();\r\n },\r\n getArrayLengths: function() {\r\n return this._arrayLengths;\r\n },\r\n getFirst: function() {\r\n return this._first;\r\n },\r\n setFirst: function(first) {\r\n this._first = first;\r\n }\r\n};\r\n\r\nexport default DrawArrayLengths;\r\n","export default \"#pragma include \\\"colorEncode.glsl\\\"\\r\\n\\r\\n#pragma DECLARE_FUNCTION\\r\\nvec4 shadowCast(const in vec4 fragEye, const in vec2 shadowDepthRange){\\r\\n // distance to camera (we make sure we are near 0 and in [0,1])\\r\\n float depth = (-fragEye.z * fragEye.w - shadowDepthRange.x) / (shadowDepthRange.y - shadowDepthRange.x);\\r\\n\\r\\n#ifdef _FLOATTEX\\r\\n return vec4(depth, 0.0, 0.0, 1.0);\\r\\n#else\\r\\n return encodeFloatRGBA(depth);\\r\\n#endif\\r\\n}\\r\\n\";","export default \"#ifdef _OUT_DISTANCE\\r\\n#define OPT_ARG_outDistance ,out float outDistance\\r\\n#define OPT_INSTANCE_ARG_outDistance ,outDistance\\r\\n#else\\r\\n#define OPT_ARG_outDistance\\r\\n#define OPT_INSTANCE_ARG_outDistance\\r\\n#endif\\r\\n\\r\\n#ifdef _ATLAS_SHADOW\\r\\n#define OPT_ARG_atlasSize ,const in vec4 atlasSize\\r\\n#else\\r\\n#define OPT_ARG_atlasSize\\r\\n#endif\\r\\n\\r\\n#ifdef _NORMAL_OFFSET\\r\\n#define OPT_ARG_normalBias ,const in float normalBias\\r\\n#else\\r\\n#define OPT_ARG_normalBias\\r\\n#endif\\r\\n\\r\\n#ifdef _JITTER_OFFSET\\r\\n#define OPT_ARG_jitter ,const in float jitter\\r\\n#define OPT_INSTANCE_ARG_jitter ,jitter\\r\\n#else\\r\\n#define OPT_ARG_jitter\\r\\n#define OPT_INSTANCE_ARG_jitter\\r\\n#endif\\r\\n\\r\\n#pragma include \\\"tapPCF.glsl\\\"\\r\\n\\r\\n#pragma DECLARE_FUNCTION DERIVATIVES:enable\\r\\nfloat shadowReceive(const in bool lighted,\\r\\n const in vec3 normalWorld,\\r\\n const in vec3 vertexWorld,\\r\\n\\r\\n const in sampler2D shadowTexture,\\r\\n\\r\\n const in vec2 shadowSize,\\r\\n const in vec3 shadowProjection,\\r\\n\\r\\n const in vec4 shadowViewRight,\\r\\n const in vec4 shadowViewUp,\\r\\n const in vec4 shadowViewLook,\\r\\n\\r\\n\\r\\n const in vec2 shadowDepthRange,\\r\\n const in float shadowBias\\r\\n OPT_ARG_atlasSize\\r\\n OPT_ARG_normalBias\\r\\n OPT_ARG_outDistance\\r\\n OPT_ARG_jitter) {\\r\\n\\r\\n // 0 for early out\\r\\n bool earlyOut = false;\\r\\n\\r\\n // Calculate shadow amount\\r\\n float shadow = 1.0;\\r\\n\\r\\n if (!lighted) {\\r\\n shadow = 0.0;\\r\\n#ifndef _OUT_DISTANCE\\r\\n earlyOut = true;\\r\\n#endif // _OUT_DISTANCE\\r\\n }\\r\\n\\r\\n if (shadowDepthRange.x == shadowDepthRange.y) {\\r\\n earlyOut = true;\\r\\n }\\r\\n\\r\\n vec4 shadowVertexEye;\\r\\n vec4 shadowNormalEye;\\r\\n float shadowReceiverZ = 0.0;\\r\\n vec4 shadowVertexProjected;\\r\\n vec2 shadowUV;\\r\\n float N_Dot_L;\\r\\n float invDepthRange;\\r\\n\\r\\n if (!earlyOut) {\\r\\n\\r\\n shadowVertexEye.x = dot(shadowViewRight.xyz, vertexWorld.xyz) + shadowViewRight.w;\\r\\n shadowVertexEye.y = dot(shadowViewUp.xyz, vertexWorld.xyz) + shadowViewUp.w;\\r\\n shadowVertexEye.z = dot(shadowViewLook.xyz, vertexWorld.xyz) + shadowViewLook.w;\\r\\n shadowVertexEye.w = 1.0;\\r\\n\\r\\n\\r\\n // derivated, only need z.\\r\\n //vec3 shadowLightDir = vec3(0.0, 0.0, 1.0); // in shadow view light is camera\\r\\n //shadowNormalEye = shadowViewMatrix * normalFront;\\r\\n //shadowNormalEye.x = dot(shadowViewRight.xyz, normalWorld.xyz);\\r\\n //shadowNormalEye.y = dot(shadowViewUp.xyz, normalWorld.xyz);\\r\\n shadowNormalEye.z = dot(shadowViewLook.xyz, normalWorld.xyz);\\r\\n //shadowNormalEye.w = 0.0;\\r\\n\\r\\n //N_Dot_L = dot(shadowNormalEye.xyz, shadowLightDir);\\r\\n N_Dot_L = shadowNormalEye.z;\\r\\n\\r\\n if (!earlyOut) {\\r\\n\\r\\n invDepthRange = 1.0 / (shadowDepthRange.y - shadowDepthRange.x);\\r\\n\\r\\n#ifdef _NORMAL_OFFSET\\r\\n\\r\\n // http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png\\r\\n float normalOffsetScale = clamp(1.0 - N_Dot_L, 0.0 , 1.0);\\r\\n normalOffsetScale *= abs((shadowVertexEye.z - shadowDepthRange.x) * invDepthRange);\\r\\n normalOffsetScale *= max(shadowProjection.x, shadowProjection.y);\\r\\n normalOffsetScale *= normalBias * invDepthRange;\\r\\n\\r\\n\\r\\n vec4 shadowNormalShift = vec4(normalWorld, 0.0) * normalOffsetScale;\\r\\n shadowNormalEye.x = dot(shadowViewRight.xyz, shadowNormalShift.xyz);\\r\\n shadowNormalEye.y = dot(shadowViewUp.xyz, shadowNormalShift.xyz);\\r\\n shadowNormalEye.z = dot(shadowViewLook.xyz, shadowNormalShift.xyz);\\r\\n shadowNormalEye.w = 0.0;\\r\\n\\r\\n vec4 viewShadow = shadowVertexEye + shadowNormalEye;\\r\\n#else\\r\\n vec4 viewShadow = shadowVertexEye;\\r\\n#endif\\r\\n\\r\\n\\r\\n if (shadowProjection.z == 0.0){\\r\\n\\r\\n // X, 0, 0, 0,\\r\\n // 0, Y, 0, 0,\\r\\n // 0, 0, -1, -1,\\r\\n // 0, 0, -2.0*znear, 0\\r\\n // mat4 shadowProjectionMatrix;\\r\\n // shadowProjectionMatrix[0] = vec4(shadowProjection.x, 0.0, 0.0, 0.0 );\\r\\n // shadowProjectionMatrix[1] = vec4(0.0, shadowProjection.y, 0.0, 0.0 );\\r\\n // shadowProjectionMatrix[2] = vec4(0.0, 0.0, -1.0, -1.0 );\\r\\n // shadowProjectionMatrix[3] = vec4(0.0, 0.0, -2.0*shadowDepthRange.x, 0.0 );\\r\\n // shadowVertexProjected = shadowProjectionMatrix * shadowVertexEye;\\r\\n\\r\\n // derivated optimisation\\r\\n shadowVertexProjected.x = shadowProjection.x * viewShadow.x;\\r\\n shadowVertexProjected.y = shadowProjection.y * viewShadow.y;\\r\\n\\r\\n shadowVertexProjected.z = - viewShadow.z - (2.0 * shadowDepthRange.x * viewShadow.w);\\r\\n shadowVertexProjected.w = - viewShadow.z;\\r\\n\\r\\n }\\r\\n else{\\r\\n // lr = 1/(left-right);\\r\\n // bt = 1/(bottom-top);\\r\\n // nf = 1/(near-far);\\r\\n // -2*lr, 0, 0, 0,\\r\\n // 0, -2*bt, 0, 0,\\r\\n // 0, 0, 2*nf, 0.0,\\r\\n // (left+right)*lr, (top+bottom)*bt, (far+near)*nf), 1\\r\\n // here left = -right && top = -bottom\\r\\n // float lr = 1.0 / (-2.0 * shadowProjection.x);\\r\\n // float bt = 1.0 / (-2.0 * shadowProjection.y);\\r\\n // float nf = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\\r\\n float nfNeg = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\\r\\n float nfPos = (shadowDepthRange.x + shadowDepthRange.y)*nfNeg;\\r\\n\\r\\n //mat4 shadowProjectionMatrix;\\r\\n //shadowProjectionMatrix[0] = vec4(1.0 / shadowProjection.x, 0.0, 0.0, 0.0 );\\r\\n //shadowProjectionMatrix[1] = vec4(0.0, 1.0 / shadowProjection.y, 0.0, 0.0 );\\r\\n //shadowProjectionMatrix[2] = vec4(0.0, 0.0, 2.0*nfNeg, 0.0 );\\r\\n //shadowProjectionMatrix[3] = vec4(0.0, 0.0, nfPos, 1.0 );\\r\\n //shadowdertexProjected = shadowProjectionMatrix * shadowVertexEye;\\r\\n\\r\\n // derivated optimisation\\r\\n shadowVertexProjected.x = viewShadow.x / shadowProjection.x;\\r\\n shadowVertexProjected.y = viewShadow.y / shadowProjection.y;\\r\\n\\r\\n shadowVertexProjected.z = 2.0 * nfNeg* viewShadow.z + nfPos * viewShadow.w;\\r\\n shadowVertexProjected.w = viewShadow.w;\\r\\n\\r\\n }\\r\\n\\r\\n\\r\\n if (shadowVertexProjected.w < 0.0) {\\r\\n earlyOut = true; // notably behind camera\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n if (!earlyOut) {\\r\\n\\r\\n shadowUV.xy = shadowVertexProjected.xy / shadowVertexProjected.w;\\r\\n shadowUV.xy = shadowUV.xy * 0.5 + 0.5;// mad like\\r\\n\\r\\n if (any(bvec4 ( shadowUV.x > 1., shadowUV.x < 0., shadowUV.y > 1., shadowUV.y < 0.))) {\\r\\n earlyOut = true;// limits of light frustum\\r\\n }\\r\\n\\r\\n // most precision near 0, make sure we are near 0 and in [0,1]\\r\\n shadowReceiverZ = - shadowVertexEye.z;\\r\\n shadowReceiverZ = (shadowReceiverZ - shadowDepthRange.x) * invDepthRange;\\r\\n\\r\\n if(shadowReceiverZ < 0.0) {\\r\\n earlyOut = true; // notably behind camera\\r\\n }\\r\\n\\r\\n }\\r\\n }\\r\\n\\r\\n // pcf pbias to add on offset\\r\\n vec2 shadowBiasPCF = vec2 (0.);\\r\\n\\r\\n#ifdef GL_OES_standard_derivatives\\r\\n#ifdef _RECEIVERPLANEDEPTHBIAS\\r\\n vec2 biasUV;\\r\\n\\r\\n vec3 texCoordDY = dFdx(shadowVertexEye.xyz);\\r\\n vec3 texCoordDX = dFdy(shadowVertexEye.xyz);\\r\\n\\r\\n biasUV.x = texCoordDY.y * texCoordDX.z - texCoordDX.y * texCoordDY.z;\\r\\n biasUV.y = texCoordDX.x * texCoordDY.z - texCoordDY.x * texCoordDX.z;\\r\\n biasUV *= 1.0 / ((texCoordDX.x * texCoordDY.y) - (texCoordDX.y * texCoordDY.x));\\r\\n\\r\\n // Static depth biasing to make up for incorrect fractional sampling on the shadow map grid\\r\\n float fractionalSamplingError = dot(vec2(1.0, 1.0) * shadowSize.xy, abs(biasUV));\\r\\n float receiverDepthBias = min(fractionalSamplingError, 0.01);\\r\\n\\r\\n shadowBiasPCF.x = biasUV.x;\\r\\n shadowBiasPCF.y = biasUV.y;\\r\\n\\r\\n shadowReceiverZ += receiverDepthBias;\\r\\n\\r\\n#else // _RECEIVERPLANEDEPTHBIAS\\r\\n shadowBiasPCF.x = clamp(dFdx(shadowReceiverZ) * shadowSize.x, -1.0, 1.0 );\\r\\n shadowBiasPCF.y = clamp(dFdy(shadowReceiverZ) * shadowSize.y, -1.0, 1.0 );\\r\\n#endif\\r\\n\\r\\n#endif // GL_OES_standard_derivatives\\r\\n\\r\\n\\r\\n vec4 clampDimension;\\r\\n\\r\\n#ifdef _ATLAS_SHADOW\\r\\n shadowUV.xy = ((shadowUV.xy * atlasSize.zw ) + atlasSize.xy) * shadowSize.xy;\\r\\n\\r\\n // clamp uv bias/filters by half pixel to avoid point filter on border\\r\\n clampDimension.xy = atlasSize.xy + vec2(0.5);\\r\\n clampDimension.zw = (atlasSize.xy + atlasSize.zw) - vec2(0.5);\\r\\n\\r\\n clampDimension = clampDimension * shadowSize.xyxy;\\r\\n#else\\r\\n clampDimension = vec4(0.0, 0.0, 1.0, 1.0);\\r\\n#endif // _RECEIVERPLANEDEPTHBIAS\\r\\n\\r\\n\\r\\n // now that derivatives is done and we don't access any mipmapped/texgrad texture we can early out\\r\\n // see http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers\\r\\n if (earlyOut) {\\r\\n // empty statement because of weird gpu intel bug\\r\\n } else {\\r\\n\\r\\n // depth bias: fighting shadow acne (depth imprecsion z-fighting)\\r\\n // cosTheta is dot( n, l ), clamped between 0 and 1\\r\\n // float shadowBias = 0.005*tan(acos(N_Dot_L));\\r\\n // same but 4 cycles instead of 15\\r\\n float depthBias = 0.05 * sqrt( 1.0 - N_Dot_L * N_Dot_L) / clamp(N_Dot_L, 0.0005, 1.0);\\r\\n\\r\\n // That makes sure that plane perpendicular to light doesn't flicker due to\\r\\n // selfshadowing and 1 = dot(Normal, Light) using a min bias\\r\\n depthBias = clamp(depthBias, 0.00005, 2.0 * shadowBias);\\r\\n\\r\\n // shadowZ must be clamped to [0,1]\\r\\n // otherwise it's not comparable to shadow caster depth map\\r\\n // which is clamped to [0,1]\\r\\n // Not doing that makes ALL shadowReceiver > 1.0 black\\r\\n // because they ALL becomes behind any point in Caster depth map\\r\\n shadowReceiverZ = clamp(shadowReceiverZ, 0.0, 1.0 -depthBias) - depthBias;\\r\\n\\r\\n // Now computes Shadow\\r\\n float res = getShadowPCF(shadowTexture,\\r\\n shadowSize,\\r\\n shadowUV,\\r\\n shadowReceiverZ,\\r\\n shadowBiasPCF,\\r\\n clampDimension\\r\\n OPT_INSTANCE_ARG_outDistance\\r\\n OPT_INSTANCE_ARG_jitter);\\r\\n#ifdef _OUT_DISTANCE\\r\\n if (lighted) shadow = res;\\r\\n outDistance *= shadowDepthRange.y - shadowDepthRange.x; // world space distance\\r\\n#else\\r\\n shadow = res;\\r\\n#endif // _OUT_DISTANCE\\r\\n }\\r\\n\\r\\n return shadow;\\r\\n\\r\\n}\\r\\n\";","export default \"#pragma include \\\"floatFromTex.glsl\\\"\\r\\n\\r\\n// simulation of texture2Dshadow glsl call on HW\\r\\n// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/\\r\\nfloat texture2DCompare(const in sampler2D depths,\\r\\n const in vec2 uv,\\r\\n const in float compare,\\r\\n const in vec4 clampDimension){\\r\\n float depth = getSingleFloatFromTex(depths, clamp(uv, clampDimension.xy, clampDimension.zw));\\r\\n return compare - depth;\\r\\n}\\r\\n\\r\\n#ifdef _JITTER_OFFSET\\r\\n// TODO could be in a random.glsl file\\r\\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\\r\\nfloat shadowInterleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\\r\\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\\r\\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\\r\\n}\\r\\n#endif\\r\\n\\r\\n// simulates linear fetch like texture2d shadow\\r\\nfloat texture2DShadowLerp(\\r\\n const in sampler2D depths,\\r\\n const in vec2 size,\\r\\n const in vec2 uv,\\r\\n const in float compare,\\r\\n const in vec4 clampDimension\\r\\n OPT_ARG_outDistance\\r\\n OPT_ARG_jitter){\\r\\n\\r\\n vec2 centroidCoord = uv / size.xy;\\r\\n\\r\\n#ifdef _JITTER_OFFSET\\r\\n if (jitter > 0.0){\\r\\n centroidCoord += shadowInterleavedGradientNoise(gl_FragCoord.xy, jitter);\\r\\n }\\r\\n#endif\\r\\n\\r\\n centroidCoord = centroidCoord + 0.5;\\r\\n vec2 f = fract(centroidCoord);\\r\\n vec2 centroidUV = floor(centroidCoord) * size.xy;\\r\\n\\r\\n vec4 fetches;\\r\\n const vec2 shift = vec2(1.0, 0.0);\\r\\n fetches.x = texture2DCompare(depths, centroidUV + size.xy * shift.yy, compare, clampDimension);\\r\\n fetches.y = texture2DCompare(depths, centroidUV + size.xy * shift.yx, compare, clampDimension);\\r\\n fetches.z = texture2DCompare(depths, centroidUV + size.xy * shift.xy, compare, clampDimension);\\r\\n fetches.w = texture2DCompare(depths, centroidUV + size.xy * shift.xx, compare, clampDimension);\\r\\n\\r\\n\\r\\n\\r\\n#ifdef _OUT_DISTANCE\\r\\n float _a = mix(fetches.x, fetches.y, f.y);\\r\\n float _b = mix(fetches.z, fetches.w, f.y);\\r\\n outDistance = mix(_a, _b, f.x);\\r\\n#endif\\r\\n\\r\\n vec4 st = step(fetches, vec4(0.0));\\r\\n\\r\\n float a = mix(st.x, st.y, f.y);\\r\\n float b = mix(st.z, st.w, f.y);\\r\\n return mix(a, b, f.x);\\r\\n}\\r\\n\";","export default \"#pragma include \\\"colorEncode.glsl\\\"\\r\\n\\r\\n// end Float codec\\r\\nfloat getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){\\r\\n#ifndef _FLOATTEX\\r\\n return decodeFloatRGBA(texture2D(depths, uv));\\r\\n#else\\r\\n return texture2D(depths, uv).x;\\r\\n#endif\\r\\n}\\r\\n\\r\\nvec2 getDoubleFloatFromTex(const in sampler2D depths, const in vec2 uv){\\r\\n#ifndef _FLOATTEX\\r\\n return decodeHalfFloatRGBA(texture2D(depths, uv));\\r\\n#else\\r\\n return texture2D(depths, uv).xy;\\r\\n#endif\\r\\n}\\r\\n\\r\\nvec4 getQuadFloatFromTex(const in sampler2D depths, const in vec2 uv){\\r\\n return texture2D(depths, uv).xyzw;\\r\\n}\\r\\n// end Float codec\\r\\n\";","export default \"#pragma include \\\"shadowLinearSoft.glsl\\\"\\r\\n\\r\\nfloat getShadowPCF(\\r\\n const in sampler2D depths,\\r\\n const in vec2 size,\\r\\n const in vec2 uv,\\r\\n const in float compare,\\r\\n const in vec2 biasPCF,\\r\\n const in vec4 clampDimension\\r\\n OPT_ARG_outDistance\\r\\n OPT_ARG_jitter) {\\r\\n\\r\\n float res = 0.0;\\r\\n\\r\\n res += texture2DShadowLerp(depths, size, uv + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter);\\r\\n\\r\\n\\r\\n#if defined(_PCFx1)\\r\\n\\r\\n#else\\r\\n\\r\\n float dx0 = -size.x;\\r\\n float dy0 = -size.y;\\r\\n float dx1 = size.x;\\r\\n float dy1 = size.y;\\r\\n\\r\\n#define TSF(o1,o2) texture2DShadowLerp(depths, size, uv + vec2(o1, o2) + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter)\\r\\n\\r\\n res += TSF(dx0, dx0);\\r\\n res += TSF(dx0, .0);\\r\\n res += TSF(dx0, dx1);\\r\\n\\r\\n#if defined(_PCFx4)\\r\\n\\r\\n res /=4.0;\\r\\n\\r\\n#elif defined(_PCFx9)\\r\\n res += TSF(.0, dx0);\\r\\n res += TSF(.0, dx1);\\r\\n\\r\\n res += TSF(dx1, dx0);\\r\\n res += TSF(dx1, .0);\\r\\n res += TSF(dx1, dx1);\\r\\n\\r\\n\\r\\n res /=9.0;\\r\\n\\r\\n#elif defined(_PCFx25)\\r\\n\\r\\n float dx02 = 2.0*dx0;\\r\\n float dy02 = 2.0*dy0;\\r\\n float dx2 = 2.0*dx1;\\r\\n float dy2 = 2.0*dy1;\\r\\n\\r\\n // complete row above\\r\\n res += TSF(dx0, dx02);\\r\\n res += TSF(dx0, dx2);\\r\\n\\r\\n res += TSF(.0, dx02);\\r\\n res += TSF(.0, dx2);\\r\\n\\r\\n res += TSF(dx1, dx02);\\r\\n res += TSF(dx1, dx2);\\r\\n\\r\\n // two new col\\r\\n res += TSF(dx02, dx02);\\r\\n res += TSF(dx02, dx0);\\r\\n res += TSF(dx02, .0);\\r\\n res += TSF(dx02, dx1);\\r\\n res += TSF(dx02, dx2);\\r\\n\\r\\n res += TSF(dx2, dx02);\\r\\n res += TSF(dx2, dx0);\\r\\n res += TSF(dx2, .0);\\r\\n res += TSF(dx2, dx1);\\r\\n res += TSF(dx2, dx2);\\r\\n\\r\\n\\r\\n res/=25.0;\\r\\n\\r\\n#endif\\r\\n\\r\\n#undef TSF\\r\\n\\r\\n#endif\\r\\n return res;\\r\\n}\\r\\n/////// end Tap\\r\\n\";","import shadowCast from './shaders/shadowCast.glsl';\r\nimport shadowReceive from './shaders/shadowReceive.glsl';\r\nimport shadowLinearSoft from './shaders/shadowLinearSoft.glsl';\r\nimport floatFromTex from './shaders/floatFromTex.glsl';\r\nimport tapPCF from './shaders/tapPCF.glsl';\r\n\r\nexport default {\r\n 'shadowCast.glsl': shadowCast,\r\n 'shadowReceive.glsl': shadowReceive,\r\n 'shadowLinearSoft.glsl': shadowLinearSoft,\r\n 'floatFromTex.glsl': floatFromTex,\r\n 'tapPCF.glsl': tapPCF\r\n};","var StackObjectPairPool = function() {\r\n this._globalDefault = undefined;\r\n this._lastApplied = undefined;\r\n this._changed = false;\r\n\r\n this._values = [];\r\n this._back = undefined;\r\n this._length = 0;\r\n};\r\n\r\nStackObjectPairPool.prototype = {\r\n getLength: function() {\r\n return this._length;\r\n },\r\n push: function(object, value) {\r\n var objectPair;\r\n if (this._length === this._values.length) {\r\n objectPair = { object: object, value: value };\r\n this._values.push(objectPair);\r\n } else {\r\n objectPair = this._values[this._length];\r\n objectPair.object = object;\r\n objectPair.value = value;\r\n }\r\n this._back = objectPair;\r\n this._length++;\r\n },\r\n pop: function() {\r\n if (!this._length) return undefined;\r\n var values = this._values;\r\n this._length--;\r\n var objectPair = values[this._length];\r\n this._back = this._length ? values[this._length - 1] : undefined;\r\n return objectPair;\r\n }\r\n};\r\nexport default StackObjectPairPool;\r\n","import P from 'bluebird';\r\n\r\nvar requestFileFromURL = function(url, options) {\r\n return new P(function(resolve, reject) {\r\n var req = new XMLHttpRequest();\r\n req.open('GET', url, true);\r\n\r\n var responseType =\r\n options && options.responseType ? options.responseType.toLowerCase() : undefined;\r\n\r\n // handle responseType\r\n if (responseType) req.responseType = responseType;\r\n\r\n if (options && options.progress) {\r\n req.addEventListener('progress', options.progress, false);\r\n }\r\n\r\n req.addEventListener('error', reject, false);\r\n\r\n req.addEventListener('load', function() {\r\n if (req.responseType === 'arraybuffer' || req.responseType === 'blob')\r\n resolve(req.response);\r\n else resolve(req.responseText);\r\n });\r\n\r\n req.send(null);\r\n });\r\n};\r\n\r\nvar requestFileFromReader = function(file, options) {\r\n return new P(function(resolve) {\r\n var responseType =\r\n options && options.responseType ? options.responseType.toLowerCase() : undefined;\r\n var reader = new window.FileReader();\r\n reader.onload = function(data) {\r\n resolve(data.target.result);\r\n };\r\n // handle responseType\r\n if (responseType) {\r\n if (responseType === 'arraybuffer') reader.readAsArrayBuffer(file);\r\n else if (responseType === 'blob') resolve(file);\r\n else if (responseType === 'string') reader.readAsText(file);\r\n else reader.readAsDataURL(file);\r\n } else {\r\n reader.readAsText(file);\r\n }\r\n });\r\n};\r\n\r\nvar requestFile = function(urlOrFile, options) {\r\n if (typeof urlOrFile === 'string') {\r\n return requestFileFromURL(urlOrFile, options);\r\n } else {\r\n return requestFileFromReader(urlOrFile, options);\r\n }\r\n};\r\n\r\nexport default requestFile;\r\n","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport MorphGeometry from '../osgAnimation/MorphGeometry';\r\n\r\nvar DisplayGraphNode = function(selectables) {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n\r\n this._selectables = selectables;\r\n this._nodeList = [];\r\n this._linkList = [];\r\n\r\n // don't reference twice same node\r\n this._uniqueNodes = new window.Set();\r\n this._uniqueEdges = new window.Set();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n DisplayGraphNode,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n getColorFromClassName: function(name) {\r\n switch (name) {\r\n case 'ShadowedScene':\r\n return '#3D3D3D';\r\n case 'Camera':\r\n return '#AB7BCF';\r\n case 'RenderBin':\r\n return '#59778B';\r\n case 'LightSource':\r\n return '#53967D';\r\n case 'RenderStage':\r\n return '#DDCC55';\r\n case 'RenderLeaf':\r\n case 'Geometry':\r\n return '#FFCC55';\r\n case 'RigGeometry':\r\n return '#DD8800';\r\n case 'MorphGeometry':\r\n return '#AA5500';\r\n case 'MatrixTransform':\r\n return '#CE697E';\r\n case 'StateSet':\r\n return '#0099FF';\r\n case 'StateGraph':\r\n case 'Skeleton':\r\n return '#96999E';\r\n case 'Bone':\r\n return '#A9DEAA';\r\n case 'Node':\r\n return '#FFFFFF';\r\n default:\r\n return '#FF00AA';\r\n }\r\n },\r\n\r\n createGraph: function(root) {\r\n this.reset();\r\n root.accept(this);\r\n },\r\n\r\n reset: function() {\r\n this._nodeList.length = 0;\r\n this._linkList.length = 0;\r\n this._uniqueNodes.clear();\r\n this._uniqueEdges.clear();\r\n },\r\n\r\n apply: function(node) {\r\n if (node._isNormalDebug) return;\r\n\r\n if (!this._uniqueNodes.has(node.getInstanceID())) {\r\n this._uniqueNodes.add(node.getInstanceID());\r\n this._nodeList.push(node);\r\n }\r\n\r\n if (this.nodePath.length >= 2) {\r\n var parentID = this.nodePath[this.nodePath.length - 2].getInstanceID();\r\n var childID = node.getInstanceID();\r\n var key = parentID + '+' + childID;\r\n if (!this._uniqueEdges.has(key)) {\r\n this._linkList.push({\r\n parentNode: parentID,\r\n childrenNode: childID\r\n });\r\n this._uniqueEdges.add(key);\r\n }\r\n }\r\n\r\n this.traverse(node);\r\n },\r\n\r\n // Create an array to display the matrix\r\n createMatrixGrid: function(node, matrixArray) {\r\n var nodeMatrix = '';\r\n\r\n nodeMatrix += '<table><tr><td>' + matrixArray[0] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[4] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[8] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[12] + '</td></tr>';\r\n\r\n nodeMatrix += '<tr><td>' + matrixArray[1] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[5] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[9] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[13] + '</td></tr>';\r\n\r\n nodeMatrix += '<tr><td>' + matrixArray[2] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[6] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[10] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[14] + '</td></tr>';\r\n\r\n nodeMatrix += '<tr><td>' + matrixArray[3] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[7] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[11] + '</td>';\r\n nodeMatrix += '<td>' + matrixArray[15] + '</td></tr></table>';\r\n\r\n return nodeMatrix;\r\n },\r\n\r\n getLabel: function(obj) {\r\n var label = obj.className() + ' (' + obj.getInstanceID() + ')';\r\n if (obj.getName && obj.getName()) label += '\\n' + obj.getName();\r\n return label;\r\n },\r\n\r\n generateNode: function(g, node) {\r\n var description = '';\r\n if (node.getMatrix && node.getMatrix()) {\r\n description += '<br /><br />' + this.createMatrixGrid(node, node.getMatrix());\r\n }\r\n\r\n this._selectables.set(node.getInstanceID().toString(), node);\r\n g.addNode(node.getInstanceID(), {\r\n label: this.getLabel(node),\r\n description: description,\r\n style: 'fill: ' + this.getColorFromClassName(node.className()) + ';stroke-width: 0px;'\r\n });\r\n },\r\n\r\n generateStateSet: function(g, node) {\r\n var stateSet = node.getStateSet();\r\n var stateSetID = stateSet.getInstanceID();\r\n\r\n var label = this.getLabel(stateSet);\r\n label += '\\nNbTexture : ' + stateSet.getNumTextureAttributeLists();\r\n\r\n if (!g.hasNode(stateSetID)) {\r\n this._selectables.set(stateSetID.toString(), stateSet);\r\n g.addNode(stateSetID, {\r\n label: label,\r\n style: 'fill: ' +\r\n this.getColorFromClassName(stateSet.className()) +\r\n ';stroke-width: 0px;'\r\n });\r\n }\r\n\r\n g.addEdge(null, node.getInstanceID(), stateSetID, {\r\n style: 'stroke: ' + this.getColorFromClassName(stateSet.className()) + ';'\r\n });\r\n },\r\n\r\n generateSourceGeometry: function(g, node) {\r\n var sourceGeom = node.getSourceGeometry();\r\n var sourceGeomID = sourceGeom.getInstanceID();\r\n\r\n this._selectables.set(sourceGeomID.toString(), sourceGeom);\r\n g.addNode(sourceGeomID, {\r\n label: this.getLabel(sourceGeom),\r\n style: 'fill: ' +\r\n this.getColorFromClassName(sourceGeom.className()) +\r\n ';stroke-width: 0px;'\r\n });\r\n\r\n g.addEdge(null, node.getInstanceID(), sourceGeomID, {\r\n style: 'stroke: ' + this.getColorFromClassName(sourceGeom.className()) + ';'\r\n });\r\n },\r\n\r\n // Subfunction of createGraph, will iterate to create all the node and link in dagre\r\n generateNodeAndLink: function(g) {\r\n for (var i = 0, ni = this._nodeList.length; i < ni; i++) {\r\n var node = this._nodeList[i];\r\n\r\n // node\r\n this.generateNode(g, node);\r\n\r\n // adds statesets node\r\n if (node.getStateSet()) {\r\n this.generateStateSet(g, node);\r\n }\r\n\r\n // adds source geometry node\r\n if (node.getSourceGeometry && node.getSourceGeometry() instanceof MorphGeometry) {\r\n this.generateSourceGeometry(g, node);\r\n }\r\n }\r\n\r\n for (var j = 0, nj = this._linkList.length; j < nj; j++) {\r\n g.addEdge(null, this._linkList[j].parentNode, this._linkList[j].childrenNode);\r\n }\r\n }\r\n }),\r\n 'osgUtil',\r\n 'DisplayGraphNode'\r\n);\r\n\r\nexport default DisplayGraphNode;","import DisplayGraphNode from './DisplayGraphNode';\r\nimport RenderBin from '../osg/RenderBin';\r\n\r\nvar DisplayGraphRenderer = function(selectables) {\r\n this._selectables = selectables;\r\n this._nodeList = [];\r\n this._linkList = [];\r\n\r\n this._renderBinMap = new window.Map();\r\n this._renderBinStack = [];\r\n\r\n this._generatorID = 0;\r\n this._refID = 0; // invalide old _instanceID if we recreate the graph\r\n\r\n this._uniqueEdges = new window.Set();\r\n};\r\n\r\nDisplayGraphRenderer.prototype = {\r\n getColorFromClassName: DisplayGraphNode.prototype.getColorFromClassName,\r\n\r\n createGraph: function(renderBin) {\r\n this.reset();\r\n this.apply(renderBin);\r\n },\r\n\r\n reset: function() {\r\n this._renderBinMap.clear();\r\n this._renderBinStack.length = 0;\r\n this._generatorID = 0;\r\n this._refID++;\r\n\r\n this._nodeList.length = 0;\r\n this._linkList.length = 0;\r\n\r\n this._uniqueEdges.clear();\r\n },\r\n\r\n apply: function(rb) {\r\n var instanceID = rb.getInstanceID();\r\n if (!this._renderBinMap.has(instanceID)) {\r\n this._renderBinMap.set(instanceID, rb);\r\n }\r\n\r\n this._renderBinStack.push(rb);\r\n\r\n // pre render stage if render stage node\r\n if (rb.getPreRenderStageList) {\r\n var preRenderList = rb.getPreRenderStageList();\r\n for (var i = 0, ni = preRenderList.length; i < ni; ++i) {\r\n this.apply(preRenderList[i].renderStage);\r\n }\r\n }\r\n\r\n // draw implementation\r\n // handle rs camera\r\n this.registerNode(rb);\r\n\r\n // post render stage if render stage node\r\n if (rb.getPostRenderStageList) {\r\n var postRenderList = rb.getPostRenderStageList();\r\n for (var j = 0, nj = postRenderList.length; j < nj; ++j) {\r\n this.apply(postRenderList[j].renderStage);\r\n }\r\n }\r\n\r\n this._renderBinStack.pop();\r\n },\r\n\r\n registerNode: function(rb) {\r\n var childID = rb.getInstanceID();\r\n\r\n this._nodeList.push(rb);\r\n\r\n // register bins\r\n var bins = rb._bins;\r\n bins.forEach(\r\n function(key, bin) {\r\n this.apply(bin);\r\n }.bind(this)\r\n );\r\n\r\n // register fine grained leafs\r\n if (rb._leafs.length) {\r\n for (var j = 0, nj = rb._leafs.length; j < nj; j++) {\r\n this.createNodeAndSetID(childID, rb._leafs[j]);\r\n }\r\n }\r\n\r\n var self = this;\r\n var context = {};\r\n\r\n var leafFunction = function(leaf) {\r\n self.createNodeAndSetID(this.stateGraphID, leaf);\r\n }.bind(context);\r\n\r\n var stateGraphFunction = function(sg) {\r\n self.createNodeAndSetID(childID, sg);\r\n var stateGraphID = sg._instanceID;\r\n var leafsPool = sg.getLeafs();\r\n context.stateGraphID = stateGraphID;\r\n leafsPool.forEach(leafFunction);\r\n };\r\n // register coarse grained leafs\r\n var stateGraphList = rb.getStateGraphList();\r\n stateGraphList.forEach(stateGraphFunction);\r\n\r\n // no parent no link\r\n if (this._renderBinStack.length < 2) return;\r\n\r\n var parentID = this._renderBinStack[this._renderBinStack.length - 2].getInstanceID();\r\n this.createLink(parentID, childID);\r\n },\r\n\r\n createLink: function(parent, child) {\r\n var key = parent + '+' + child;\r\n if (!this._uniqueEdges.has(key)) {\r\n this._linkList.push({\r\n parentNode: parent,\r\n childrenNode: child\r\n });\r\n this._uniqueEdges.add(key);\r\n }\r\n },\r\n\r\n createNodeAndSetID: function(parentID, node) {\r\n // register render leaf\r\n this._nodeList.push(node);\r\n\r\n // generate fake id < 0 because RenderLeaf does not inherit from Object\r\n if (\r\n node._instanceID === undefined ||\r\n (node._instanceID < 0 && node._refID !== this._refID)\r\n ) {\r\n node._instanceID = -1 - this._generatorID++;\r\n node._refID = this._refID;\r\n }\r\n\r\n this.createLink(parentID, node._instanceID);\r\n },\r\n\r\n generateRenderLeaf: function(g, node) {\r\n var instanceID = node._instanceID;\r\n var className = 'RenderLeaf';\r\n var geomName =\r\n node._geometry && node._geometry.getName() ?\r\n '\\n' + node._geometry.getName() :\r\n 'Geometry';\r\n\r\n var label = className + ' ( ' + node._instanceID + ' )';\r\n label += '\\n' + geomName + ' ( ' + node._geometry.getInstanceID() + ' )';\r\n\r\n this._selectables.set(instanceID.toString(), node);\r\n g.addNode(instanceID, {\r\n label: label,\r\n description: '',\r\n style: 'fill: ' + this.getColorFromClassName(className) + ';stroke-width: 0px;'\r\n });\r\n },\r\n\r\n generateStateGraph: function(g, node) {\r\n var instanceID = node._instanceID;\r\n var className = 'StateGraph';\r\n var label = className + ' ( ' + node._instanceID + ' )';\r\n label += '\\n' + node._leafs._length + ' leafs';\r\n\r\n this._selectables.set(instanceID.toString(), node);\r\n g.addNode(instanceID, {\r\n label: label,\r\n description: '',\r\n style: 'fill: ' + this.getColorFromClassName(className) + ';stroke-width: 0px;'\r\n });\r\n },\r\n\r\n generateRenderStage: function(g, node) {\r\n var label = node.className() + ' ( ' + node._instanceID + ' )';\r\n if (node.getName()) label += '\\n' + node.getName();\r\n label +=\r\n '\\nViewport ( ' +\r\n node.getViewport().width() +\r\n ' x ' +\r\n node.getViewport().height() +\r\n ' )';\r\n\r\n this._selectables.set(node.getInstanceID().toString(), node);\r\n g.addNode(node.getInstanceID(), {\r\n label: label,\r\n description: '',\r\n style: 'fill: ' + this.getColorFromClassName(node.className()) + ';stroke-width: 0px;'\r\n });\r\n },\r\n\r\n generateRenderBin: function(g, rb) {\r\n var label = rb.className() + ' ( ' + rb.getInstanceID() + ' )';\r\n if (rb.getName()) label += '\\n' + rb.getName();\r\n\r\n var sortMode = '';\r\n if (rb.getSortMode() === RenderBin.SORT_BACK_TO_FRONT) sortMode = 'SortMode: BackToFront';\r\n\r\n var description = 'BinNumber: ' + rb.getBinNumber() + '\\n' + sortMode;\r\n\r\n this._selectables.set(rb.getInstanceID().toString(), rb);\r\n g.addNode(rb.getInstanceID(), {\r\n label: label,\r\n description: description,\r\n style: 'fill: ' + this.getColorFromClassName(rb.className()) + ';stroke-width: 0px;'\r\n });\r\n },\r\n\r\n // Subfunction of createGraph, will iterate to create all the node and link in dagre\r\n generateNodeAndLink: function(g) {\r\n for (var i = 0, ni = this._nodeList.length; i < ni; i++) {\r\n var node = this._nodeList[i];\r\n\r\n // detect if RenderLeaf\r\n if (node._geometry && node._depth !== undefined) {\r\n this.generateRenderLeaf(g, node);\r\n } else if (node.className() === 'StateGraph') {\r\n this.generateStateGraph(g, node);\r\n } else if (node.className() === 'RenderStage') {\r\n this.generateRenderStage(g, node);\r\n } else {\r\n // it's a RenderBin\r\n this.generateRenderBin(g, node);\r\n }\r\n }\r\n\r\n for (var j = 0, nj = this._linkList.length; j < nj; j++) {\r\n g.addEdge(null, this._linkList[j].parentNode, this._linkList[j].childrenNode);\r\n }\r\n }\r\n};\r\n\r\nexport default DisplayGraphRenderer;","import DisplayGraphRenderer from '../osgUtil/DisplayGraphRenderer';\r\nimport DisplayGraphNode from '../osgUtil/DisplayGraphNode';\r\nimport notify from '../osg/notify';\r\n\r\nimport $ from 'jquery'\r\n\r\nvar init$ = function() {\r\n if (!$) {\r\n notify.warn(\r\n 'You will not be able to use osgUtil.DisplayGraph until you add jQuery in your page'\r\n );\r\n }\r\n\r\n};\r\n\r\n// Simple tooltips implementation\r\nvar SimpleTooltips = function(options) {\r\n this.options = options;\r\n var css = document.createElement('style');\r\n css.type = 'text/css';\r\n css.innerHTML = [\r\n '.osgDebugSimpleTooltip {',\r\n 'display: none;',\r\n 'position: absolute;',\r\n 'margin-left: 10px;',\r\n 'border-radius: 4px;',\r\n 'padding: 10px;',\r\n 'background: rgba(0,0,0,.9);',\r\n 'color: #ffffff;',\r\n '}',\r\n '.osgDebugSimpleTooltip:before {',\r\n 'content: ',\r\n ';',\r\n 'position: absolute;',\r\n 'left: -10px;',\r\n 'top: 8px;',\r\n 'border: 10px solid transparent;',\r\n 'border-width: 10px 10px 10px 0;',\r\n 'border-right-color: rgba(0,0,0,.9);',\r\n '}'\r\n ].join('\\n');\r\n document.getElementsByTagName('head')[0].appendChild(css);\r\n\r\n this.el = document.createElement('div');\r\n this.el.className = 'osgDebugSimpleTooltip';\r\n document.body.appendChild(this.el);\r\n var nodes = document.querySelectorAll(this.options.selector);\r\n for (var i = 0; i < nodes.length; i++) {\r\n nodes[i].addEventListener('mouseover', this.showTooltip.bind(this), false);\r\n nodes[i].addEventListener('mouseout', this.hideTooltip.bind(this), false);\r\n }\r\n};\r\nSimpleTooltips.prototype = {\r\n showTooltip: function(e) {\r\n if (!$) return;\r\n\r\n var target = e.currentTarget;\r\n this.el.innerHTML = target.getAttribute('title');\r\n this.el.style.display = 'block';\r\n this.el.style.left =\r\n $(target).position().left +\r\n $(target)\r\n .get(0)\r\n .getBoundingClientRect().width +\r\n 'px';\r\n this.el.style.top = $(target).position().top + 'px';\r\n },\r\n hideTooltip: function() {\r\n this.el.style.display = 'none';\r\n }\r\n};\r\n\r\nvar DisplayGraph = function() {\r\n init$();\r\n if (!$) return;\r\n\r\n // indexed with instanceID, references nodes, stateSet, sourceGeometry...\r\n // referenced with strings !\r\n this._selectables = new window.Map();\r\n\r\n this._graphNode = new DisplayGraphNode(this._selectables);\r\n this._graphRender = new DisplayGraphRenderer(this._selectables);\r\n\r\n this._displayNode = true;\r\n this._displayRenderer = false;\r\n\r\n // callback when selecting a node\r\n this._cbSelect = undefined;\r\n\r\n this._focusedElement = 'graph';\r\n this._idToDomElement = new window.Map();\r\n\r\n this._$svg = $('<svg width=100% height=100%></svg>');\r\n $('body').append(this._$svg);\r\n\r\n this._css =\r\n '.node {text-align: center;cursor: pointer;}.node rect {stroke: #FFF;}.edgePath path {stroke: #FFF;fill: none;}table {text-align: right;}svg {position: absolute;left: 0px;top: 0px;}.osgDebugButton {position: absolute;left: 15px;top: 15px;z-index: 5;border: 0;background: #65a9d7;background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));background: -webkit-linear-gradient(top, #3e779d, #65a9d7);background: -moz-linear-gradient(top, #3e779d, #65a9d7);background: -ms-linear-gradient(top, #3e779d, #65a9d7);background: -o-linear-gradient(top, #3e779d, #65a9d7);padding: 5px 10px;-webkit-border-radius: 7px;-moz-border-radius: 7px;border-radius: 7px;-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;box-shadow: rgba(0,0,0,1) 0 1px 0;text-shadow: rgba(0,0,0,.4) 0 1px 0;color: white;font-size: 15px;font-family: Helvetica, Arial, Sans-Serif;text-decoration: none;vertical-align: middle;}.osgDebugButton:hover {border-top-color: #28597a;background: #28597a;color: #ccc;}.osgDebugButton:active {border-top-color: #1b435e;background: #1b435e;}.osgDebugSimpleTooltip .osgDebugName {font-weight: bold;color: #60b1fc;margin: 0;}.osgDebugSimpleTooltip .osgDebugDescription {margin: 0;}';\r\n};\r\n\r\nDisplayGraph.instance = function() {\r\n if (!DisplayGraph._instance) DisplayGraph._instance = new DisplayGraph();\r\n return DisplayGraph._instance;\r\n};\r\n\r\nDisplayGraph.prototype = {\r\n getColorFromClassName: DisplayGraphNode.prototype.getColorFromClassName,\r\n\r\n setCallbackSelect: function(cb) {\r\n this._cbSelect = cb;\r\n },\r\n\r\n reset: function() {\r\n if (!$) return;\r\n\r\n this._selectables.clear();\r\n this._$svg.empty();\r\n this._focusedElement = 'scene';\r\n $('.osgDebugButton').hide();\r\n },\r\n\r\n setDisplayGraphRenderer: function(bool) {\r\n this._displayRenderer = bool;\r\n },\r\n\r\n createRenderGraph: function(renderStage) {\r\n // called by renderer\r\n this._graphRender.createGraph(renderStage);\r\n this.displayGraph();\r\n },\r\n\r\n createGraph: function(root) {\r\n if (!$) return;\r\n this.reset();\r\n\r\n this._displayNode = !!root;\r\n if (root) {\r\n this._graphNode.createGraph(root);\r\n }\r\n\r\n // check if asynchronous is necessary\r\n if (!this._displayRenderer) {\r\n this.displayGraph();\r\n } else {\r\n // circular dependency\r\n require('../osgViewer/Renderer').default.debugGraph = true;\r\n }\r\n },\r\n\r\n // Create and display a dagre d3 graph\r\n displayGraph: function() {\r\n if (!$) return;\r\n if (window.d3 && window.dagreD3) {\r\n this._createGraphApply();\r\n return;\r\n }\r\n\r\n var d3url = '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js';\r\n var dagreurl = '//cdn.jsdelivr.net/dagre-d3/0.2.9/dagre-d3.min.js';\r\n\r\n var cb = this._createGraphApply.bind(this);\r\n $.getScript(d3url).done(function() {\r\n $.getScript(dagreurl).done(cb);\r\n });\r\n },\r\n\r\n _createGraphApply: function() {\r\n var diGraph = new window.dagreD3.Digraph();\r\n if (this._displayNode) this._graphNode.generateNodeAndLink(diGraph);\r\n if (this._displayRenderer) this._graphRender.generateNodeAndLink(diGraph);\r\n\r\n // Add the style of the graph\r\n this.injectStyleElement();\r\n $('.osgDebugButton').show();\r\n\r\n // Create the renderer\r\n var renderer = (this.renderer = new window.dagreD3.Renderer());\r\n\r\n // Set up an SVG group so that we can translate the final graph.\r\n var svg = window.d3.select(this._$svg.get(0));\r\n var svgGroup = svg.append('g');\r\n\r\n // Set initial zoom to 75%\r\n var initialScale = 0.75;\r\n var oldZoom = renderer.zoom();\r\n renderer.zoom(function(g, argSVG) {\r\n var zoom = oldZoom(g, argSVG);\r\n\r\n zoom.scale(initialScale).event(argSVG);\r\n return zoom;\r\n });\r\n\r\n // Simple function to style the tooltip for the given node.\r\n var styleTooltip = function(instanceID, description) {\r\n // instanceID is used by onNodeSelect to retrieve the node\r\n return (\r\n '<p class=\"osgDebugName\">' +\r\n instanceID +\r\n '</p><pre class=\"osgDebugDescription\">' +\r\n description +\r\n '</pre>'\r\n );\r\n };\r\n\r\n var idToDom = this._idToDomElement;\r\n // Override drawNodes to set up the hover.\r\n var oldDrawNodes = renderer.drawNodes();\r\n renderer.drawNodes(function(g, argSVG) {\r\n var svgNodes = oldDrawNodes(g, argSVG);\r\n\r\n // Set the title on each of the nodes and use tipsy to display the tooltip on hover\r\n svgNodes.attr('title', function(d) {\r\n idToDom.set(d, this);\r\n return styleTooltip(d, g.node(d).description || '');\r\n });\r\n\r\n return svgNodes;\r\n });\r\n\r\n // Run the renderer. This is what draws the final graph.\r\n renderer.run(diGraph, svgGroup);\r\n\r\n this.tooltip = new SimpleTooltips({\r\n selector: '.node'\r\n });\r\n\r\n // Do a console log of the node (or stateset) and save it in window.*\r\n $('.node').click(this.onNodeSelect.bind(this));\r\n this.focusOnGraph();\r\n },\r\n\r\n selectNode: function(node) {\r\n var id = node.getInstanceID();\r\n var dom = this._idToDomElement.get(id);\r\n if (dom) $(dom).click();\r\n },\r\n\r\n onNodeSelect: function(e) {\r\n var target = e.currentTarget;\r\n var identifier = $(target.getAttribute('title'))[0].innerHTML;\r\n var selectables = this._selectables;\r\n\r\n // color the node back\r\n if (this.lastNode) {\r\n this.lastNode.style.fill = this.lastColor;\r\n }\r\n\r\n // non selectables nodes\r\n var elt = selectables.get(identifier);\r\n if (!elt) return;\r\n\r\n this.lastNode = target.childNodes[0];\r\n this.lastColor = this.lastNode.style.fill;\r\n target.childNodes[0].style.fill = '#f00';\r\n\r\n window.activeNode = elt;\r\n notify.info('window.activeNode is set with the node below !');\r\n notify.log(window.activeNode);\r\n notify.log('\\n');\r\n\r\n if (this._cbSelect) this._cbSelect(elt);\r\n },\r\n\r\n focusOnScene: function() {\r\n $('.osgDebugButton').text('Access to the graph');\r\n this._$svg.css('zIndex', '-2');\r\n this._focusedElement = 'scene';\r\n },\r\n\r\n focusOnGraph: function() {\r\n $('.osgDebugButton').text('Access to the scene');\r\n this._$svg.css('zIndex', '2');\r\n $('.osgDebugSimpleTooltip').css('zIndex', '3');\r\n this._focusedElement = 'graph';\r\n },\r\n\r\n // Apply all the style\r\n injectStyleElement: function() {\r\n if (this._cssInjected) return;\r\n this._cssInjected = true;\r\n\r\n $('body').append('<button class=\"osgDebugButton\">Access to the scene</button>');\r\n $('.osgDebugButton').click(\r\n function() {\r\n if (this._focusedElement === 'scene') this.focusOnGraph();\r\n else this.focusOnScene();\r\n }.bind(this)\r\n );\r\n\r\n var css = document.createElement('style');\r\n css.type = 'text/css';\r\n css.innerHTML = this._css;\r\n document.getElementsByTagName('head')[0].appendChild(css);\r\n }\r\n};\r\n\r\nexport default DisplayGraph;","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport Skeleton from './Skeleton';\r\n\r\n/**\r\n * FindNearestParentSkeleton\r\n */\r\n\r\nvar FindNearestParentSkeleton = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_PARENTS);\r\n this._root = undefined;\r\n\r\n // node path to skeleton (without skeleton node though)\r\n this._pathToRoot = undefined;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n FindNearestParentSkeleton,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (this._root) return;\r\n\r\n if (node.typeID === Skeleton.typeID) {\r\n this._root = node;\r\n this._pathToRoot = this.nodePath.slice(1);\r\n return;\r\n }\r\n\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'FindNearestParentSkeleton'\r\n);\r\n\r\nexport default FindNearestParentSkeleton;\r\n","import utils from '../osg/utils';\r\nimport notify from '../osg/notify';\r\nimport ObjectBase from '../osg/Object';\r\nimport FindNearestParentSkeleton from './FindNearestParentSkeleton';\r\n\r\n// converted from C++ probably it could be merged into RigGeometry\r\n// it could probably inlined into RigGeometry code\r\nvar UpdateRigGeometry = function() {\r\n ObjectBase.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n UpdateRigGeometry,\r\n utils.objectInherit(ObjectBase.prototype, {\r\n init: function(geom) {\r\n var finder = new FindNearestParentSkeleton();\r\n if (geom.getParents().length > 1)\r\n notify.warn(\r\n 'A RigGeometry should not have multi parent ( ' + geom.getName() + ' )'\r\n );\r\n\r\n geom.getParents()[0].accept(finder);\r\n\r\n if (!finder._root) {\r\n notify.warn(\r\n 'A RigGeometry did not find a parent skeleton for RigGeometry ( ' +\r\n geom.getName() +\r\n ' )'\r\n );\r\n return;\r\n }\r\n\r\n geom.setSkeleton(finder._root);\r\n geom.setPathToSkeleton(finder._pathToRoot);\r\n },\r\n\r\n update: function(node /*, nv*/) {\r\n // Circular ref\r\n if (node && node.className() !== 'RigGeometry') return true;\r\n\r\n var geom = node;\r\n\r\n // maybe this code could simpler\r\n if (!geom.getSkeleton() && geom.getParents().length !== 0) this.init(geom);\r\n if (!geom.getSkeleton()) return true;\r\n\r\n if (geom.getNeedToComputeMatrix()) geom.computeMatrixFromRootSkeleton();\r\n\r\n geom.update();\r\n\r\n return true;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'UpdateRigGeometry'\r\n);\r\n\r\nexport default UpdateRigGeometry;\r\n","import utils from '../osg/utils';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport notify from '../osg/notify';\r\nimport Bone from './Bone';\r\n\r\nvar CollectBoneVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n this._boneMap = {};\r\n};\r\n\r\nutils.createPrototypeObject(\r\n CollectBoneVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.typeID === Bone.typeID) {\r\n var name = node.getName();\r\n\r\n if (!name) {\r\n notify.warn('found Bone without name');\r\n } else {\r\n this._boneMap[name] = node;\r\n }\r\n }\r\n\r\n this.traverse(node);\r\n },\r\n\r\n getBoneMap: function() {\r\n return this._boneMap;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'CollectBoneVisitor'\r\n);\r\n\r\nexport default CollectBoneVisitor;\r\n","import { mat4 } from '../osg/glMatrix';\r\nimport StateAttribute from '../osg/StateAttribute';\r\nimport SkinningAttribute from './SkinningAttribute';\r\nimport CollectBoneVisitor from './CollectBoneVisitor';\r\n\r\n/**\r\n * Hardware implementation for rigGeometry\r\n *\r\n */\r\nvar RigTransformHardware = function() {\r\n this._isInitialized = false;\r\n\r\n // bones are sorted to be used directly by\r\n // computeMatrixPalette\r\n // means the\r\n this._bones = [];\r\n};\r\n\r\nRigTransformHardware.prototype = {\r\n // boneNameID contains a map: boneName: id\r\n // {\r\n // 'bone0' : 1,\r\n // 'bone4' : 0,\r\n // }\r\n //\r\n // boneMap contains a map: boneName: Bone\r\n // {\r\n // 'bone0: : Bone object,\r\n // 'bone1: : Bone object,\r\n // }\r\n //\r\n // return index / bone object\r\n // [\r\n // Bone4 object,\r\n // Bone0 object\r\n // ]\r\n computeBonePalette: function(boneMap, boneNameID) {\r\n var bones = this._bones;\r\n for (var boneName in boneMap) {\r\n var index = boneNameID[boneName];\r\n var bone = boneMap[boneName];\r\n\r\n if (index !== undefined) bones[index] = bone;\r\n }\r\n\r\n return bones;\r\n },\r\n\r\n init: function(geom) {\r\n // init the bones map\r\n\r\n // stop here\r\n // compute bonemap / index\r\n var mapVisitor = new CollectBoneVisitor();\r\n geom.getSkeleton().accept(mapVisitor);\r\n var bm = mapVisitor.getBoneMap();\r\n\r\n this.computeBonePalette(bm, geom._boneNameID);\r\n\r\n // matrix are 4x3\r\n var nbVec4Uniforms = this._bones.length * 3;\r\n var animAttrib = (this._skinningAttribute = new SkinningAttribute());\r\n animAttrib.setMatrixPalette(new Float32Array(nbVec4Uniforms * 4));\r\n geom.getStateSetAnimation().setAttributeAndModes(animAttrib, StateAttribute.ON);\r\n\r\n this._isInitialized = true;\r\n return true;\r\n },\r\n\r\n computeMatrixPalette: (function() {\r\n var mTmp = mat4.create();\r\n\r\n return function(transformFromSkeletonToGeometry, invTransformFromSkeletonToGeometry) {\r\n var bones = this._bones;\r\n var matPalette = this._skinningAttribute.getMatrixPalette();\r\n var uniformIndex = 0;\r\n\r\n for (var i = 0, l = bones.length; i < l; i++) {\r\n var bone = bones[i];\r\n\r\n var invBindMatrix = bone.getInvBindMatrixInSkeletonSpace();\r\n var boneMatrix = bone.getMatrixInSkeletonSpace();\r\n\r\n mat4.mul(mTmp, boneMatrix, invBindMatrix);\r\n mat4.mul(mTmp, invTransformFromSkeletonToGeometry, mTmp);\r\n mat4.mul(mTmp, mTmp, transformFromSkeletonToGeometry);\r\n\r\n // TODO: maybe change upload order so that we can use\r\n // glsl constructor :\r\n // mat4(uBones[index], uBones[index+1], uBones[index+2], vec4(0.0, 0.0, 0.0, 1.0))\r\n // for faster glsl\r\n matPalette[uniformIndex++] = mTmp[0];\r\n matPalette[uniformIndex++] = mTmp[4];\r\n matPalette[uniformIndex++] = mTmp[8];\r\n matPalette[uniformIndex++] = mTmp[12];\r\n\r\n matPalette[uniformIndex++] = mTmp[1];\r\n matPalette[uniformIndex++] = mTmp[5];\r\n matPalette[uniformIndex++] = mTmp[9];\r\n matPalette[uniformIndex++] = mTmp[13];\r\n\r\n matPalette[uniformIndex++] = mTmp[2];\r\n matPalette[uniformIndex++] = mTmp[6];\r\n matPalette[uniformIndex++] = mTmp[10];\r\n matPalette[uniformIndex++] = mTmp[14];\r\n }\r\n };\r\n })(),\r\n\r\n update: function(geom) {\r\n if (!this._isInitialized) this.init(geom);\r\n\r\n this.computeMatrixPalette(\r\n geom.getMatrixFromSkeletonToGeometry(),\r\n geom.getInvMatrixFromSkeletonToGeometry()\r\n );\r\n }\r\n};\r\n\r\nexport default RigTransformHardware;\r\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport Geometry from '../osg/Geometry';\r\nimport notify from '../osg/notify';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport StateSet from '../osg/StateSet';\r\nimport MorphGeometry from './MorphGeometry';\r\nimport UpdateRigGeometry from './UpdateRigGeometry';\r\nimport RigTransformHardware from './RigTransformHardware';\r\nimport AnimationUpdateCallback from './AnimationUpdateCallback';\r\nimport ComputeMatrixFromNodePath from '../osg/computeMatrixFromNodePath';\r\n\r\n// RigGeometry is a Geometry deformed by bones\r\n// To connect bones to RigGeometry it requires:\r\n// - a map of bones with index / weight eg also called BoneMapID or VertexInfluenceMap\r\n// {\r\n// bone0: { index: [], // vertex index\r\n// weight: [] // weight for this index\r\n// },\r\n// bone2: { index: [],\r\n// weight: []\r\n// }\r\n// }\r\n\r\nvar RigGeometry = function() {\r\n Geometry.call(this);\r\n\r\n this._shape = null; // by default no kdtree/shape for rig\r\n\r\n this.addUpdateCallback(new UpdateRigGeometry());\r\n\r\n // handle matrixFromSkeletonToGeometry and invMatrixFromSkeletonToGeometry computation\r\n this._root = undefined;\r\n this._pathToRoot = undefined;\r\n this._isAnimatedPath = false;\r\n\r\n this._boneNameID = {};\r\n\r\n this._matrixFromSkeletonToGeometry = mat4.create();\r\n this._invMatrixFromSkeletonToGeometry = mat4.create();\r\n\r\n this._rigTransformImplementation = new RigTransformHardware();\r\n this._geometry = undefined;\r\n\r\n // RigGeometry have a special stateset that will be pushed at the very end of the culling\r\n // this stateSet only represents animation (and shouldn't contain any rendering attributes)\r\n // It's a way to make every RigGeometry unique (in term of stateSet stack)\r\n this._stateSetAnimation = new StateSet();\r\n\r\n this._needToComputeMatrix = true;\r\n};\r\n\r\nutils.createPrototypeNode(\r\n RigGeometry,\r\n utils.objectInherit(Geometry.prototype, {\r\n getStateSetAnimation: function() {\r\n return this._stateSetAnimation;\r\n },\r\n\r\n getSkeleton: function() {\r\n return this._root;\r\n },\r\n\r\n setSkeleton: function(root) {\r\n this._root = root;\r\n },\r\n\r\n setPathToSkeleton: function(path) {\r\n this._pathToRoot = path;\r\n this._isAnimatedPath = AnimationUpdateCallback.checkPathIsAnimated(path);\r\n },\r\n\r\n setNeedToComputeMatrix: function(needToComputeMatrix) {\r\n this._needToComputeMatrix = needToComputeMatrix;\r\n },\r\n\r\n getNeedToComputeMatrix: function() {\r\n return this._needToComputeMatrix;\r\n },\r\n\r\n computeBoundingBox: function(boundingBox) {\r\n boundingBox.init();\r\n\r\n var vertexArray = this.getVertexAttributeList().Vertex;\r\n var weightsArray = this.getVertexAttributeList().Weights;\r\n // mainly copy paste of geometry computeBoundingBox code, except we only\r\n // take into account the non-influenced vertices\r\n\r\n // we do that only for the non-influenced vertices because the rigged ones\r\n // can't be statically computed (full moving bbox of rigs should be computed externally\r\n // through bones or cpu rigged colision mesh, etc)\r\n // bbox is important for culling (near/far)\r\n\r\n if (\r\n vertexArray &&\r\n weightsArray &&\r\n vertexArray.getElements() &&\r\n vertexArray.getItemSize() > 2\r\n ) {\r\n var weights = weightsArray.getElements();\r\n var vertexes = vertexArray.getElements();\r\n var itemSize = vertexArray.getItemSize();\r\n\r\n var min = boundingBox.getMin();\r\n var max = boundingBox.getMax();\r\n\r\n var minx = min[0];\r\n var miny = min[1];\r\n var minz = min[2];\r\n var maxx = max[0];\r\n var maxy = max[1];\r\n var maxz = max[2];\r\n\r\n for (\r\n var idx = 0, idb = 0, l = vertexes.length;\r\n idx < l;\r\n idx += itemSize, idb += 4\r\n ) {\r\n if (\r\n weights[idx] !== 0.0 ||\r\n weights[idx + 1] !== 0.0 ||\r\n weights[idx + 2] !== 0.0 ||\r\n weights[idx + 3] !== 0.0\r\n )\r\n continue;\r\n\r\n var v1 = vertexes[idx];\r\n var v2 = vertexes[idx + 1];\r\n var v3 = vertexes[idx + 2];\r\n if (v1 < minx) minx = v1;\r\n if (v1 > maxx) maxx = v1;\r\n if (v2 < miny) miny = v2;\r\n if (v2 > maxy) maxy = v2;\r\n if (v3 < minz) minz = v3;\r\n if (v3 > maxz) maxz = v3;\r\n }\r\n\r\n min[0] = minx;\r\n min[1] = miny;\r\n min[2] = minz;\r\n max[0] = maxx;\r\n max[1] = maxy;\r\n max[2] = maxz;\r\n }\r\n\r\n return boundingBox;\r\n },\r\n\r\n computeMatrixFromRootSkeleton: function() {\r\n if (!this._root) {\r\n notify.warn(\r\n 'Warning ' +\r\n this.className() +\r\n '.computeMatrixFromRootSkeleton if you have this message it means you miss to call buildTransformer( root ), or your RigGeometry (' +\r\n this.getName() +\r\n ') is not attached to a Skeleton subgraph'\r\n );\r\n return;\r\n }\r\n\r\n mat4.identity(this._matrixFromSkeletonToGeometry);\r\n ComputeMatrixFromNodePath.computeLocalToWorld(\r\n this._pathToRoot,\r\n true,\r\n this._matrixFromSkeletonToGeometry\r\n );\r\n mat4.invert(this._invMatrixFromSkeletonToGeometry, this._matrixFromSkeletonToGeometry);\r\n\r\n if (!this._isAnimatedPath) this._needToComputeMatrix = false;\r\n },\r\n\r\n getMatrixFromSkeletonToGeometry: function() {\r\n return this._matrixFromSkeletonToGeometry;\r\n },\r\n\r\n getInvMatrixFromSkeletonToGeometry: function() {\r\n return this._invMatrixFromSkeletonToGeometry;\r\n },\r\n\r\n getSourceGeometry: function() {\r\n return this._geometry;\r\n },\r\n\r\n setSourceGeometry: function(geometry) {\r\n this._geometry = geometry;\r\n },\r\n\r\n getBoneNameID: function() {\r\n return this._boneNameID;\r\n },\r\n\r\n setBoneNameID: function(boneMap) {\r\n this._boneNameID = boneMap;\r\n },\r\n\r\n mergeChildrenVertexAttributeList: function() {\r\n if (this._geometry instanceof MorphGeometry)\r\n this._geometry.mergeChildrenVertexAttributeList();\r\n\r\n var sourceGeometryVertexAttributeList = this._geometry.getVertexAttributeList();\r\n\r\n Geometry.appendVertexAttributeToList(\r\n sourceGeometryVertexAttributeList,\r\n this.getVertexAttributeList()\r\n );\r\n },\r\n\r\n mergeChildrenData: function() {\r\n // move to the rig the vertex attributes, the primitives and the stateset\r\n\r\n this.mergeChildrenVertexAttributeList();\r\n var primitiveSetList = this._geometry.getPrimitiveSetList();\r\n\r\n this.getPrimitiveSetList().length = 0;\r\n for (var i = 0, il = primitiveSetList.length; i < il; i++)\r\n this.getPrimitiveSetList()[i] = primitiveSetList[i];\r\n\r\n if (this.getStateSet())\r\n console.error('A stateset in the rig is already present : ' + this.getStateSet());\r\n this.setStateSet(this._geometry.getStateSet());\r\n },\r\n\r\n update: function() {\r\n this._rigTransformImplementation.update(this);\r\n },\r\n\r\n computeTransformedVertex: function(id, out) {\r\n out = out || vec3.create();\r\n\r\n var vList = this.getVertexAttributeList();\r\n var vWeights = vList.Weights.getElements();\r\n var vBones = vList.Bones.getElements();\r\n\r\n var x = 0.0;\r\n var y = 0.0;\r\n var z = 0.0;\r\n if (this._geometry.computeTransformedVertex) {\r\n this._geometry.computeTransformedVertex(id, out);\r\n x = out[0];\r\n y = out[1];\r\n z = out[2];\r\n } else {\r\n var verts = vList.Vertex.getElements();\r\n x = verts[id * 3];\r\n y = verts[id * 3 + 1];\r\n z = verts[id * 3 + 2];\r\n }\r\n\r\n var id4 = id * 4;\r\n\r\n var palette = this._rigTransformImplementation._skinningAttribute.getMatrixPalette();\r\n var m0 = 0.0;\r\n var m1 = 0.0;\r\n var m2 = 0.0;\r\n var m4 = 0.0;\r\n var m5 = 0.0;\r\n var m6 = 0.0;\r\n var m8 = 0.0;\r\n var m9 = 0.0;\r\n var m10 = 0.0;\r\n var m12 = 0.0;\r\n var m13 = 0.0;\r\n var m14 = 0.0;\r\n var m15 = 0.0;\r\n\r\n var doSkin = false;\r\n for (var i = 0; i < 4; ++i) {\r\n var w = vWeights[id4 + i];\r\n if (w === 0.0) continue;\r\n\r\n var idBone = vBones[id4 + i] * 12;\r\n\r\n m0 += palette[idBone + 0] * w;\r\n m4 += palette[idBone + 1] * w;\r\n m8 += palette[idBone + 2] * w;\r\n m12 += palette[idBone + 3] * w;\r\n\r\n m1 += palette[idBone + 4] * w;\r\n m5 += palette[idBone + 5] * w;\r\n m9 += palette[idBone + 6] * w;\r\n m13 += palette[idBone + 7] * w;\r\n\r\n m2 += palette[idBone + 8] * w;\r\n m6 += palette[idBone + 9] * w;\r\n m10 += palette[idBone + 10] * w;\r\n m14 += palette[idBone + 11] * w;\r\n\r\n m15 += w;\r\n doSkin = true;\r\n }\r\n\r\n if (!doSkin) {\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n }\r\n\r\n var d = 1.0 / m15;\r\n out[0] = (m0 * x + m4 * y + m8 * z + m12) * d;\r\n out[1] = (m1 * x + m5 * y + m9 * z + m13) * d;\r\n out[2] = (m2 * x + m6 * y + m10 * z + m14) * d;\r\n\r\n return out;\r\n },\r\n\r\n computeTransformedVertices: function() {\r\n // obviously slow as it can't rely on kdTree AND we transform everything cpu side\r\n\r\n var vList = this.getVertexAttributeList();\r\n var verts = this._geometry.computeTransformedVertices\r\n ? this._geometry.computeTransformedVertices()\r\n : vList.Vertex.getElements();\r\n var vWeights = vList.Weights.getElements();\r\n var vBones = vList.Bones.getElements();\r\n\r\n var riggedVerts = this._riggedVerts || new Float32Array(verts.length);\r\n\r\n // /!\\ if the geometry has several parents inside a skeleton\r\n // it might not work as it will just take the last compute matrix palette\r\n var palette = this._rigTransformImplementation._skinningAttribute.getMatrixPalette();\r\n\r\n // verbose... but fast\r\n for (var idv = 0, idr = 0, len = verts.length; idv < len; idv += 3, idr += 4) {\r\n var m0 = 0.0;\r\n var m1 = 0.0;\r\n var m2 = 0.0;\r\n\r\n var m4 = 0.0;\r\n var m5 = 0.0;\r\n var m6 = 0.0;\r\n\r\n var m8 = 0.0;\r\n var m9 = 0.0;\r\n var m10 = 0.0;\r\n\r\n var m12 = 0.0;\r\n var m13 = 0.0;\r\n var m14 = 0.0;\r\n var m15 = 0.0;\r\n\r\n var doSkin = false;\r\n\r\n var w = vWeights[idr];\r\n var idBone;\r\n if (w !== 0.0) {\r\n idBone = vBones[idr] * 12;\r\n m0 += palette[idBone + 0] * w;\r\n m4 += palette[idBone + 1] * w;\r\n m8 += palette[idBone + 2] * w;\r\n m12 += palette[idBone + 3] * w;\r\n\r\n m1 += palette[idBone + 4] * w;\r\n m5 += palette[idBone + 5] * w;\r\n m9 += palette[idBone + 6] * w;\r\n m13 += palette[idBone + 7] * w;\r\n\r\n m2 += palette[idBone + 8] * w;\r\n m6 += palette[idBone + 9] * w;\r\n m10 += palette[idBone + 10] * w;\r\n m14 += palette[idBone + 11] * w;\r\n\r\n m15 += w;\r\n doSkin = true;\r\n }\r\n\r\n w = vWeights[idr + 1];\r\n if (w !== 0.0) {\r\n idBone = vBones[idr + 1] * 12;\r\n m0 += palette[idBone + 0] * w;\r\n m4 += palette[idBone + 1] * w;\r\n m8 += palette[idBone + 2] * w;\r\n m12 += palette[idBone + 3] * w;\r\n\r\n m1 += palette[idBone + 4] * w;\r\n m5 += palette[idBone + 5] * w;\r\n m9 += palette[idBone + 6] * w;\r\n m13 += palette[idBone + 7] * w;\r\n\r\n m2 += palette[idBone + 8] * w;\r\n m6 += palette[idBone + 9] * w;\r\n m10 += palette[idBone + 10] * w;\r\n m14 += palette[idBone + 11] * w;\r\n\r\n m15 += w;\r\n doSkin = true;\r\n }\r\n\r\n w = vWeights[idr + 2];\r\n if (w !== 0.0) {\r\n idBone = vBones[idr + 2] * 12;\r\n\r\n m0 += palette[idBone + 0] * w;\r\n m4 += palette[idBone + 1] * w;\r\n m8 += palette[idBone + 2] * w;\r\n m12 += palette[idBone + 3] * w;\r\n\r\n m1 += palette[idBone + 4] * w;\r\n m5 += palette[idBone + 5] * w;\r\n m9 += palette[idBone + 6] * w;\r\n m13 += palette[idBone + 7] * w;\r\n\r\n m2 += palette[idBone + 8] * w;\r\n m6 += palette[idBone + 9] * w;\r\n m10 += palette[idBone + 10] * w;\r\n m14 += palette[idBone + 11] * w;\r\n\r\n m15 += w;\r\n doSkin = true;\r\n }\r\n\r\n w = vWeights[idr + 3];\r\n if (w !== 0.0) {\r\n idBone = vBones[idr + 3] * 12;\r\n\r\n m0 += palette[idBone + 0] * w;\r\n m4 += palette[idBone + 1] * w;\r\n m8 += palette[idBone + 2] * w;\r\n m12 += palette[idBone + 3] * w;\r\n\r\n m1 += palette[idBone + 4] * w;\r\n m5 += palette[idBone + 5] * w;\r\n m9 += palette[idBone + 6] * w;\r\n m13 += palette[idBone + 7] * w;\r\n\r\n m2 += palette[idBone + 8] * w;\r\n m6 += palette[idBone + 9] * w;\r\n m10 += palette[idBone + 10] * w;\r\n m14 += palette[idBone + 11] * w;\r\n\r\n m15 += w;\r\n doSkin = true;\r\n }\r\n\r\n var x = verts[idv];\r\n var y = verts[idv + 1];\r\n var z = verts[idv + 2];\r\n\r\n if (!doSkin) {\r\n riggedVerts[idv] = x;\r\n riggedVerts[idv + 1] = y;\r\n riggedVerts[idv + 2] = z;\r\n continue;\r\n }\r\n\r\n var d = 1.0 / m15;\r\n riggedVerts[idv] = (m0 * x + m4 * y + m8 * z + m12) * d;\r\n riggedVerts[idv + 1] = (m1 * x + m5 * y + m9 * z + m13) * d;\r\n riggedVerts[idv + 2] = (m2 * x + m6 * y + m10 * z + m14) * d;\r\n }\r\n\r\n return riggedVerts;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'RigGeometry'\r\n);\r\n\r\nexport default RigGeometry;\r\n","export default {\r\n NO_LIMIT: 0,\r\n LIMIT_ONE_PER_DRAWABLE: 1,\r\n LIMIT_ONE: 2,\r\n\r\n // PrimitiveMask\r\n POINT_PRIMITIVES: 1 << 0, /// check for points\r\n LINE_PRIMITIVES: 1 << 1, /// check for lines\r\n TRIANGLE_PRIMITIVES: 1 << 2, /// check for triangles and other primitives like quad, polygons that can be decomposed into triangles\r\n ALL_PRIMITIVES: (1 << 0) | (1 << 1) | (1 << 2)\r\n};\r\n","import utils from './utils';\r\nimport Lod from './Lod';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport { mat4 } from './glMatrix';\r\nimport { vec3 } from './glMatrix';\r\n\r\n/**\r\n * PagedLOD that can contains paged child nodes\r\n * @class PagedLod\r\n */\r\nvar PagedLOD = function() {\r\n Lod.call(this);\r\n this._perRangeDataList = [];\r\n this._loading = false;\r\n this._expiryTime = 0.0;\r\n this._expiryFrame = 0;\r\n this._centerMode = Lod.USER_DEFINED_CENTER;\r\n this._frameNumberOfLastTraversal = 0;\r\n this._databasePath = '';\r\n this._numChildrenThatCannotBeExpired = 0;\r\n};\r\n\r\n/**\r\n * PerRangeData utility structure to store per range values\r\n * @class PerRangeData\r\n */\r\nvar PerRangeData = function() {\r\n this.filename = '';\r\n this.function = undefined;\r\n this.loaded = false;\r\n this.timeStamp = 0.0;\r\n this.frameNumber = 0;\r\n this.frameNumberOfLastTraversal = 0;\r\n this.dbrequest = undefined;\r\n};\r\n\r\n/** @lends PagedLOD.prototype */\r\nutils.createPrototypeNode(\r\n PagedLOD,\r\n utils.objectInherit(Lod.prototype, {\r\n // Functions here\r\n setRange: function(childNo, min, max) {\r\n if (childNo >= this._range.length) {\r\n var r = [];\r\n r.push([min, min]);\r\n this._range.push(r);\r\n }\r\n this._range[childNo][0] = min;\r\n this._range[childNo][1] = max;\r\n },\r\n\r\n setExpiryTime: function(expiryTime) {\r\n this._expiryTime = expiryTime;\r\n },\r\n\r\n setDatabasePath: function(path) {\r\n this._databasePath = path;\r\n },\r\n\r\n getDatabasePath: function() {\r\n return this._databasePath;\r\n },\r\n\r\n setFileName: function(childNo, filename) {\r\n // May we should expand the vector first?\r\n if (childNo >= this._perRangeDataList.length) {\r\n var rd = new PerRangeData();\r\n rd.filename = filename;\r\n this._perRangeDataList.push(rd);\r\n } else {\r\n this._perRangeDataList[childNo].filename = filename;\r\n }\r\n },\r\n setFunction: function(childNo, func) {\r\n if (childNo >= this._perRangeDataList.length) {\r\n var rd = new PerRangeData();\r\n rd.function = func;\r\n this._perRangeDataList.push(rd);\r\n } else {\r\n this._perRangeDataList[childNo].function = func;\r\n }\r\n },\r\n\r\n addChild: function(node, min, max) {\r\n Lod.prototype.addChild.call(this, node, min, max);\r\n this._perRangeDataList.push(new PerRangeData());\r\n },\r\n\r\n addChildNode: function(node) {\r\n Lod.prototype.addChildNode.call(this, node);\r\n },\r\n\r\n setFrameNumberOfLastTraversal: function(frameNumber) {\r\n this._frameNumberOfLastTraversal = frameNumber;\r\n },\r\n\r\n getFrameNumberOfLastTraversal: function() {\r\n return this._frameNumberOfLastTraversal;\r\n },\r\n setTimeStamp: function(childNo, timeStamp) {\r\n this._perRangeDataList[childNo].timeStamp = timeStamp;\r\n },\r\n setFrameNumber: function(childNo, frameNumber) {\r\n this._perRangeDataList[childNo].frameNumber = frameNumber;\r\n },\r\n setNumChildrenThatCannotBeExpired: function(num) {\r\n this._numChildrenThatCannotBeExpired = num;\r\n },\r\n getNumChildrenThatCannotBeExpired: function() {\r\n return this._numChildrenThatCannotBeExpired;\r\n },\r\n getDatabaseRequest: function(childNo) {\r\n return this._perRangeDataList[childNo].dbrequest;\r\n },\r\n removeExpiredChildren: function(expiryTime, expiryFrame, removedChildren) {\r\n if (this.children.length <= this._numChildrenThatCannotBeExpired) return;\r\n var i = this.children.length - 1;\r\n var timed, framed;\r\n timed = this._perRangeDataList[i].timeStamp + this._expiryTime;\r\n framed = this._perRangeDataList[i].frameNumber + this._expiryFrame;\r\n if (\r\n timed < expiryTime &&\r\n framed < expiryFrame &&\r\n (this._perRangeDataList[i].filename.length > 0 ||\r\n this._perRangeDataList[i].function !== undefined)\r\n ) {\r\n removedChildren.push(this.children[i]);\r\n this.removeChild(this.children[i]);\r\n this._perRangeDataList[i].loaded = false;\r\n if (this._perRangeDataList[i].dbrequest !== undefined) {\r\n this._perRangeDataList[i].dbrequest._groupExpired = true;\r\n }\r\n }\r\n },\r\n\r\n traverse: (function() {\r\n // avoid to generate variable on the heap to limit garbage collection\r\n // instead create variable and use the same each time\r\n var zeroVector = vec3.create();\r\n var eye = vec3.create();\r\n var viewModel = mat4.create();\r\n\r\n return function(visitor) {\r\n var traversalMode = visitor.traversalMode;\r\n var updateTimeStamp = false;\r\n\r\n if (visitor.getVisitorType() === NodeVisitor.CULL_VISITOR) {\r\n this._frameNumberOfLastTraversal = visitor.getFrameStamp().getFrameNumber();\r\n updateTimeStamp = true;\r\n }\r\n\r\n switch (traversalMode) {\r\n case NodeVisitor.TRAVERSE_ALL_CHILDREN:\r\n for (var index = 0; index < this.children.length; index++) {\r\n this.children[index].accept(visitor);\r\n }\r\n break;\r\n\r\n case NodeVisitor.TRAVERSE_ACTIVE_CHILDREN:\r\n var requiredRange = 0;\r\n\r\n // Calculate distance from viewpoint\r\n var matrix = visitor.getCurrentModelViewMatrix();\r\n mat4.invert(viewModel, matrix);\r\n if (this._rangeMode === Lod.DISTANCE_FROM_EYE_POINT) {\r\n vec3.transformMat4(eye, zeroVector, viewModel);\r\n var d = vec3.distance(this.getBound().center(), eye);\r\n requiredRange = d * visitor.getLODScale();\r\n } else {\r\n // Calculate pixels on screen\r\n var projmatrix = visitor.getCurrentProjectionMatrix();\r\n // focal lenght is the value stored in projmatrix[0]\r\n requiredRange = this.projectBoundingSphere(\r\n this.getBound(),\r\n matrix,\r\n projmatrix[0]\r\n );\r\n // Get the real area value and apply LODScale\r\n requiredRange =\r\n requiredRange *\r\n visitor.getViewport().width() *\r\n visitor.getViewport().width() *\r\n 0.25 /\r\n visitor.getLODScale();\r\n if (requiredRange < 0)\r\n requiredRange = this._range[this._range.length - 1][0];\r\n }\r\n\r\n var needToLoadChild = false;\r\n var lastChildTraversed = -1;\r\n for (var j = 0; j < this._range.length; ++j) {\r\n if (\r\n this._range[j][0] <= requiredRange &&\r\n requiredRange < this._range[j][1]\r\n ) {\r\n if (j < this.children.length) {\r\n if (updateTimeStamp) {\r\n this._perRangeDataList[\r\n j\r\n ].timeStamp = visitor.getFrameStamp().getSimulationTime();\r\n this._perRangeDataList[\r\n j\r\n ].frameNumber = visitor.getFrameStamp().getFrameNumber();\r\n }\r\n\r\n this.children[j].accept(visitor);\r\n lastChildTraversed = j;\r\n } else {\r\n needToLoadChild = true;\r\n }\r\n }\r\n }\r\n if (needToLoadChild) {\r\n var numChildren = this.children.length;\r\n if (numChildren > 0 && numChildren - 1 !== lastChildTraversed) {\r\n if (updateTimeStamp) {\r\n this._perRangeDataList[\r\n numChildren - 1\r\n ].timeStamp = visitor.getFrameStamp().getSimulationTime();\r\n this._perRangeDataList[\r\n numChildren - 1\r\n ].frameNumber = visitor.getFrameStamp().getFrameNumber();\r\n }\r\n\r\n this.children[numChildren - 1].accept(visitor);\r\n }\r\n // now request the loading of the next unloaded child.\r\n if (numChildren < this._perRangeDataList.length) {\r\n // compute priority from where abouts in the required range the distance falls.\r\n var priority =\r\n (this._range[numChildren][0] - requiredRange) /\r\n (this._range[numChildren][1] - this._range[numChildren][0]);\r\n if (this._rangeMode === Lod.PIXEL_SIZE_ON_SCREEN) {\r\n priority = -priority;\r\n }\r\n // Here we do the request\r\n var group = visitor.nodePath[visitor.nodePath.length - 1];\r\n if (this._perRangeDataList[numChildren].loaded === false) {\r\n this._perRangeDataList[numChildren].loaded = true;\r\n var dbhandler = visitor.getDatabaseRequestHandler();\r\n this._perRangeDataList[\r\n numChildren\r\n ].dbrequest = dbhandler.requestNodeFile(\r\n this._perRangeDataList[numChildren].function,\r\n this._databasePath +\r\n this._perRangeDataList[numChildren].filename,\r\n group,\r\n visitor.getFrameStamp().getSimulationTime(),\r\n priority\r\n );\r\n } else {\r\n // Update timestamp of the request.\r\n if (\r\n this._perRangeDataList[numChildren].dbrequest !== undefined\r\n ) {\r\n this._perRangeDataList[\r\n numChildren\r\n ].dbrequest._timeStamp = visitor\r\n .getFrameStamp()\r\n .getSimulationTime();\r\n this._perRangeDataList[\r\n numChildren\r\n ].dbrequest._priority = priority;\r\n } else {\r\n // The DB request is undefined, so the DBPager was not accepting requests, we need to ask for the child again.\r\n this._perRangeDataList[numChildren].loaded = false;\r\n }\r\n }\r\n }\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n };\r\n })()\r\n }),\r\n 'osg',\r\n 'PagedLOD'\r\n);\r\n\r\nexport default PagedLOD;","import notify from './notify';\r\nimport utils from './utils';\r\nimport { vec3, mat4 } from './glMatrix';\r\n\r\nvar BoundingBox = function() {\r\n this._min = vec3.create();\r\n this._max = vec3.create();\r\n this.init();\r\n};\r\n\r\nutils.createPrototypeObject(\r\n BoundingBox,\r\n {\r\n init: function() {\r\n vec3.copy(this._min, vec3.INFINITY);\r\n vec3.copy(this._max, vec3.NEGATIVE_INFINITY);\r\n },\r\n\r\n volume: function() {\r\n var v = this._max[0] - this._min[0];\r\n v *= this._max[1] - this._min[1];\r\n v *= this._max[2] - this._min[2];\r\n return v;\r\n },\r\n\r\n copy: function(box) {\r\n vec3.copy(this._min, box._min);\r\n vec3.copy(this._max, box._max);\r\n },\r\n\r\n valid: function() {\r\n return (\r\n this._max[0] >= this._min[0] &&\r\n this._max[1] >= this._min[1] &&\r\n this._max[2] >= this._min[2]\r\n );\r\n },\r\n\r\n expandByBoundingSphere: function(bs) {\r\n if (!bs.valid()) {\r\n return;\r\n }\r\n var max = this._max;\r\n var min = this._min;\r\n var radius = bs._radius;\r\n var x = bs._center[0];\r\n var y = bs._center[1];\r\n var z = bs._center[2];\r\n min[0] = Math.min(min[0], x - radius);\r\n min[1] = Math.min(min[1], y - radius);\r\n min[2] = Math.min(min[2], z - radius);\r\n\r\n max[0] = Math.max(max[0], x + radius);\r\n max[1] = Math.max(max[1], y + radius);\r\n max[2] = Math.max(max[2], z + radius);\r\n },\r\n\r\n expandByvec3: function(v) {\r\n notify.warn('deprecated, use expandByVec3');\r\n this.expandByVec3(v);\r\n },\r\n\r\n expandByVec3: function(v) {\r\n var min = this._min;\r\n var max = this._max;\r\n min[0] = Math.min(min[0], v[0]);\r\n min[1] = Math.min(min[1], v[1]);\r\n min[2] = Math.min(min[2], v[2]);\r\n\r\n max[0] = Math.max(max[0], v[0]);\r\n max[1] = Math.max(max[1], v[1]);\r\n max[2] = Math.max(max[2], v[2]);\r\n },\r\n\r\n expandByBoundingBox: function(bb) {\r\n if (!bb.valid()) return;\r\n\r\n var min = this._min;\r\n var max = this._max;\r\n var bbmin = bb._min;\r\n var bbmax = bb._max;\r\n\r\n if (bbmin[0] < min[0]) min[0] = bbmin[0];\r\n if (bbmax[0] > max[0]) max[0] = bbmax[0];\r\n\r\n if (bbmin[1] < min[1]) min[1] = bbmin[1];\r\n if (bbmax[1] > max[1]) max[1] = bbmax[1];\r\n\r\n if (bbmin[2] < min[2]) min[2] = bbmin[2];\r\n if (bbmax[2] > max[2]) max[2] = bbmax[2];\r\n },\r\n\r\n center: function(result) {\r\n var min = this._min;\r\n var max = this._max;\r\n result[0] = (min[0] + max[0]) * 0.5;\r\n result[1] = (min[1] + max[1]) * 0.5;\r\n result[2] = (min[2] + max[2]) * 0.5;\r\n return result;\r\n },\r\n\r\n radius: function() {\r\n return Math.sqrt(this.radius2());\r\n },\r\n\r\n radius2: function() {\r\n var min = this._min;\r\n var max = this._max;\r\n var dx = max[0] - min[0];\r\n var dy = max[1] - min[1];\r\n var dz = max[2] - min[2];\r\n return 0.25 * (dx * dx + dy * dy + dz * dz);\r\n },\r\n\r\n getMin: function() {\r\n return this._min;\r\n },\r\n\r\n getMax: function() {\r\n return this._max;\r\n },\r\n\r\n setMin: function(min) {\r\n vec3.copy(this._min, min);\r\n return this;\r\n },\r\n\r\n setMax: function(max) {\r\n vec3.copy(this._max, max);\r\n return this;\r\n },\r\n\r\n xMax: function() {\r\n return this._max[0];\r\n },\r\n\r\n yMax: function() {\r\n return this._max[1];\r\n },\r\n\r\n zMax: function() {\r\n return this._max[2];\r\n },\r\n\r\n xMin: function() {\r\n return this._min[0];\r\n },\r\n\r\n yMin: function() {\r\n return this._min[1];\r\n },\r\n\r\n zMin: function() {\r\n return this._min[2];\r\n },\r\n\r\n corner: function(pos, ret) {\r\n /*jshint bitwise: false */\r\n if (pos & 1) {\r\n ret[0] = this._max[0];\r\n } else {\r\n ret[0] = this._min[0];\r\n }\r\n if (pos & 2) {\r\n ret[1] = this._max[1];\r\n } else {\r\n ret[1] = this._min[1];\r\n }\r\n if (pos & 4) {\r\n ret[2] = this._max[2];\r\n } else {\r\n ret[2] = this._min[2];\r\n }\r\n return ret;\r\n /*jshint bitwise: true */\r\n },\r\n\r\n // http://dev.theomader.com/transform-bounding-boxes/\r\n // https://github.com/erich666/GraphicsGems/blob/master/gems/TransBox.c\r\n transformMat4: (function() {\r\n var tmpMin = vec3.create();\r\n var tmpMax = vec3.create();\r\n return function(out, m) {\r\n var inMin = this.getMin();\r\n var inMax = this.getMax();\r\n\r\n /* Take care of translation by beginning at T. */\r\n mat4.getTranslation(tmpMin, m);\r\n vec3.copy(tmpMax, tmpMin);\r\n\r\n /* Now find the extreme points by considering the product of the */\r\n /* min and max with each component of M. */\r\n for (var i = 0; i < 3; ++i) {\r\n var i4 = i * 4;\r\n var mini = inMin[i];\r\n var maxi = inMax[i];\r\n for (var j = 0; j < 3; ++j) {\r\n var cm = m[i4 + j];\r\n var a = cm * maxi;\r\n var b = cm * mini;\r\n if (a < b) {\r\n tmpMin[j] += a;\r\n tmpMax[j] += b;\r\n } else {\r\n tmpMin[j] += b;\r\n tmpMax[j] += a;\r\n }\r\n }\r\n }\r\n var outMax = out.getMax();\r\n var outMin = out.getMin();\r\n\r\n outMax[0] = tmpMax[0];\r\n outMax[1] = tmpMax[1];\r\n outMax[2] = tmpMax[2];\r\n\r\n outMin[0] = tmpMin[0];\r\n outMin[1] = tmpMin[1];\r\n outMin[2] = tmpMin[2];\r\n\r\n return out;\r\n };\r\n })()\r\n },\r\n 'osg',\r\n 'BoundingBox'\r\n);\r\n\r\nexport default BoundingBox;\r\n","export default {\r\n RELATIVE_RF: 0,\r\n ABSOLUTE_RF: 1\r\n};\r\n","import notify from './notify';\r\nimport utils from './utils';\r\nimport osgMath from './math';\r\nimport NodeVisitor from './NodeVisitor';\r\nimport CullSettings from './CullSettings';\r\nimport CullStack from './CullStack';\r\nimport { mat4 } from './glMatrix';\r\nimport MatrixTransform from './MatrixTransform';\r\nimport AutoTransform from './AutoTransform';\r\nimport Projection from './Projection';\r\nimport LightSource from './LightSource';\r\nimport cullVisitorHelper from './cullVisitorHelper';\r\nimport Geometry from './Geometry';\r\nimport RenderLeaf from './RenderLeaf';\r\nimport RenderBin from './RenderBin';\r\nimport RenderStage from './RenderStage';\r\nimport Node from './Node';\r\nimport Lod from './Lod';\r\nimport Switch from './Switch';\r\nimport PagedLOD from './PagedLOD';\r\nimport Camera from './Camera';\r\nimport TransformEnums from './transformEnums';\r\nimport { vec3 } from './glMatrix';\r\nimport Skeleton from '../osgAnimation/Skeleton';\r\nimport RigGeometry from '../osgAnimation/RigGeometry';\r\nimport Bone from '../osgAnimation/Bone';\r\nimport MorphGeometry from '../osgAnimation/MorphGeometry';\r\nimport PooledArray from './PooledArray';\r\nimport PooledResource from './PooledResource';\r\n\r\nvar createRenderLeaf = function() {\r\n return new RenderLeaf();\r\n};\r\n\r\nvar createCullSettings = function() {\r\n return new CullSettings();\r\n};\r\n\r\n/**\r\n * CullVisitor traverse the tree and collect Matrix/State for the rendering traverse\r\n * @class CullVisitor\r\n */\r\nvar CullVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ACTIVE_CHILDREN);\r\n CullSettings.call(this);\r\n CullStack.call(this);\r\n\r\n this._rootStateGraph = undefined;\r\n this._currentStateGraph = undefined;\r\n this._currentRenderBin = undefined;\r\n this._currentRenderStage = undefined;\r\n this._rootRenderStage = undefined;\r\n this._computedNear = Number.POSITIVE_INFINITY;\r\n this._computedFar = Number.NEGATIVE_INFINITY;\r\n\r\n this._camera = undefined;\r\n\r\n this._pooledLeaf = new PooledResource(createRenderLeaf);\r\n\r\n this._pooledRenderStages = {};\r\n\r\n this._pooledCullSettings = new PooledResource(createCullSettings);\r\n\r\n this._renderBinStack = new PooledArray();\r\n this.visitorType = NodeVisitor.CULL_VISITOR;\r\n\r\n this._identityMatrix = mat4.create();\r\n\r\n this._renderer = undefined;\r\n this._renderStageType = RenderStage;\r\n\r\n this._numCamera = 0;\r\n this._numMatrixTransform = 0;\r\n this._numProjection = 0;\r\n this._numNode = 0;\r\n this._numLightSource = 0;\r\n this._numGeometry = 0;\r\n};\r\n\r\nCullVisitor.registerApplyFunction = cullVisitorHelper.registerApplyFunction;\r\nCullVisitor.getApplyFunction = cullVisitorHelper.getApplyFunction;\r\n\r\nutils.createPrototypeObject(\r\n CullVisitor,\r\n utils.objectInherit(\r\n CullStack.prototype,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n applyFunctionArray: cullVisitorHelper.applyFunctionArray,\r\n\r\n distance: function(coord, matrix) {\r\n return -(\r\n coord[0] * matrix[2] +\r\n coord[1] * matrix[6] +\r\n coord[2] * matrix[10] +\r\n matrix[14]\r\n );\r\n },\r\n\r\n getComputedNear: function() {\r\n return this._computedNear;\r\n },\r\n\r\n getComputedFar: function() {\r\n return this._computedFar;\r\n },\r\n\r\n resetStats: function() {\r\n this._numCamera = 0;\r\n this._numMatrixTransform = 0;\r\n this._numProjection = 0;\r\n this._numNode = 0;\r\n this._numLightSource = 0;\r\n this._numGeometry = 0;\r\n },\r\n\r\n handleCullCallbacksAndTraverse: function(node) {\r\n var ccb = node.getCullCallback();\r\n if (ccb && !ccb.cull(node, this)) return;\r\n this.traverse(node);\r\n },\r\n\r\n getCurrentCamera: function() {\r\n return this._currentRenderBin.getStage().getCamera();\r\n },\r\n\r\n updateCalculatedNearFar: (function() {\r\n var nearVec = vec3.create();\r\n var farVec = vec3.create();\r\n\r\n return function(matrix, drawable) {\r\n var bb = drawable.getBoundingBox();\r\n var dNear, dFar;\r\n\r\n // efficient computation of near and far, only taking into account the nearest and furthest\r\n // corners of the bounding box.\r\n dNear = this.distance(bb.corner(this._bbCornerNear, nearVec), matrix);\r\n dFar = this.distance(bb.corner(this._bbCornerFar, farVec), matrix);\r\n\r\n if (dNear > dFar) {\r\n var tmp = dNear;\r\n dNear = dFar;\r\n dFar = tmp;\r\n }\r\n\r\n if (dFar < 0.0) {\r\n // whole object behind the eye point so discard\r\n return false;\r\n }\r\n\r\n if (dNear < this._computedNear) {\r\n this._computedNear = dNear;\r\n }\r\n\r\n if (dFar > this._computedFar) {\r\n this._computedFar = dFar;\r\n }\r\n\r\n return true;\r\n };\r\n })(),\r\n\r\n setStateGraph: function(sg) {\r\n this._rootStateGraph = sg;\r\n this._currentStateGraph = sg;\r\n },\r\n setRenderStage: function(rg) {\r\n this._rootRenderStage = rg;\r\n this._currentRenderBin = rg;\r\n },\r\n setRenderer: function(renderer) {\r\n this._renderer = renderer;\r\n },\r\n getRenderer: function() {\r\n return this._renderer;\r\n },\r\n\r\n reset: function() {\r\n CullStack.prototype.reset.call(this);\r\n\r\n this._pooledLeaf.reset();\r\n this._pooledCullSettings.reset();\r\n\r\n // renderstage / renderbin pools\r\n for (var key in this._pooledRenderStages) {\r\n this._pooledRenderStages[key].reset();\r\n }\r\n RenderBin.reset();\r\n\r\n this._computedNear = Number.POSITIVE_INFINITY;\r\n this._computedFar = Number.NEGATIVE_INFINITY;\r\n },\r\n\r\n getCurrentRenderBin: function() {\r\n return this._currentRenderBin;\r\n },\r\n\r\n setCurrentRenderBin: function(rb) {\r\n this._currentRenderBin = rb;\r\n },\r\n\r\n // mimic the osg implementation\r\n // in osg you can push 0, in this case an identity matrix will be loaded\r\n addPositionedAttribute: function(matrix, attribute) {\r\n var m = matrix ? matrix : this._identityMatrix;\r\n this._currentRenderBin.getStage().addPositionAttribute(m, attribute);\r\n },\r\n\r\n pushStateSet: function(stateset) {\r\n this._currentStateGraph = this._currentStateGraph.findOrInsert(stateset);\r\n if (stateset.getBinName() !== undefined) {\r\n var renderBinStack = this._renderBinStack;\r\n var currentRenderBin = this._currentRenderBin;\r\n renderBinStack.push(currentRenderBin);\r\n this._currentRenderBin = currentRenderBin\r\n .getStage()\r\n .findOrInsert(stateset.getBinNumber(), stateset.getBinName());\r\n }\r\n },\r\n\r\n /** Pop the top state set and hence associated state group.\r\n * Move the current state group to the parent of the popped\r\n * state group.\r\n */\r\n popStateSet: function() {\r\n var currentStateGraph = this._currentStateGraph;\r\n var stateset = currentStateGraph.getStateSet();\r\n this._currentStateGraph = currentStateGraph.getParent();\r\n if (stateset.getBinName() !== undefined) {\r\n var renderBinStack = this._renderBinStack;\r\n if (renderBinStack.getLength() === 0) {\r\n this._currentRenderBin = this._currentRenderBin.getStage();\r\n } else {\r\n this._currentRenderBin = renderBinStack.pop();\r\n }\r\n }\r\n },\r\n\r\n popProjectionMatrix: function() {\r\n if (this._computeNearFar === true && this._computedFar >= this._computedNear) {\r\n var m = this.getCurrentProjectionMatrix();\r\n if (this._clampProjectionMatrixCallback !== undefined) {\r\n this._clampProjectionMatrixCallback(\r\n m,\r\n this._computedNear,\r\n this._computedFar,\r\n this._nearFarRatio\r\n );\r\n } else {\r\n this.clampProjectionMatrix(\r\n m,\r\n this._computedNear,\r\n this._computedFar,\r\n this._nearFarRatio\r\n );\r\n }\r\n }\r\n CullStack.prototype.popProjectionMatrix.call(this);\r\n },\r\n\r\n clampProjectionMatrix: function(projection, znear, zfar, nearFarRatio, resultNearFar) {\r\n var epsilon = 1e-6;\r\n if (zfar < znear - epsilon) {\r\n notify.log(\r\n 'clampProjectionMatrix not applied, invalid depth range, znear = ' +\r\n znear +\r\n ' zfar = ' +\r\n zfar,\r\n false,\r\n true\r\n );\r\n return false;\r\n }\r\n\r\n var desiredZnear, desiredZfar;\r\n if (zfar < znear + epsilon) {\r\n // znear and zfar are too close together and could cause divide by zero problems\r\n // late on in the clamping code, so move the znear and zfar apart.\r\n var average = (znear + zfar) * 0.5;\r\n znear = average - epsilon;\r\n zfar = average + epsilon;\r\n // OSG_INFO << '_clampProjectionMatrix widening znear and zfar to '<<znear<<' '<<zfar<<std::endl;\r\n }\r\n\r\n if (\r\n Math.abs(projection[3]) < epsilon &&\r\n Math.abs(projection[7]) < epsilon &&\r\n Math.abs(projection[11]) < epsilon\r\n ) {\r\n // OSG_INFO << 'Orthographic matrix before clamping'<<projection<<std::endl;\r\n\r\n var deltaSpan = (zfar - znear) * 0.02;\r\n if (deltaSpan < 1.0) {\r\n deltaSpan = 1.0;\r\n }\r\n desiredZnear = znear - deltaSpan;\r\n desiredZfar = zfar + deltaSpan;\r\n\r\n // assign the clamped values back to the computed values.\r\n znear = desiredZnear;\r\n zfar = desiredZfar;\r\n\r\n projection[10] = -2.0 / (desiredZfar - desiredZnear);\r\n projection[14] = -(desiredZfar + desiredZnear) / (desiredZfar - desiredZnear);\r\n // OSG_INFO << 'Orthographic matrix after clamping '<<projection<<std::endl;\r\n } else {\r\n // OSG_INFO << 'Persepective matrix before clamping'<<projection<<std::endl;\r\n //std::cout << '_computed_znear'<<_computed_znear<<std::endl;\r\n //std::cout << '_computed_zfar'<<_computed_zfar<<std::endl;\r\n\r\n var zfarPushRatio = 1.02;\r\n var znearPullRatio = 0.98;\r\n\r\n //znearPullRatio = 0.99;\r\n\r\n desiredZnear = znear * znearPullRatio;\r\n desiredZfar = zfar * zfarPushRatio;\r\n\r\n // near plane clamping.\r\n var minNearPlane = zfar * nearFarRatio;\r\n if (desiredZnear < minNearPlane) {\r\n desiredZnear = minNearPlane;\r\n }\r\n\r\n // assign the clamped values back to the computed values.\r\n znear = desiredZnear;\r\n zfar = desiredZfar;\r\n\r\n var m22 = projection[10];\r\n var m32 = projection[14];\r\n var m23 = projection[11];\r\n var m33 = projection[15];\r\n var transNearPlane = (-desiredZnear * m22 + m32) / (-desiredZnear * m23 + m33);\r\n var transFarPlane = (-desiredZfar * m22 + m32) / (-desiredZfar * m23 + m33);\r\n\r\n var ratio = Math.abs(2.0 / (transNearPlane - transFarPlane));\r\n var center = -(transNearPlane + transFarPlane) / 2.0;\r\n\r\n var centerRatio = center * ratio;\r\n projection[2] = projection[2] * ratio + projection[3] * centerRatio;\r\n projection[6] = projection[6] * ratio + projection[7] * centerRatio;\r\n projection[10] = m22 * ratio + m23 * centerRatio;\r\n projection[14] = m32 * ratio + m33 * centerRatio;\r\n // same as\r\n // var matrix = [ 1.0, 0.0, 0.0, 0.0,\r\n // 0.0, 1.0, 0.0, 0.0,\r\n // 0.0, 0.0, ratio, 0.0,\r\n // 0.0, 0.0, center * ratio, 1.0\r\n // ];\r\n // mat4.mul( projection , matrix, projection );\r\n\r\n // OSG_INFO << 'Persepective matrix after clamping'<<projection<<std::endl;\r\n }\r\n if (resultNearFar !== undefined) {\r\n resultNearFar[0] = znear;\r\n resultNearFar[1] = zfar;\r\n }\r\n return true;\r\n },\r\n\r\n popCameraModelViewProjectionMatrix: function() {\r\n this.popModelViewMatrix();\r\n this.popProjectionMatrix();\r\n },\r\n\r\n pushCameraModelViewProjectionMatrix: function(camera, modelview, projection) {\r\n this.pushModelViewMatrix(modelview);\r\n this.pushProjectionMatrix(projection);\r\n },\r\n\r\n apply: function(node) {\r\n this.applyFunctionArray[node.nodeTypeID].call(this, node);\r\n },\r\n\r\n createOrReuseRenderLeaf: function() {\r\n return this._pooledLeaf.getOrCreateObject();\r\n },\r\n\r\n createOrReuseRenderStage: function(classInstance) {\r\n var type = !classInstance ? 'RenderStage' : classInstance.className();\r\n\r\n if (!this._pooledRenderStages[type]) {\r\n var classCtor = !classInstance ? RenderStage : classInstance.constructor;\r\n var createRenderStage = function() {\r\n return new classCtor(classInstance._app);\r\n };\r\n this._pooledRenderStages[type] = new PooledResource(createRenderStage);\r\n }\r\n return this._pooledRenderStages[type].getOrCreateObject().init();\r\n },\r\n\r\n // function call after the push state in the geometry apply function\r\n // the idea is to avoid heavy copy-paste for the rigGeometry apply\r\n // since the only difference is that we want to push an additional state\r\n // Maybe it will be useful when we'll add morph target geometry or something...\r\n postPushGeometry: function(cull, node) {\r\n var sourceGeometry;\r\n var geometryStateSetAnimation;\r\n\r\n if (node instanceof RigGeometry) {\r\n geometryStateSetAnimation = node.getStateSetAnimation();\r\n if (geometryStateSetAnimation) cull.pushStateSet(geometryStateSetAnimation);\r\n\r\n sourceGeometry = node.getSourceGeometry();\r\n\r\n if (sourceGeometry instanceof MorphGeometry) {\r\n geometryStateSetAnimation = sourceGeometry.getStateSetAnimation();\r\n if (geometryStateSetAnimation) cull.pushStateSet(geometryStateSetAnimation);\r\n }\r\n } else if (node instanceof MorphGeometry) {\r\n geometryStateSetAnimation = node.getStateSetAnimation();\r\n if (geometryStateSetAnimation) cull.pushStateSet(geometryStateSetAnimation);\r\n }\r\n },\r\n\r\n // same comment as above (postPushGeometry)\r\n prePopGeometry: function(cull, node) {\r\n if (node instanceof RigGeometry) {\r\n var sourceGeometry = node.getSourceGeometry();\r\n\r\n if (sourceGeometry instanceof MorphGeometry) {\r\n if (sourceGeometry.getStateSetAnimation()) cull.popStateSet();\r\n }\r\n\r\n if (node.getStateSetAnimation()) cull.popStateSet();\r\n } else if (node instanceof MorphGeometry && node.getStateSetAnimation()) {\r\n cull.popStateSet();\r\n }\r\n },\r\n\r\n pushLeaf: function(node, depth) {\r\n var leafs = this._currentStateGraph.getLeafs();\r\n if (!leafs.getLength()) {\r\n this._currentRenderBin.addStateGraph(this._currentStateGraph);\r\n }\r\n\r\n var leaf = this.createOrReuseRenderLeaf();\r\n\r\n leaf.init(\r\n this._currentStateGraph,\r\n node,\r\n this.getCurrentProjectionMatrix(),\r\n this.getCurrentViewMatrix(),\r\n this.getCurrentModelViewMatrix(),\r\n this.getCurrentModelMatrix(),\r\n depth\r\n );\r\n\r\n leafs.push(leaf);\r\n }\r\n })\r\n ),\r\n 'osg',\r\n 'CullVisitor'\r\n);\r\n\r\n// Camera cull visitor call\r\n// ANY CHANGE, any change : double check in rendere Camera code\r\n// for the first camera\r\nvar cameraApply = function(camera) {\r\n this._numCamera++;\r\n\r\n var stateset = camera.getStateSet();\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n var modelview = this._pooledMatrix.getOrCreateObject();\r\n var projection = this._pooledMatrix.getOrCreateObject();\r\n\r\n if (camera.getReferenceFrame() === TransformEnums.RELATIVE_RF) {\r\n var lastProjectionMatrix = this.getCurrentProjectionMatrix();\r\n mat4.mul(projection, lastProjectionMatrix, camera.getProjectionMatrix());\r\n\r\n var lastViewMatrix = this.getCurrentModelViewMatrix();\r\n mat4.mul(modelview, lastViewMatrix, camera.getViewMatrix());\r\n } else {\r\n // absolute\r\n mat4.copy(modelview, camera.getViewMatrix());\r\n mat4.copy(projection, camera.getProjectionMatrix());\r\n }\r\n\r\n // save current state of the camera\r\n var previousZnear = this._computedNear;\r\n var previousZfar = this._computedFar;\r\n\r\n var previousCullsettings = this._pooledCullSettings.getOrCreateObject();\r\n previousCullsettings.reset();\r\n previousCullsettings.setCullSettings(this);\r\n\r\n this._computedNear = Number.POSITIVE_INFINITY;\r\n this._computedFar = Number.NEGATIVE_INFINITY;\r\n //\r\n\r\n this.setCullSettings(camera);\r\n // global override\r\n // upon who setted the parameter\r\n // if it's cullvisitor\r\n // it's an OVERRIDER for enableFrustumCulling\r\n // allowing for global EnableFrustimCulling\r\n if (\r\n previousCullsettings.getSettingSourceOverrider() === this &&\r\n previousCullsettings.getEnableFrustumCulling()\r\n ) {\r\n this.setEnableFrustumCulling(true);\r\n }\r\n\r\n this.pushCameraModelViewProjectionMatrix(camera, modelview, projection);\r\n\r\n if (camera.getViewport()) {\r\n this.pushViewport(camera.getViewport());\r\n }\r\n\r\n // nested camera\r\n if (camera.getRenderOrder() === Camera.NESTED_RENDER) {\r\n this.handleCullCallbacksAndTraverse(camera);\r\n } else {\r\n var renderBin = this.getCurrentRenderBin();\r\n var previousStage = renderBin.getStage();\r\n\r\n // use render to texture stage\r\n var rtts = this.createOrReuseRenderStage(this._rootRenderStage);\r\n\r\n rtts.setCamera(camera);\r\n rtts.setClearDepth(camera.getClearDepth());\r\n rtts.setClearColor(camera.getClearColor());\r\n rtts.setClearMask(camera.getClearMask());\r\n\r\n var viewport = camera.getViewport() ? camera.getViewport() : previousStage.getViewport();\r\n var scissor = camera.getScissor() ? camera.getScissor() : previousStage.getScissor();\r\n rtts.setViewport(viewport);\r\n rtts.setScissor(scissor);\r\n\r\n // skip positional state for now\r\n // ...\r\n\r\n this.setCurrentRenderBin(rtts);\r\n\r\n this.handleCullCallbacksAndTraverse(camera);\r\n\r\n this.setCurrentRenderBin(renderBin);\r\n\r\n if (camera.getRenderOrder() === Camera.PRE_RENDER) {\r\n this.getCurrentRenderBin()\r\n .getStage()\r\n .addPreRenderStage(rtts, camera.renderOrderNum);\r\n } else {\r\n this.getCurrentRenderBin()\r\n .getStage()\r\n .addPostRenderStage(rtts, camera.renderOrderNum);\r\n }\r\n }\r\n\r\n this.popCameraModelViewProjectionMatrix(camera);\r\n\r\n if (camera.getViewport()) {\r\n this.popViewport();\r\n }\r\n\r\n // restore previous state of the camera\r\n this.setCullSettings(previousCullsettings);\r\n this._computedNear = previousZnear;\r\n this._computedFar = previousZfar;\r\n\r\n if (stateset) this.popStateSet();\r\n};\r\n\r\nvar matrixTransformApply = function(node) {\r\n this._numMatrixTransform++;\r\n\r\n // Camera and lights must enlarge node parent bounding boxes for this not to cull\r\n if (this.isCulled(node, this.nodePath)) {\r\n return;\r\n }\r\n // push the culling mode.\r\n this.pushCurrentMask();\r\n\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n var lastMatrixStack = this.getCurrentModelViewMatrix();\r\n mat4.copy(matrix, lastMatrixStack);\r\n node.computeLocalToWorldMatrix(matrix);\r\n this.pushModelViewMatrix(matrix);\r\n\r\n var stateset = node.getStateSet();\r\n\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n this.handleCullCallbacksAndTraverse(node);\r\n\r\n if (stateset) this.popStateSet();\r\n\r\n this.popModelViewMatrix();\r\n\r\n // pop the culling mode.\r\n this.popCurrentMask();\r\n};\r\n\r\nvar projectionApply = function(node) {\r\n this._numProjection++;\r\n\r\n var lastMatrixStack = this.getCurrentProjectionMatrix();\r\n var matrix = this._pooledMatrix.getOrCreateObject();\r\n mat4.mul(matrix, lastMatrixStack, node.getProjectionMatrix());\r\n this.pushProjectionMatrix(matrix);\r\n\r\n var stateset = node.getStateSet();\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n this.handleCullCallbacksAndTraverse(node);\r\n\r\n if (stateset) this.popStateSet();\r\n\r\n this.popProjectionMatrix();\r\n};\r\n\r\n// here it's treated as a group node for culling\r\n// as there's isn't any in osgjs\r\n// so frustumCulling is done here\r\nvar nodeApply = function(node) {\r\n this._numNode++;\r\n\r\n // Camera and lights must enlarge node parent bounding boxes for this not to cull\r\n if (this.isCulled(node, this.nodePath)) {\r\n return;\r\n }\r\n\r\n // push the culling mode.\r\n this.pushCurrentMask();\r\n\r\n var stateset = node.getStateSet();\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n this.handleCullCallbacksAndTraverse(node);\r\n\r\n if (stateset) this.popStateSet();\r\n\r\n // pop the culling mode.\r\n this.popCurrentMask();\r\n};\r\n\r\nvar lightSourceApply = function(node) {\r\n this._numLightSource++;\r\n\r\n var stateset = node.getStateSet();\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n var light = node.getLight();\r\n if (light) {\r\n if (node.getReferenceFrame() === TransformEnums.RELATIVE_RF)\r\n this.addPositionedAttribute(this.getCurrentModelViewMatrix(), light);\r\n else this.addPositionedAttribute(null, light);\r\n }\r\n\r\n this.handleCullCallbacksAndTraverse(node);\r\n\r\n if (stateset) this.popStateSet();\r\n};\r\n\r\nvar tempVec = vec3.create();\r\nvar loggedOnce = false;\r\nvar geometryApply = function(node) {\r\n this._numGeometry++;\r\n\r\n var modelview = this.getCurrentModelViewMatrix();\r\n var bb = node.getBoundingBox();\r\n if (this._computeNearFar && bb.valid()) {\r\n if (!this.updateCalculatedNearFar(modelview, node)) {\r\n return;\r\n }\r\n }\r\n\r\n // using modelview is not a pb because geometry\r\n // is a leaf node, else traversing the graph would be an\r\n // issue because we use modelview after\r\n var ccb = node.getCullCallback();\r\n if (ccb && !ccb.cull(node, this)) return;\r\n\r\n var stateset = node.getStateSet();\r\n if (stateset) this.pushStateSet(stateset);\r\n\r\n this.postPushGeometry(this, node);\r\n\r\n var depth = 0;\r\n if (bb.valid()) {\r\n depth = this.distance(bb.center(tempVec), modelview);\r\n }\r\n if (osgMath.isNaN(depth)) {\r\n if (!loggedOnce) {\r\n notify.warn('warning geometry has a NaN depth, ' + modelview + ' center ' + tempVec);\r\n loggedOnce = true;\r\n }\r\n } else {\r\n this.pushLeaf(node, depth);\r\n }\r\n\r\n this.prePopGeometry(this, node);\r\n if (stateset) this.popStateSet();\r\n};\r\n\r\ncullVisitorHelper.registerApplyFunction(Node.nodeTypeID, nodeApply);\r\ncullVisitorHelper.registerApplyFunction(Switch.nodeTypeID, nodeApply);\r\ncullVisitorHelper.registerApplyFunction(PagedLOD.nodeTypeID, nodeApply);\r\ncullVisitorHelper.registerApplyFunction(Camera.nodeTypeID, cameraApply);\r\ncullVisitorHelper.registerApplyFunction(MatrixTransform.nodeTypeID, matrixTransformApply);\r\ncullVisitorHelper.registerApplyFunction(Projection.nodeTypeID, projectionApply);\r\ncullVisitorHelper.registerApplyFunction(Geometry.nodeTypeID, geometryApply);\r\ncullVisitorHelper.registerApplyFunction(Skeleton.nodeTypeID, matrixTransformApply);\r\ncullVisitorHelper.registerApplyFunction(Bone.nodeTypeID, matrixTransformApply);\r\ncullVisitorHelper.registerApplyFunction(AutoTransform.nodeTypeID, matrixTransformApply);\r\ncullVisitorHelper.registerApplyFunction(Lod.nodeTypeID, nodeApply);\r\ncullVisitorHelper.registerApplyFunction(LightSource.nodeTypeID, lightSourceApply);\r\ncullVisitorHelper.registerApplyFunction(RigGeometry.nodeTypeID, geometryApply);\r\ncullVisitorHelper.registerApplyFunction(MorphGeometry.nodeTypeID, geometryApply);\r\n\r\nexport default CullVisitor;","import utils from '../osg/utils';\r\nimport notify from '../osg/notify';\r\nimport Node from './node/Node';\r\n\r\n/*\r\n\r\nNodes are automatically created when parsing a glsl file\r\n\r\n=== function name ===\r\n* First letter of your glsl function will be converted to upperCase\r\n* You can override the function name with NODE_NAME:myNewName\r\n\r\n=== variable name ===\r\n* The output variable is always named result, other variable names are unchanged\r\n* You can override a variable name by writing glslName:jsName\r\n\r\n=== overloading matching ===\r\n* Overloading is supported, it will select the best matching depending of the js inputs/outputs\r\n* For now you need to put the overload functions in the same glsl file\r\n* Overloading will prioritize variable name matching first, then output types, and finally input types\r\n* When there is a mismatch in types, it'll downcast your input (e.g: by transforming your vec4 into a vec3)\r\n\r\n=== misc ===\r\n* Shader nodes have a function addExtensions if you want to enable extensions\r\n* Shader nodes have a function addDefines if you want to provides defines\r\n\r\n* /!\\ hack: Extensions in pragma is partially supported: for now only by writing DERIVATIVES:enable after the pragma will work\r\n\r\n* /!\\ hack: you can declare functions as defines too but it will only perform name checking\r\n No type checking/downcasting and no in/out validation\r\n\r\n* /!\\ hack: Optional argument are handled with define that have the structure : OPT_ARG_myOptVar\r\n The variable will be named myOptVar in that example\r\n No type checking/downcasting and no in/out validation for the optional variable\r\n\r\n\r\nTry to stick with the simple example if possible\r\n\r\n============================\r\n====== SIMPLE EXAMPLE ======\r\n============================\r\n\r\n---- glsl ----\r\n#pragma DECLARE_FUNCTION\r\nvec3 myFunc(const in float myVarIn, out float myVarOut) {\r\n // do stuffs\r\n}\r\n\r\n---- js ----\r\nthis.getNode('MyFunc')\r\n .inputs({\r\n myVarIn: var1\r\n })\r\n .outputs({\r\n result: var2,\r\n myVarOut: var3\r\n });\r\n\r\n============================\r\n====== COMPLEX EXAMPLE =====\r\n============================\r\n\r\n---- glsl ----\r\n#pragma DECLARE_FUNCTION NODE_NAME:myFuncTiti result:resOut myVarIn:totoIn optVariable:optVar DERIVATIVES:enable\r\nvec3 myFunc(const in float myVarIn, out float myVarOut, OPT_ARG_optVariable) {\r\n // do stuffs\r\n}\r\n\r\n---- js ----\r\nthis.getNode('myFuncTiti')\r\n .inputs({\r\n totoIn: var1,\r\n optVar: var2\r\n })\r\n .outputs({\r\n resOut: var4,\r\n myVarOut: var5\r\n })\r\n .addDefines(['#define TOTO']);\r\n\r\n*/\r\n\r\nvar sprintf = function(string, args) {\r\n if (!string || !args) {\r\n return '';\r\n }\r\n\r\n var arg;\r\n\r\n for (var index in args) {\r\n arg = args[index];\r\n\r\n if (arg === undefined) {\r\n continue;\r\n }\r\n\r\n if (arg.getVariable) {\r\n arg = arg.getVariable();\r\n }\r\n string = string.replace('%s', arg);\r\n }\r\n return string;\r\n};\r\n\r\nvar checkVariableType = function(vars, optionalPrefix) {\r\n var inputs = vars;\r\n var varsList = [];\r\n var prefix = optionalPrefix;\r\n if (optionalPrefix === undefined) {\r\n prefix = '';\r\n }\r\n\r\n for (var i = 0, l = inputs.length; i < l; i++) {\r\n var variable = inputs[i];\r\n var output;\r\n\r\n if (variable === undefined) {\r\n output = 'undefined';\r\n } else if (typeof variable === 'string') {\r\n output = variable;\r\n } else if (variable.getType) {\r\n output = variable.getType() + ' ' + variable.getVariable();\r\n } else {\r\n output = variable.getVariable();\r\n }\r\n\r\n varsList.push(prefix + output);\r\n }\r\n\r\n return varsList;\r\n};\r\n\r\nvar callFunction = function(funcName, output, inputs) {\r\n var osgShader = require('./osgShader').default;\r\n\r\n var debug = [];\r\n var callString = '';\r\n\r\n // debug\r\n if (osgShader.debugShaderNode) {\r\n debug.push('\\n// output');\r\n Array.prototype.push.apply(debug, checkVariableType([output], '// '));\r\n }\r\n\r\n if (output) {\r\n callString = (output.getVariable ? output.getVariable() : output) + ' = ';\r\n }\r\n\r\n callString = callString + funcName + '( ';\r\n\r\n if (inputs && inputs.length > 0) {\r\n // debug\r\n if (osgShader.debugShaderNode) {\r\n debug.push('// inputs');\r\n Array.prototype.push.apply(debug, checkVariableType(inputs, '// '));\r\n }\r\n\r\n for (var i = 0, l = inputs.length; i < l; i++) {\r\n callString += inputs[i].getVariable ? inputs[i].getVariable() : inputs[i];\r\n if (i !== l - 1) callString += ', ';\r\n }\r\n }\r\n\r\n callString += ' );\\n';\r\n\r\n if (osgShader.debugShaderNode) {\r\n return debug.join('\\n') + '\\n' + callString;\r\n }\r\n\r\n return callString;\r\n};\r\n\r\nvar extractPragmaArgs = function(option) {\r\n // extract glslVar:jsVar pattern\r\n // res: [\"DERIVATIVES:enable\", \"glslVarIn:jsVarIn\", \"glslVarOut:jsVarOut\"]\r\n var res = option.match(/([^\\s]+):([^\\s]+)/g);\r\n\r\n var map = {};\r\n if (!res) return map;\r\n\r\n for (var i = 0; i < res.length; ++i) {\r\n var split = res[i].split(':');\r\n map[split[0]] = split[1];\r\n }\r\n\r\n return map;\r\n};\r\n\r\nvar extractSignature = function(option, signature) {\r\n var openParen = signature.indexOf('(');\r\n var closeParen = signature.indexOf(')');\r\n\r\n // preSignature: \"vec3 myFunction\"\r\n var preSignature = signature.substring(0, openParen);\r\n preSignature = preSignature\r\n .replace(/[\\r\\n|\\r|\\n]/g, '')\r\n .trim()\r\n .replace(/\\s+/g, ' ');\r\n\r\n var splitPre = preSignature.split(/\\s/);\r\n var firstWord = splitPre[0];\r\n var nameFunc = splitPre[1];\r\n\r\n // override variable names\r\n var pragmaArgs = extractPragmaArgs(option);\r\n var returnName = pragmaArgs.result || 'result';\r\n\r\n // override node name\r\n var nodeName = pragmaArgs.NODE_NAME;\r\n if (!nodeName) {\r\n nodeName = nameFunc[0].toUpperCase() + nameFunc.substring(1);\r\n }\r\n\r\n // extensions\r\n var extensions = [];\r\n if (pragmaArgs.DERIVATIVES) {\r\n extensions.push('#extension GL_OES_standard_derivatives : ' + pragmaArgs.DERIVATIVES);\r\n }\r\n\r\n var outputs = [];\r\n var returnVariable;\r\n var isDefine = firstWord === '#define';\r\n // return variable\r\n if (firstWord !== 'void') {\r\n returnVariable = {\r\n name: returnName,\r\n type: !isDefine && firstWord\r\n };\r\n outputs.push(returnVariable);\r\n }\r\n\r\n // postSignature: \"const in vec3 varIn, const out float varOut\"\r\n var postSignature = signature.substring(openParen + 1, closeParen);\r\n postSignature = postSignature.replace(/[\\r\\n|\\r|\\n]/g, '');\r\n\r\n // array of arguments\r\n var argumentList = postSignature.split(/OPT_ARG_|,/);\r\n var hasOptionalArgs = postSignature.indexOf('OPT_ARG_') !== -1;\r\n\r\n var inputs = [];\r\n var orderedArgs = [];\r\n for (var i = 0; i < argumentList.length; ++i) {\r\n var argi = argumentList[i];\r\n if (!argi) continue;\r\n\r\n // cleanArg: \"const in vec3 varIn\"\r\n var cleanArg = argi\r\n .trim()\r\n .replace(/\\s+/g, ' ')\r\n .split('[')[0];\r\n var splits = cleanArg.split(/\\s/);\r\n var nbSplits = splits.length;\r\n\r\n var isOutput = nbSplits >= 3 && splits[nbSplits - 3].indexOf('out') !== -1;\r\n var glslName = splits[nbSplits - 1];\r\n var res = {\r\n isOutput: isOutput,\r\n type: splits[nbSplits - 2],\r\n name: pragmaArgs[glslName] || glslName,\r\n optional: hasOptionalArgs && postSignature.indexOf('OPT_ARG_' + glslName) !== -1\r\n };\r\n\r\n orderedArgs.push(res);\r\n if (res.optional) continue;\r\n\r\n if (isOutput) outputs.push(res);\r\n else inputs.push(res);\r\n }\r\n\r\n return {\r\n nodeName: nodeName,\r\n functionName: nameFunc,\r\n signature: {\r\n returnVariable: returnVariable,\r\n orderedArgs: orderedArgs,\r\n outputs: outputs,\r\n inputs: inputs,\r\n extensions: extensions\r\n }\r\n };\r\n};\r\n\r\nvar createNode = function(res, fileName) {\r\n var NodeCustom = function() {\r\n Node.call(this);\r\n this._defines = [];\r\n this._extensions = [];\r\n this._missingArgs = false;\r\n };\r\n\r\n utils.createPrototypeObject(\r\n NodeCustom,\r\n utils.objectInherit(Node.prototype, {\r\n type: res.nodeName,\r\n signatures: [res.signature],\r\n globalDeclare: '#pragma include \"' + fileName + '\"',\r\n\r\n checkInputsOutputs: function() {},\r\n\r\n globalFunctionDeclaration: function() {\r\n return this.globalDeclare;\r\n },\r\n\r\n addExtensions: function(exts) {\r\n this._extensions.push.apply(this._extensions, exts);\r\n return this;\r\n },\r\n\r\n getExtensions: function() {\r\n this.getOrCreateSignature();\r\n return this._extensions;\r\n },\r\n\r\n addDefines: function(defines) {\r\n this._defines.push.apply(this._defines, defines);\r\n return this;\r\n },\r\n\r\n getDefines: function() {\r\n return this._defines;\r\n },\r\n\r\n _validateSameVariables: function(glslArray, jsObj) {\r\n var nbGlsl = glslArray.length;\r\n for (var i = 0; i < nbGlsl; ++i) {\r\n if (!jsObj[glslArray[i].name]) return false;\r\n }\r\n return glslArray.length === Object.keys(jsObj).length;\r\n },\r\n\r\n _validateSameType: function(glslArray, jsObj) {\r\n var nbGlsl = glslArray.length;\r\n for (var i = 0; i < nbGlsl; ++i) {\r\n var jsVar = jsObj[glslArray[i].name];\r\n if (jsVar.getType() !== glslArray[i].type) return false;\r\n }\r\n return true;\r\n },\r\n\r\n _getSignatureBestMatch: function() {\r\n if (this.signatures.length === 1) return this.signatures[0];\r\n\r\n var matchNames = [];\r\n var matchOutput = [];\r\n var matchInput = [];\r\n var nbSignatures = this.signatures.length;\r\n for (var i = 0; i < nbSignatures; ++i) {\r\n var sig = this.signatures[i];\r\n if (!this._validateSameVariables(sig.outputs, this._outputs)) continue;\r\n if (!this._validateSameVariables(sig.inputs, this._inputs)) continue;\r\n matchNames.push(sig);\r\n\r\n if (!this._validateSameType(sig.outputs, this._outputs)) continue;\r\n matchOutput.push(sig);\r\n\r\n if (!this._validateSameType(sig.inputs, this._inputs)) continue;\r\n matchInput.push(sig);\r\n }\r\n\r\n if (!matchNames.length) return this.signatures[0];\r\n if (matchNames.length === 1 || !matchOutput.length) return matchNames[0];\r\n if (matchOutput.length === 1 || !matchInput.length) return matchOutput[0];\r\n return matchInput[0];\r\n },\r\n\r\n getOrCreateSignature: function() {\r\n if (!this._signature) {\r\n this._signature = this._getSignatureBestMatch();\r\n this.addExtensions(this._signature.extensions);\r\n }\r\n return this._signature;\r\n },\r\n\r\n _typeDownCast: function(glslArg) {\r\n var jsArg;\r\n if (glslArg.optional) {\r\n jsArg = this._inputs[glslArg.name] || this._outputs[glslArg.name];\r\n if (!jsArg) return;\r\n } else {\r\n jsArg = glslArg.isOutput\r\n ? this._outputs[glslArg.name]\r\n : this._inputs[glslArg.name];\r\n }\r\n\r\n if (!jsArg) {\r\n var typeIn = glslArg.isOutput ? 'output' : 'input';\r\n notify.error(\r\n 'missing ' + typeIn + ' ' + glslArg.name + ' on NodeCustom ' + res.nodeName\r\n );\r\n this._missingArgs = true;\r\n return;\r\n }\r\n\r\n var realType = jsArg.getType();\r\n var validType = glslArg.type;\r\n\r\n if (!validType || validType === realType) return jsArg;\r\n if (validType === 'vec3') return jsArg.getVariable() + '.rgb';\r\n if (validType === 'vec2') return jsArg.getVariable() + '.rg';\r\n if (validType === 'float') return jsArg.getVariable() + '.r';\r\n return jsArg;\r\n },\r\n\r\n computeShader: function() {\r\n var signature = this.getOrCreateSignature();\r\n\r\n var ret = signature.returnVariable && signature.returnVariable.name;\r\n var returnOut = ret ? this._outputs[ret] : undefined;\r\n if (ret && !returnOut) {\r\n notify.error('missing output ' + ret + ' on NodeCustom ' + res.nodeName);\r\n this._missingArgs = true;\r\n }\r\n\r\n var orderedArgs = [];\r\n for (var i = 0; i < signature.orderedArgs.length; ++i) {\r\n var input = this._typeDownCast(signature.orderedArgs[i]);\r\n if (input) orderedArgs.push(input);\r\n }\r\n\r\n if (this._missingArgs) return '';\r\n return callFunction(res.functionName, returnOut, orderedArgs);\r\n }\r\n }),\r\n 'osgShader',\r\n res.nodeName\r\n );\r\n\r\n return NodeCustom;\r\n};\r\n\r\nvar shaderNodeClassGlobal = {};\r\n\r\nvar extractFunctions = function(shaderLib, fileName) {\r\n var signatures = shaderLib[fileName].split(/#pragma DECLARE_FUNCTION(.*)[\\r\\n|\\r|\\n]/);\r\n var nbSignatures = (signatures.length - 1) / 2;\r\n\r\n var shaderNodeClassLocal = {};\r\n for (var i = 0; i < nbSignatures; ++i) {\r\n var result = extractSignature(signatures[i * 2 + 1], signatures[i * 2 + 2]);\r\n var nodeName = result.nodeName;\r\n var shaderNode = shaderNodeClassLocal[nodeName];\r\n if (shaderNode) {\r\n shaderNode.prototype.signatures.push(result.signature);\r\n continue;\r\n }\r\n // new shadernode in this local shaderLib\r\n shaderNode = shaderNodeClassGlobal[nodeName];\r\n if (shaderNode) {\r\n // replace shader node globally\r\n shaderNode.prototype.signatures = [result.signature];\r\n shaderNode.prototype.globalDeclare = '#pragma include \"' + fileName + '\"';\r\n } else {\r\n shaderNode = createNode(result, fileName);\r\n }\r\n shaderNodeClassLocal[nodeName] = shaderNode;\r\n shaderNodeClassGlobal[nodeName] = shaderNode;\r\n }\r\n\r\n return shaderNodeClassLocal;\r\n};\r\n\r\nexport default {\r\n callFunction: callFunction,\r\n checkVariableType: checkVariableType,\r\n sprintf: sprintf,\r\n extractFunctions: extractFunctions\r\n};\r\n","import utils from '../osg/utils';\r\nimport { vec3 } from '../osg/glMatrix';\r\nimport { mat4 } from '../osg/glMatrix';\r\nimport Intersector from '../osgUtil/Intersector';\r\nimport LineSegmentIntersectFunctor from '../osgUtil/LineSegmentIntersectFunctor';\r\n\r\nvar LineSegmentIntersector = function() {\r\n Intersector.call(this);\r\n\r\n this._start = vec3.create();\r\n this._iStart = vec3.create();\r\n\r\n this._end = vec3.create();\r\n this._iEnd = vec3.create();\r\n\r\n // only used for lines and points\r\n this._threshold = 0.0;\r\n this._iThreshold = 0.0;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n LineSegmentIntersector,\r\n utils.objectInherit(Intersector.prototype, {\r\n set: function(start, end, threshold) {\r\n vec3.copy(this._start, start);\r\n vec3.copy(this._iStart, start);\r\n vec3.copy(this._end, end);\r\n vec3.copy(this._iEnd, end);\r\n\r\n if (threshold !== undefined) {\r\n this._threshold = this._iThreshold = threshold;\r\n }\r\n },\r\n\r\n setStart: function(start) {\r\n vec3.copy(this._start, start);\r\n vec3.copy(this._iStart, start);\r\n },\r\n\r\n setEnd: function(end) {\r\n vec3.copy(this._end, end);\r\n vec3.copy(this._iEnd, end);\r\n },\r\n\r\n intersectNode: function(node) {\r\n // TODO implement intersectBoundingBox?\r\n return this.intersectBoundingSphere(node.getBoundingSphere());\r\n },\r\n\r\n // Intersection Segment/Sphere\r\n intersectBoundingSphere: (function() {\r\n var sm = vec3.create();\r\n var se = vec3.create();\r\n return function(bsphere) {\r\n // test for _start inside the bounding sphere\r\n if (!bsphere.valid()) return false;\r\n vec3.sub(sm, this._iStart, bsphere.center());\r\n var c = vec3.sqrLen(sm) - bsphere.radius2();\r\n if (c <= 0.0) {\r\n return true;\r\n }\r\n // solve quadratic equation\r\n vec3.sub(se, this._iEnd, this._iStart);\r\n var a = vec3.sqrLen(se);\r\n var b = vec3.dot(sm, se) * 2.0;\r\n var d = b * b - 4.0 * a * c;\r\n // no intersections if d<0\r\n if (d < 0.0) {\r\n return false;\r\n }\r\n // compute two solutions of quadratic equation\r\n d = Math.sqrt(d);\r\n var div = 0.5 / a;\r\n var r1 = (-b - d) * div;\r\n var r2 = (-b + d) * div;\r\n\r\n // return false if both intersections are before the ray start\r\n if (r1 <= 0.0 && r2 <= 0.0) {\r\n return false;\r\n }\r\n\r\n if (r1 > 1.0 && r2 > 1.0) {\r\n return false;\r\n }\r\n return true;\r\n };\r\n })(),\r\n\r\n intersect: (function() {\r\n var functor = new LineSegmentIntersectFunctor();\r\n\r\n return function(iv, node) {\r\n functor.setGeometry(node);\r\n functor.setIntersectionVisitor(iv);\r\n functor.setIntersector(this);\r\n\r\n functor.set(this._iStart, this._iEnd, this._iThreshold);\r\n\r\n var kdtree = node.getShape();\r\n if (kdtree) {\r\n kdtree.intersectLineSegment(\r\n functor,\r\n kdtree.getNodes()[0],\r\n this._iStart,\r\n this._iEnd,\r\n this._iThreshold\r\n );\r\n return;\r\n } else {\r\n // handle rig transformed vertices\r\n if (node.computeTransformedVertices) {\r\n functor.setVertices(node.computeTransformedVertices());\r\n }\r\n\r\n functor.apply(node);\r\n }\r\n\r\n functor.reset();\r\n };\r\n })(),\r\n\r\n setCurrentTransformation: function(matrix) {\r\n mat4.invert(matrix, matrix);\r\n\r\n if (this._threshold > 0.0) {\r\n var tmp = this._iStart;\r\n mat4.getScale(tmp, matrix);\r\n var x = tmp[0];\r\n var y = tmp[1];\r\n var z = tmp[2];\r\n this._iThreshold = this._threshold * (x > y ? (x > z ? x : z) : y > z ? y : z);\r\n }\r\n vec3.transformMat4(this._iStart, this._start, matrix);\r\n vec3.transformMat4(this._iEnd, this._end, matrix);\r\n }\r\n }),\r\n 'osgUtil',\r\n 'LineSegmentIntersector'\r\n);\r\n\r\nexport default LineSegmentIntersector;\r\n","import utils from '../osg/utils';\r\nimport MatrixTransform from '../osg/MatrixTransform';\r\nimport UpdateSkeleton from './UpdateSkeleton';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport UpdateMatrixTransform from './UpdateMatrixTransform';\r\nimport Bone from './Bone';\r\n\r\nvar ResetRestPoseVisitor = function() {\r\n NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ResetRestPoseVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getTypeID() === Bone.getTypeID()) {\r\n var cb = node.getUpdateCallback();\r\n if (cb instanceof UpdateMatrixTransform) {\r\n var stackedTransforms = cb._stackedTransforms;\r\n for (var st = 0, l = stackedTransforms.length; st < l; st++) {\r\n var stackedTransform = stackedTransforms[st];\r\n stackedTransform.resetToDefaultValue();\r\n }\r\n cb.computeChannels();\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'ResetRestPoseVisitor'\r\n);\r\n\r\nvar resetter = new ResetRestPoseVisitor();\r\n\r\nvar Skeleton = function() {\r\n MatrixTransform.call(this);\r\n};\r\n\r\nutils.createPrototypeNode(\r\n Skeleton,\r\n utils.objectInherit(MatrixTransform.prototype, {\r\n setDefaultUpdateCallback: function() {\r\n this.addUpdateCallback(new UpdateSkeleton());\r\n },\r\n\r\n setRestPose: function() {\r\n this.accept(resetter);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'Skeleton'\r\n);\r\n\r\nexport default Skeleton;\r\n","import utils from '../osg/utils';\r\nimport Bone from './Bone';\r\nimport NodeVisitor from '../osg/NodeVisitor';\r\nimport notify from '../osg/notify';\r\nimport Object from '../osg/Object';\r\n\r\n/**\r\n * ValidateSkeletonVisitor\r\n * @class ValidateSkeletonVisitor\r\n */\r\nvar ValidateSkeletonVisitor = function() {\r\n NodeVisitor.call(this);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n ValidateSkeletonVisitor,\r\n utils.objectInherit(NodeVisitor.prototype, {\r\n apply: function(node) {\r\n if (node.getTypeID() !== Bone.getTypeID()) {\r\n return;\r\n }\r\n var foundNonBone = false;\r\n\r\n var children = node.getChildren();\r\n for (var i = 0, l = node.getChildren().length; i < l; i++) {\r\n var child = children[i];\r\n if (child.getTypeID() === Bone.getTypeID()) {\r\n if (foundNonBone) {\r\n notify.warn(\r\n 'Warning: a Bone was found after a non-Bone child ' +\r\n 'within a Skeleton. Children of a Bone must be ordered ' +\r\n 'with all child Bones first for correct update order.'\r\n );\r\n //this.traversalMode = NodeVisitor.TRAVERSE_NONE;\r\n return;\r\n }\r\n } else {\r\n foundNonBone = true;\r\n }\r\n }\r\n this.traverse(node);\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'ValidateSkeletonVisitor'\r\n);\r\n\r\nvar compareBone = function(x, y) {\r\n var a = x instanceof Bone ? 0 : 1;\r\n var b = y instanceof Bone ? 0 : 1;\r\n\r\n return a - b;\r\n};\r\n\r\n/**\r\n * UpdateSkeleton\r\n * @class UpdateSkeleton\r\n */\r\nvar UpdateSkeleton = function() {\r\n this._needValidate = true;\r\n};\r\n\r\nutils.createPrototypeObject(\r\n UpdateSkeleton,\r\n utils.objectInherit(Object.prototype, {\r\n needToValidate: function() {\r\n return this._needValidate;\r\n },\r\n\r\n update: function(node, nv) {\r\n if (this._needValidate && nv.getVisitorType() === NodeVisitor.UPDATE_VISITOR) {\r\n if (node.className && node.className() === 'Skeleton') {\r\n var validateSkeletonVisitor = new ValidateSkeletonVisitor();\r\n var children = node.getChildren();\r\n for (var i = 0, l = children.length; i < l; i++) {\r\n var child = children[i];\r\n child.accept(validateSkeletonVisitor);\r\n }\r\n\r\n //Re-order skeleton children to force correct bones update, we should put bones first\r\n children.sort(compareBone);\r\n\r\n this._needValidate = false;\r\n }\r\n }\r\n return true;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'UpdateSkeleton'\r\n);\r\n\r\nexport default UpdateSkeleton;\r\n","var applyFunctionArray = [];\r\n\r\nvar registerApplyFunction = function(type, apply) {\r\n applyFunctionArray[type] = apply;\r\n};\r\n\r\nvar getApplyFunction = function(type) {\r\n return applyFunctionArray[type];\r\n};\r\n\r\nexport default {\r\n applyFunctionArray: applyFunctionArray,\r\n registerApplyFunction: registerApplyFunction,\r\n getApplyFunction: getApplyFunction\r\n};\r\n","import utils from '../osg/utils';\r\nimport BufferArray from '../osg/BufferArray';\r\nimport RigGeometry from './RigGeometry';\r\nimport AnimationUpdateCallback from './AnimationUpdateCallback';\r\nimport Target from './target';\r\nimport MorphGeometry from './MorphGeometry';\r\n\r\nvar UpdateMorph = function() {\r\n AnimationUpdateCallback.call(this);\r\n\r\n this._targets = []; // float target\r\n this._targetNames = []; // names of targets\r\n this._morphs = []; // the update morph can update several morphs\r\n\r\n this._weights = new Float32Array(MorphGeometry.MAX_MORPH_GPU);\r\n // stuffs to handles > max morph gpu targets\r\n this._indexMap = new Uint32Array(MorphGeometry.MAX_MORPH_GPU); // we map VA to the last gpu morphed VA targets\r\n this._gpuMorphed = []; // size of this._targets, for each target a bool states if it's gpu morphed or not\r\n\r\n this._maxMorphGPU = -1;\r\n};\r\n\r\n// for sorting\r\nvar funcWeights = function(a, b) {\r\n return Math.abs(b.value) - Math.abs(a.value);\r\n};\r\n\r\nutils.createPrototypeObject(\r\n UpdateMorph,\r\n utils.objectInherit(AnimationUpdateCallback.prototype, {\r\n _initNode: function(geom) {\r\n var morph;\r\n if (geom instanceof MorphGeometry) {\r\n morph = geom;\r\n } else if (\r\n geom instanceof RigGeometry &&\r\n geom.getSourceGeometry() instanceof MorphGeometry\r\n ) {\r\n morph = geom.getSourceGeometry();\r\n }\r\n\r\n if (!morph) return;\r\n\r\n if (morph.getName() === this.getName()) {\r\n if (!morph.isInitialized()) morph.init();\r\n\r\n this._morphs.push(morph);\r\n this._maxMorphGPU = Math.min(this._maxMorphGPU, morph.getMaximumPossibleMorphGPU());\r\n }\r\n },\r\n\r\n init: function(node) {\r\n this._maxMorphGPU = MorphGeometry.MAX_MORPH_GPU;\r\n this._morphs.length = 0;\r\n\r\n //Find the morph geometry & init it\r\n var children = node.getChildren();\r\n if (!children.length) {\r\n this._initNode(node);\r\n return;\r\n }\r\n\r\n for (var i = 0, l = children.length; i < l; i++) {\r\n this._initNode(children[i]);\r\n }\r\n },\r\n\r\n isInitialized: function() {\r\n var morphs = this._morphs;\r\n var nbMorphs = morphs.length;\r\n if (!nbMorphs) return false;\r\n\r\n for (var i = 0; i < nbMorphs; ++i) {\r\n if (!morphs[i].isInitialized()) return false;\r\n }\r\n\r\n return true;\r\n },\r\n\r\n getNumTarget: function() {\r\n return this._targets.length;\r\n },\r\n\r\n getTarget: function(index) {\r\n return this._targets[index];\r\n },\r\n\r\n getTargetName: function(index) {\r\n return this._targetNames[index];\r\n },\r\n\r\n addTarget: function(name, index) {\r\n this._targets[index] = Target.createFloatTarget(0);\r\n this._targetNames[index] = name;\r\n },\r\n\r\n _remapBufferArrays: function() {\r\n // basically, this function remaps all the active morphed VA to the 4th first morphTargets VA\r\n var indexMap = this._indexMap;\r\n var morphs = this._morphs;\r\n for (var i = 0; i < this._maxMorphGPU; ++i) {\r\n var index = indexMap[i];\r\n var strI = '_' + i;\r\n var strIndex = '_' + index;\r\n\r\n for (var j = 0, nbMorphs = morphs.length; j < nbMorphs; ++j) {\r\n var morph = morphs[j];\r\n var vAttrs = morph.getVertexAttributeList();\r\n var morphNames = morph.getMorphTargetNames();\r\n for (var k = 0, nbNames = morphNames.length; k < nbNames; ++k) {\r\n var attName = morphNames[k];\r\n vAttrs[attName + strI].setBufferArray(\r\n vAttrs[attName + strIndex].getInitialBufferArray()\r\n );\r\n }\r\n }\r\n }\r\n },\r\n\r\n _mergeExtraMorphTarget: function(attrs, attName, extraWeightSum) {\r\n var i = 0;\r\n // ignore the gpu morphed\r\n var gpuMorphed = this._gpuMorphed;\r\n var vAttr = attrs[attName];\r\n var vertexLen = vAttr.getElements().length;\r\n var nbVertex = vertexLen / vAttr.getItemSize();\r\n var itemSize = vAttr.getItemSize();\r\n\r\n vAttr._cpuMorph =\r\n vAttr._cpuMorph ||\r\n new BufferArray(BufferArray.ARRAY_BUFFER, new Float32Array(vertexLen), itemSize);\r\n var morphExtraTargets = vAttr._cpuMorph.getElements();\r\n for (i = 0; i < vertexLen; ++i) {\r\n morphExtraTargets[i] = 0.0;\r\n }\r\n\r\n var targets = this._targets;\r\n for (var j = 0, nb = targets.length; j < nb; ++j) {\r\n // ignore gpu morphed targets\r\n if (gpuMorphed[j] === true) continue;\r\n\r\n var weight = targets[j].value;\r\n if (Math.abs(weight) <= MorphGeometry.EFFECTIVE_EPS) continue;\r\n\r\n weight /= extraWeightSum;\r\n\r\n var morphElts = attrs[attName + '_' + j].getInitialBufferArray().getElements();\r\n for (i = 0; i < nbVertex; ++i) {\r\n var k = i * itemSize;\r\n morphExtraTargets[k] += weight * morphElts[k];\r\n morphExtraTargets[k + 1] += weight * morphElts[k + 1];\r\n morphExtraTargets[k + 2] += weight * morphElts[k + 2];\r\n // don't morph tangent w component\r\n }\r\n }\r\n\r\n // map on last index target\r\n attrs[attName + '_' + (this._maxMorphGPU - 1)].setBufferArray(vAttr._cpuMorph);\r\n vAttr._cpuMorph.dirty();\r\n },\r\n\r\n _computeExtraWeightsSum: function() {\r\n var gpuMorphed = this._gpuMorphed;\r\n var sum = 0.0;\r\n var targets = this._targets;\r\n for (var i = 0, nb = targets.length; i < nb; ++i) {\r\n // ignore gpu morphed targets\r\n if (gpuMorphed[i] === true) continue;\r\n\r\n var weight = targets[i].value;\r\n if (Math.abs(weight) <= MorphGeometry.EFFECTIVE_EPS) continue;\r\n\r\n sum += weight;\r\n }\r\n // check comment in _morphBufferArrayCPU (avoid near zero value)\r\n var eps = 1e-5;\r\n if (Math.abs(sum) > eps) return sum;\r\n return sum < 0.0 ? -eps : eps;\r\n },\r\n\r\n _morphBufferArrayCPU: function() {\r\n // the idea is... we have :\r\n // v' = v * (1-w1-w2-w3) + t1*w1 + t2*w2 + t3*w3\r\n // we want\r\n // v' = v * (1-w1-w4) + t1*w1 + t4*w4\r\n // so basically we have to compute\r\n // w4 = w2+w3 // (check if ~0 !)\r\n // t4 = (t2*w2+t3*w3)/w4\r\n // (w4 is extraWeightSum and t4 will be computed in _mergeExtraMorphTarget)\r\n\r\n // compute new weights for the 4th target (all the extra target will be merged inside this one)\r\n var extraWeightSum = (this._weights[\r\n this._maxMorphGPU - 1\r\n ] = this._computeExtraWeightsSum());\r\n\r\n var processed = {}; // handles referenced buffer array (avoid useless double morph computation the same buffer)\r\n var morphs = this._morphs;\r\n for (var i = 0, nbMorphs = morphs.length; i < nbMorphs; ++i) {\r\n var morph = morphs[i];\r\n var vAttrs = morph.getVertexAttributeList();\r\n var morphNames = morph.getMorphTargetNames();\r\n\r\n for (var j = 0, nbNames = morphNames.length; j < nbNames; ++j) {\r\n var name = morphNames[j];\r\n var attr = vAttrs[name];\r\n // skip if the bufferArray is shared in another morphGeometry and has already been cpu morphed\r\n if (!attr || processed[attr.getInstanceID()]) continue;\r\n processed[attr.getInstanceID()] = true;\r\n\r\n this._mergeExtraMorphTarget(vAttrs, name, extraWeightSum);\r\n }\r\n }\r\n },\r\n\r\n updateWeights: function() {\r\n if (this._maxMorphGPU === 0) return;\r\n\r\n var i = 0;\r\n var targets = this._targets;\r\n var nbTargets = targets.length;\r\n // reset weights\r\n var weights = this._weights;\r\n weights[0] = weights[1] = weights[2] = weights[3] = 0.0;\r\n\r\n // no need to swap VA or to use CPU morph\r\n if (nbTargets <= this._maxMorphGPU) {\r\n for (i = 0; i < nbTargets; ++i) {\r\n weights[i] = targets[i].value;\r\n }\r\n return;\r\n }\r\n\r\n // reset indexMap\r\n var indexMap = this._indexMap;\r\n indexMap[0] = indexMap[1] = indexMap[2] = indexMap[3] = 0;\r\n\r\n // reset gpu morphed array\r\n var gpuMorphed = this._gpuMorphed;\r\n gpuMorphed.length = nbTargets;\r\n for (i = 0; i < nbTargets; ++i) gpuMorphed[i] = false;\r\n\r\n var sortedTargets = targets.slice(0).sort(funcWeights);\r\n\r\n for (i = 0; i < this._maxMorphGPU; ++i) {\r\n var ti = targets.indexOf(sortedTargets[i]);\r\n gpuMorphed[ti] = true;\r\n indexMap[i] = ti;\r\n weights[i] = sortedTargets[i].value;\r\n }\r\n\r\n // check more than 4 targets, we compute all the extra targets influence and merge in the last 4th morphs targets\r\n var extraEpsilon = Math.abs(sortedTargets[this._maxMorphGPU].value);\r\n var extraMorphCPU = extraEpsilon > MorphGeometry.EFFECTIVE_EPS;\r\n gpuMorphed[indexMap[this._maxMorphGPU - 1]] = !extraMorphCPU;\r\n\r\n this._remapBufferArrays();\r\n if (extraMorphCPU) {\r\n this._morphBufferArrayCPU();\r\n }\r\n },\r\n\r\n reset: function() {\r\n var targets = this._targets;\r\n for (var i = 0, nbTarget = targets.length; i < nbTarget; ++i) {\r\n targets[i].value = targets[i].defaultValue;\r\n }\r\n },\r\n\r\n update: function(node /*, nv*/) {\r\n if (!this.isInitialized()) this.init(node);\r\n\r\n this.updateWeights();\r\n\r\n var weights = this._weights;\r\n var nbTargets = Math.min(this._maxMorphGPU, this._targets.length);\r\n var morphs = this._morphs;\r\n for (var i = 0, nbMorphs = morphs.length; i < nbMorphs; ++i) {\r\n var array = morphs[i].getTargetsWeight();\r\n for (var j = 0; j < nbTargets; j++) {\r\n array[j] = weights[j];\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n }),\r\n 'osgAnimation',\r\n 'UpdateMorph'\r\n);\r\n\r\nexport default UpdateMorph;\r\n"],"sourceRoot":""}
|