csyjk 1.1.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.babelrc +7 -0
- package/.idea/modules.xml +8 -0
- package/.idea/xx.iml +12 -0
- package/dist/app.js +43 -0
- package/{index.html → dist/index.html} +0 -0
- package/{style.css → dist/style.css} +1 -1
- package/package.json +40 -5
- package/public/gltf.js +2241 -0
- package/public/index.html +10 -0
- package/src/index.js +3 -0
- package/src/lib/gltf/assets/check.jpg +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.css +358 -0
- package/src/lib/gltf/assets/iconfont/iconfont.eot +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.js +1 -0
- package/src/lib/gltf/assets/iconfont/iconfont.json +604 -0
- package/src/lib/gltf/assets/iconfont/iconfont.svg +189 -0
- package/src/lib/gltf/assets/iconfont/iconfont.ttf +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.woff +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.woff2 +0 -0
- package/src/lib/gltf/assets/yjkkit-sdk/index.js +0 -0
- package/src/lib/gltf/assets/yjkkit-sdk/package.json +15 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/ContextMenu.js +863 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/index.js +3 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +462 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.js +279 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.js +262 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/Annotation.js +362 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +575 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/AxisGizmoPlugin.js +333 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +777 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +525 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.js +242 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +297 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/FastNavPlugin.js +345 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +122 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +462 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFPerformanceModelLoader.js +508 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFSceneGraphLoader.js +922 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/CubeTextureCanvas.js +273 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/NavCubePlugin.js +687 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJLoaderPlugin.js +145 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJSceneGraphLoader.js +777 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLDefaultDataSource.js +33 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLLoaderPlugin.js +273 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLSceneGraphLoader.js +313 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Control.js +1328 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Overview.js +249 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Plane.js +169 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js +403 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +134 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/IFCStoreyPlanObjectStates.js +77 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/Storey.js +61 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyMap.js +57 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +822 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/ModelTreeView.js +888 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewNode.js +88 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewPlugin.js +624 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/modelValidation.js +87 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/ViewCullPlugin.js +295 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +78 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +847 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +167 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +228 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +220 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +279 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +244 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +301 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +426 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +479 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/lib/pako.js +6818 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DLoaderPlugin.js +238 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DSceneGraphLoader.js +1279 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/.jshintrc +11 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/deflate.js +2060 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/inflate.js +2155 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/mime-types.js +1002 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/pako/codecs.js +64 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/z-worker.js +153 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-ext.js +267 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-fs.js +553 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip.js +991 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zlib-asm/codecs.js +49 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/index.js +17 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/culling/ObjectCullStates.js +205 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Dot.js +78 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Label.js +97 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Wire.js +95 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Plugin.js +112 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Viewer.js +372 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/index.js +3 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaultColors.js +162 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaults.js +39 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaModel.js +145 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaObject.js +215 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaScene.js +311 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/CameraControl.js +1669 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/cc.js +0 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/CameraUpdater.js +312 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PanController.js +112 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PickController.js +193 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PivotController.js +289 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/cu.js +0 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +122 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +186 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MouseMiscHandler.js +68 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +439 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +361 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +258 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPickHandler.js +197 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/mouspan.js +498 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Component.js +908 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Entity.js +475 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/ImagePlane.js +570 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/PerformanceModel.js +2623 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ENTITY_FLAGS.js +21 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceMesh.js +262 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceNode.js +697 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/RENDER_PASSES.js +34 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ScratchMemory.js +63 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/compression.js +183 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingBuffer.js +33 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingLayer.js +736 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingRenderers.js +68 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingColorRenderer.js +295 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +327 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingLayer.js +698 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingRenderers.js +68 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingColorRenderer.js +364 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +356 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingBuffer.js +33 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingLayer.js +776 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingRenderers.js +113 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingColorRenderer.js +340 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +312 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +343 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +331 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingShadowRenderer.js +242 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +348 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingLayer.js +737 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingRenderers.js +143 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingColorRenderer.js +373 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +366 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +370 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +386 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +376 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +293 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +382 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingBuffer.js +37 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingLayer.js +1017 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingRenderers.js +246 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorQualityRenderer.js +809 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +504 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +297 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +300 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +322 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +311 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +291 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +319 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +305 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +300 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +242 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +323 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingLayer.js +969 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingRenderers.js +246 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorQualityRenderer.js +859 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +557 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +341 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +338 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +356 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +354 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +329 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +358 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +349 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +363 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +284 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +354 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Camera.js +880 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraFlightAnimation.js +669 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPath.js +194 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPathAnimation.js +326 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CustomProjection.js +149 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Frustum.js +316 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Ortho.js +286 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Perspective.js +302 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Canvas.js +464 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Spinner.js +323 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/core.js +234 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/Geometry.js +33 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/ReadableGeometry.js +689 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/VBOGeometry.js +327 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxGeometry.js +238 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +106 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildCylinderGeometry.js +271 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildGridGeometry.js +102 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +168 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildSphereGeometry.js +161 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildTorusGeometry.js +172 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildVectorTextGeometry.js +1721 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/index.js +8 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/index.js +4 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/load3DSGeometry.js +103 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/loadOBJGeometry.js +130 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/index.js +18 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/input/Input.js +1475 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/canvas2image.js +218 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/k3d.js +1032 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/AmbientLight.js +175 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/CubeTexture.js +156 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/DirLight.js +314 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Light.js +29 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/LightMap.js +77 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/PointLight.js +395 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/ReflectionMap.js +79 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Shadow.js +138 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/index.js +5 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/Marker.js +382 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EdgeMaterial.js +359 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EmphasisMaterial.js +577 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Fresnel.js +222 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LambertMaterial.js +378 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LinesMaterial.js +169 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Material.js +39 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/MetallicMaterial.js +820 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PhongMaterial.js +860 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PointsMaterial.js +320 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/SpecularMaterial.js +807 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Texture.js +522 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/index.js +8 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/Frustum.js +118 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/buildEdgeIndices.js +162 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/geometryCompressionUtils.js +353 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/math.js +5302 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/rtcCoords.js +132 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/CameraMemento.js +200 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ModelMemento.js +272 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ObjectsMemento.js +259 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/index.js +3 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/Mesh.js +2165 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawRenderer.js +978 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawShaderSource.js +1566 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +249 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +163 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +276 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +269 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +207 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +156 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshRenderer.js +210 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +146 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +186 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +120 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowRenderer.js +214 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +96 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/metriqs/Metriqs.js +259 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/Node.js +1356 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/CubicBezierCurve.js +194 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Curve.js +183 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Path.js +239 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/QuadraticBezierCurve.js +161 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/SplineCurve.js +133 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/index.js +5 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/postfx/SAO.js +547 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/scene/Scene.js +2481 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/SectionPlane.js +194 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/Skybox.js +119 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/index.js +1 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/stats.js +45 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Map.js +45 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Queue.js +56 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/index.js +2 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils.js +452 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/viewport/Viewport.js +212 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/ArrayBuf.js +121 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Attribute.js +23 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Drawable.js +270 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/FrameContext.js +259 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/PickResult.js +317 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Pickable.js +69 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Program.js +179 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderBuffer.js +315 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderFlags.js +203 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderState.js +40 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Renderer.js +1300 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Sampler.js +18 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Shader.js +49 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Texture2D.js +217 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +214 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionTester.js +432 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +326 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +375 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/webglEnums.js +61 -0
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webglInfo.js +48 -0
- package/src/lib/gltf/gltf.css +392 -0
- package/src/lib/gltf/gltf.js +2241 -0
- package/webpack.config.js +70 -0
- package/app.js +0 -43
@@ -0,0 +1,859 @@
|
|
1
|
+
import {Program} from "../../../../../webgl/Program.js";
|
2
|
+
import {math} from "../../../../../math/math.js";
|
3
|
+
import {createRTCViewMat, getPlaneRTCPos} from "../../../../../math/rtcCoords.js";
|
4
|
+
import {WEBGL_INFO} from "../../../../../webglInfo.js";
|
5
|
+
|
6
|
+
const tempVec4 = math.vec4();
|
7
|
+
const tempVec3a = math.vec3();
|
8
|
+
|
9
|
+
const TEXTURE_DECODE_FUNCS = {
|
10
|
+
"linear": "linearToLinear",
|
11
|
+
"sRGB": "sRGBToLinear",
|
12
|
+
"gamma": "gammaToLinear"
|
13
|
+
};
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @private
|
17
|
+
*/
|
18
|
+
class TrianglesInstancingColorQualityRenderer {
|
19
|
+
|
20
|
+
constructor(scene, withSAO) {
|
21
|
+
this._scene = scene;
|
22
|
+
this._withSAO = withSAO;
|
23
|
+
this._hash = this._getHash();
|
24
|
+
this._allocate();
|
25
|
+
}
|
26
|
+
|
27
|
+
getValid() {
|
28
|
+
return this._hash === this._getHash();
|
29
|
+
};
|
30
|
+
|
31
|
+
_getHash() {
|
32
|
+
const scene = this._scene;
|
33
|
+
return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
|
34
|
+
}
|
35
|
+
|
36
|
+
drawLayer(frameCtx, instancingLayer, renderPass) {
|
37
|
+
|
38
|
+
const model = instancingLayer.model;
|
39
|
+
const scene = this._scene;
|
40
|
+
const camera = scene.camera;
|
41
|
+
const gl = scene.canvas.gl;
|
42
|
+
const state = instancingLayer._state;
|
43
|
+
const instanceExt = this._instanceExt;
|
44
|
+
const rtcCenter = instancingLayer._state.rtcCenter;
|
45
|
+
|
46
|
+
if (!this._program) {
|
47
|
+
this._allocate();
|
48
|
+
if (this.errors) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
if (frameCtx.lastProgramId !== this._program.id) {
|
54
|
+
frameCtx.lastProgramId = this._program.id;
|
55
|
+
this._bindProgram(frameCtx);
|
56
|
+
}
|
57
|
+
|
58
|
+
gl.uniform1i(this._uRenderPass, renderPass);
|
59
|
+
|
60
|
+
gl.uniformMatrix4fv(this._uViewMatrix, false, (rtcCenter) ? createRTCViewMat(camera.viewMatrix, rtcCenter) : camera.viewMatrix);
|
61
|
+
gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
|
62
|
+
|
63
|
+
gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
|
64
|
+
gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
|
65
|
+
|
66
|
+
const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
|
67
|
+
if (numSectionPlanes > 0) {
|
68
|
+
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
69
|
+
const baseIndex = instancingLayer.layerIndex * numSectionPlanes;
|
70
|
+
const renderFlags = model.renderFlags;
|
71
|
+
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
|
72
|
+
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
73
|
+
if (sectionPlaneUniforms) {
|
74
|
+
const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
|
75
|
+
gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
|
76
|
+
if (active) {
|
77
|
+
const sectionPlane = sectionPlanes[sectionPlaneIndex];
|
78
|
+
if (rtcCenter) {
|
79
|
+
const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, rtcCenter, tempVec3a);
|
80
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
|
81
|
+
} else {
|
82
|
+
gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
|
83
|
+
}
|
84
|
+
gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
gl.uniformMatrix4fv(this._uPositionsDecodeMatrix, false, instancingLayer._state.positionsDecodeMatrix);
|
91
|
+
|
92
|
+
this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
|
93
|
+
this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
|
94
|
+
this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
|
95
|
+
|
96
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 1);
|
97
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 1);
|
98
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 1);
|
99
|
+
|
100
|
+
this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);
|
101
|
+
this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);
|
102
|
+
this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);
|
103
|
+
|
104
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol0.location, 1);
|
105
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol1.location, 1);
|
106
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol2.location, 1);
|
107
|
+
|
108
|
+
this._aPosition.bindArrayBuffer(state.positionsBuf);
|
109
|
+
this._aNormal.bindArrayBuffer(state.normalsBuf);
|
110
|
+
|
111
|
+
this._aColor.bindArrayBuffer(state.colorsBuf);
|
112
|
+
instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 1);
|
113
|
+
|
114
|
+
this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);
|
115
|
+
instanceExt.vertexAttribDivisorANGLE(this._aMetallicRoughness.location, 1);
|
116
|
+
|
117
|
+
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
118
|
+
instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 1);
|
119
|
+
|
120
|
+
if (this._aFlags2) {
|
121
|
+
this._aFlags2.bindArrayBuffer(state.flags2Buf);
|
122
|
+
instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 1);
|
123
|
+
}
|
124
|
+
|
125
|
+
if (this._aOffset) {
|
126
|
+
this._aOffset.bindArrayBuffer(state.offsetsBuf);
|
127
|
+
instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 1);
|
128
|
+
}
|
129
|
+
|
130
|
+
state.indicesBuf.bind();
|
131
|
+
|
132
|
+
instanceExt.drawElementsInstancedANGLE(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
133
|
+
|
134
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 0);
|
135
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 0);
|
136
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 0);
|
137
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol0.location, 0);
|
138
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol1.location, 0);
|
139
|
+
instanceExt.vertexAttribDivisorANGLE(this._aModelNormalMatrixCol2.location, 0);
|
140
|
+
instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 0);
|
141
|
+
instanceExt.vertexAttribDivisorANGLE(this._aMetallicRoughness.location, 0);
|
142
|
+
instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 0);
|
143
|
+
|
144
|
+
if (this._aFlags2) { // Won't be in shader when not clipping
|
145
|
+
instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 0);
|
146
|
+
}
|
147
|
+
|
148
|
+
if (this._aOffset) {
|
149
|
+
instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 0);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
_allocate() {
|
154
|
+
|
155
|
+
const scene = this._scene;
|
156
|
+
const gl = scene.canvas.gl;
|
157
|
+
const lightsState = scene._lightsState;
|
158
|
+
|
159
|
+
this._program = new Program(gl, this._buildShader());
|
160
|
+
|
161
|
+
if (this._program.errors) {
|
162
|
+
this.errors = this._program.errors;
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
this._instanceExt = gl.getExtension("ANGLE_instanced_arrays");
|
167
|
+
|
168
|
+
const program = this._program;
|
169
|
+
|
170
|
+
this._uRenderPass = program.getLocation("renderPass");
|
171
|
+
|
172
|
+
this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
|
173
|
+
|
174
|
+
this._uWorldMatrix = program.getLocation("worldMatrix");
|
175
|
+
this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
|
176
|
+
|
177
|
+
this._uViewMatrix = program.getLocation("viewMatrix");
|
178
|
+
this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
|
179
|
+
this._uProjMatrix = program.getLocation("projMatrix");
|
180
|
+
|
181
|
+
this._uGammaFactor = program.getLocation("gammaFactor");
|
182
|
+
|
183
|
+
this._uLightAmbient = program.getLocation("lightAmbient");
|
184
|
+
this._uLightColor = [];
|
185
|
+
this._uLightDir = [];
|
186
|
+
this._uLightPos = [];
|
187
|
+
this._uLightAttenuation = [];
|
188
|
+
|
189
|
+
const lights = lightsState.lights;
|
190
|
+
let light;
|
191
|
+
|
192
|
+
for (var i = 0, len = lights.length; i < len; i++) {
|
193
|
+
light = lights[i];
|
194
|
+
switch (light.type) {
|
195
|
+
case "dir":
|
196
|
+
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
197
|
+
this._uLightPos[i] = null;
|
198
|
+
this._uLightDir[i] = program.getLocation("lightDir" + i);
|
199
|
+
break;
|
200
|
+
case "point":
|
201
|
+
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
202
|
+
this._uLightPos[i] = program.getLocation("lightPos" + i);
|
203
|
+
this._uLightDir[i] = null;
|
204
|
+
this._uLightAttenuation[i] = program.getLocation("lightAttenuation" + i);
|
205
|
+
break;
|
206
|
+
case "spot":
|
207
|
+
this._uLightColor[i] = program.getLocation("lightColor" + i);
|
208
|
+
this._uLightPos[i] = program.getLocation("lightPos" + i);
|
209
|
+
this._uLightDir[i] = program.getLocation("lightDir" + i);
|
210
|
+
this._uLightAttenuation[i] = program.getLocation("lightAttenuation" + i);
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
if (lightsState.reflectionMaps.length > 0) {
|
216
|
+
this._uReflectionMap = "reflectionMap";
|
217
|
+
}
|
218
|
+
|
219
|
+
if (lightsState.lightMaps.length > 0) {
|
220
|
+
this._uLightMap = "lightMap";
|
221
|
+
}
|
222
|
+
|
223
|
+
this._uSectionPlanes = [];
|
224
|
+
|
225
|
+
for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
|
226
|
+
this._uSectionPlanes.push({
|
227
|
+
active: program.getLocation("sectionPlaneActive" + i),
|
228
|
+
pos: program.getLocation("sectionPlanePos" + i),
|
229
|
+
dir: program.getLocation("sectionPlaneDir" + i)
|
230
|
+
});
|
231
|
+
}
|
232
|
+
|
233
|
+
this._aPosition = program.getAttribute("position");
|
234
|
+
this._aNormal = program.getAttribute("normal");
|
235
|
+
this._aColor = program.getAttribute("color");
|
236
|
+
this._aMetallicRoughness = program.getAttribute("metallicRoughness");
|
237
|
+
this._aFlags = program.getAttribute("flags");
|
238
|
+
this._aFlags2 = program.getAttribute("flags2");
|
239
|
+
this._aOffset = program.getAttribute("offset");
|
240
|
+
|
241
|
+
this._aModelMatrixCol0 = program.getAttribute("modelMatrixCol0");
|
242
|
+
this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
|
243
|
+
this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
|
244
|
+
|
245
|
+
this._aModelNormalMatrixCol0 = program.getAttribute("modelNormalMatrixCol0");
|
246
|
+
this._aModelNormalMatrixCol1 = program.getAttribute("modelNormalMatrixCol1");
|
247
|
+
this._aModelNormalMatrixCol2 = program.getAttribute("modelNormalMatrixCol2");
|
248
|
+
|
249
|
+
this._uOcclusionTexture = "uOcclusionTexture";
|
250
|
+
this._uSAOParams = program.getLocation("uSAOParams");
|
251
|
+
|
252
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
253
|
+
this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
_bindProgram(frameCtx) {
|
258
|
+
|
259
|
+
const maxTextureUnits = WEBGL_INFO.MAX_TEXTURE_UNITS;
|
260
|
+
const scene = this._scene;
|
261
|
+
const gl = scene.canvas.gl;
|
262
|
+
const lightsState = scene._lightsState;
|
263
|
+
const lights = lightsState.lights;
|
264
|
+
const project = scene.camera.project;
|
265
|
+
|
266
|
+
this._program.bind();
|
267
|
+
|
268
|
+
gl.uniformMatrix4fv(this._uProjMatrix, false, project.matrix);
|
269
|
+
|
270
|
+
if (this._uLightAmbient) {
|
271
|
+
gl.uniform4fv(this._uLightAmbient, scene._lightsState.getAmbientColorAndIntensity());
|
272
|
+
}
|
273
|
+
|
274
|
+
for (let i = 0, len = lights.length; i < len; i++) {
|
275
|
+
const light = lights[i];
|
276
|
+
if (this._uLightColor[i]) {
|
277
|
+
gl.uniform4f(this._uLightColor[i], light.color[0], light.color[1], light.color[2], light.intensity);
|
278
|
+
}
|
279
|
+
if (this._uLightPos[i]) {
|
280
|
+
gl.uniform3fv(this._uLightPos[i], light.pos);
|
281
|
+
if (this._uLightAttenuation[i]) {
|
282
|
+
gl.uniform1f(this._uLightAttenuation[i], light.attenuation);
|
283
|
+
}
|
284
|
+
}
|
285
|
+
if (this._uLightDir[i]) {
|
286
|
+
gl.uniform3fv(this._uLightDir[i], light.dir);
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
if (lightsState.reflectionMaps.length > 0 && lightsState.reflectionMaps[0].texture && this._uReflectionMap) {
|
291
|
+
this._program.bindTexture(this._uReflectionMap, lightsState.reflectionMaps[0].texture, frameCtx.textureUnit);
|
292
|
+
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
293
|
+
frameCtx.bindTexture++;
|
294
|
+
}
|
295
|
+
|
296
|
+
if (lightsState.lightMaps.length > 0 && lightsState.lightMaps[0].texture && this._uLightMap) {
|
297
|
+
this._program.bindTexture(this._uLightMap, lightsState.lightMaps[0].texture, frameCtx.textureUnit);
|
298
|
+
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
299
|
+
frameCtx.bindTexture++;
|
300
|
+
}
|
301
|
+
|
302
|
+
if (this._withSAO) {
|
303
|
+
const sao = scene.sao;
|
304
|
+
const saoEnabled = sao.possible;
|
305
|
+
if (saoEnabled) {
|
306
|
+
const viewportWidth = gl.drawingBufferWidth;
|
307
|
+
const viewportHeight = gl.drawingBufferHeight;
|
308
|
+
tempVec4[0] = viewportWidth;
|
309
|
+
tempVec4[1] = viewportHeight;
|
310
|
+
tempVec4[2] = sao.blendCutoff;
|
311
|
+
tempVec4[3] = sao.blendFactor;
|
312
|
+
gl.uniform4fv(this._uSAOParams, tempVec4);
|
313
|
+
this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, frameCtx.textureUnit);
|
314
|
+
frameCtx.textureUnit = (frameCtx.textureUnit + 1) % maxTextureUnits;
|
315
|
+
frameCtx.bindTexture++;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
320
|
+
const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
|
321
|
+
gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
|
322
|
+
}
|
323
|
+
|
324
|
+
if (this._uGammaFactor) {
|
325
|
+
gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
_buildShader() {
|
330
|
+
return {
|
331
|
+
vertex: this._buildVertexShader(),
|
332
|
+
fragment: this._buildFragmentShader()
|
333
|
+
};
|
334
|
+
}
|
335
|
+
|
336
|
+
_buildVertexShader() {
|
337
|
+
|
338
|
+
const scene = this._scene;
|
339
|
+
const sectionPlanesState = scene._sectionPlanesState;
|
340
|
+
const lightsState = scene._lightsState;
|
341
|
+
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
342
|
+
const clippingCaps = sectionPlanesState.clippingCaps;
|
343
|
+
const src = [];
|
344
|
+
|
345
|
+
src.push("// Instancing geometry quality drawing vertex shader");
|
346
|
+
|
347
|
+
if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
348
|
+
src.push("#extension GL_EXT_frag_depth : enable");
|
349
|
+
}
|
350
|
+
src.push("uniform int renderPass;");
|
351
|
+
|
352
|
+
src.push("attribute vec3 position;");
|
353
|
+
src.push("attribute vec2 normal;");
|
354
|
+
src.push("attribute vec4 color;");
|
355
|
+
src.push("attribute vec2 metallicRoughness;");
|
356
|
+
src.push("attribute vec4 flags;");
|
357
|
+
src.push("attribute vec4 flags2;");
|
358
|
+
|
359
|
+
if (scene.entityOffsetsEnabled) {
|
360
|
+
src.push("attribute vec3 offset;");
|
361
|
+
}
|
362
|
+
|
363
|
+
src.push("attribute vec4 modelMatrixCol0;"); // Modeling matrix
|
364
|
+
src.push("attribute vec4 modelMatrixCol1;");
|
365
|
+
src.push("attribute vec4 modelMatrixCol2;");
|
366
|
+
|
367
|
+
src.push("attribute vec4 modelNormalMatrixCol0;");
|
368
|
+
src.push("attribute vec4 modelNormalMatrixCol1;");
|
369
|
+
src.push("attribute vec4 modelNormalMatrixCol2;");
|
370
|
+
|
371
|
+
src.push("uniform mat4 worldMatrix;");
|
372
|
+
src.push("uniform mat4 worldNormalMatrix;");
|
373
|
+
src.push("uniform mat4 viewMatrix;");
|
374
|
+
src.push("uniform mat4 viewNormalMatrix;");
|
375
|
+
src.push("uniform mat4 projMatrix;");
|
376
|
+
src.push("uniform mat4 positionsDecodeMatrix;");
|
377
|
+
|
378
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
379
|
+
src.push("uniform float logDepthBufFC;");
|
380
|
+
if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
381
|
+
src.push("varying float vFragDepth;");
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
src.push("vec3 octDecode(vec2 oct) {");
|
386
|
+
src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
|
387
|
+
src.push(" if (v.z < 0.0) {");
|
388
|
+
src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");
|
389
|
+
src.push(" }");
|
390
|
+
src.push(" return normalize(v);");
|
391
|
+
src.push("}");
|
392
|
+
|
393
|
+
src.push("varying vec4 vViewPosition;");
|
394
|
+
src.push("varying vec3 vViewNormal;");
|
395
|
+
src.push("varying vec4 vColor;");
|
396
|
+
src.push("varying vec2 vMetallicRoughness;");
|
397
|
+
|
398
|
+
if (lightsState.lightMaps.length > 0) {
|
399
|
+
src.push("varying vec3 vWorldNormal;");
|
400
|
+
}
|
401
|
+
|
402
|
+
if (clipping) {
|
403
|
+
src.push("varying vec4 vWorldPosition;");
|
404
|
+
src.push("varying vec4 vFlags2;");
|
405
|
+
if (clippingCaps) {
|
406
|
+
src.push("varying vec4 vClipPosition;");
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
src.push("void main(void) {");
|
411
|
+
|
412
|
+
// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
413
|
+
// renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
|
414
|
+
|
415
|
+
src.push(`if (int(flags.x) != renderPass) {`);
|
416
|
+
src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);"); // Cull vertex
|
417
|
+
|
418
|
+
src.push("} else {");
|
419
|
+
|
420
|
+
src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
|
421
|
+
src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
|
422
|
+
if (scene.entityOffsetsEnabled) {
|
423
|
+
src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
|
424
|
+
}
|
425
|
+
|
426
|
+
src.push("vec4 viewPosition = viewMatrix * worldPosition; ");
|
427
|
+
|
428
|
+
src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");
|
429
|
+
src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");
|
430
|
+
src.push("vec3 viewNormal = vec4(viewNormalMatrix * worldNormal).xyz;");
|
431
|
+
|
432
|
+
src.push("vec4 clipPos = projMatrix * viewPosition;");
|
433
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
434
|
+
if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
435
|
+
src.push("vFragDepth = 1.0 + clipPos.w;");
|
436
|
+
} else {
|
437
|
+
src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
|
438
|
+
src.push("clipPos.z *= clipPos.w;");
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
if (clipping) {
|
443
|
+
src.push("vWorldPosition = worldPosition;");
|
444
|
+
src.push("vFlags2 = flags2;");
|
445
|
+
if (clippingCaps) {
|
446
|
+
src.push("vClipPosition = clipPos;");
|
447
|
+
}
|
448
|
+
}
|
449
|
+
|
450
|
+
src.push("vViewPosition = viewPosition;");
|
451
|
+
src.push("vViewNormal = viewNormal;");
|
452
|
+
src.push("vColor = color;");
|
453
|
+
src.push("vMetallicRoughness = metallicRoughness;");
|
454
|
+
|
455
|
+
if (lightsState.lightMaps.length > 0) {
|
456
|
+
src.push("vWorldNormal = worldNormal.xyz;");
|
457
|
+
}
|
458
|
+
|
459
|
+
src.push("gl_Position = clipPos;");
|
460
|
+
src.push("}");
|
461
|
+
src.push("}");
|
462
|
+
return src;
|
463
|
+
}
|
464
|
+
|
465
|
+
_buildFragmentShader() {
|
466
|
+
|
467
|
+
const scene = this._scene;
|
468
|
+
const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
|
469
|
+
const sectionPlanesState = scene._sectionPlanesState;
|
470
|
+
const lightsState = scene._lightsState;
|
471
|
+
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
472
|
+
const clippingCaps = sectionPlanesState.clippingCaps;
|
473
|
+
const src = [];
|
474
|
+
|
475
|
+
src.push("// Instancing geometry quality drawing fragment shader");
|
476
|
+
|
477
|
+
if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
478
|
+
src.push("#extension GL_EXT_frag_depth : enable");
|
479
|
+
}
|
480
|
+
|
481
|
+
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
482
|
+
src.push("precision highp float;");
|
483
|
+
src.push("precision highp int;");
|
484
|
+
src.push("#else");
|
485
|
+
src.push("precision mediump float;");
|
486
|
+
src.push("precision mediump int;");
|
487
|
+
src.push("#endif");
|
488
|
+
|
489
|
+
if (scene.logarithmicDepthBufferEnabled) {
|
490
|
+
if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
491
|
+
src.push("uniform float logDepthBufFC;");
|
492
|
+
src.push("varying float vFragDepth;");
|
493
|
+
}
|
494
|
+
}
|
495
|
+
|
496
|
+
if (this._withSAO) {
|
497
|
+
src.push("uniform sampler2D uOcclusionTexture;");
|
498
|
+
src.push("uniform vec4 uSAOParams;");
|
499
|
+
|
500
|
+
src.push("const float packUpscale = 256. / 255.;");
|
501
|
+
src.push("const float unpackDownScale = 255. / 256.;");
|
502
|
+
src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
|
503
|
+
src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");
|
504
|
+
|
505
|
+
src.push("float unpackRGBAToDepth( const in vec4 v ) {");
|
506
|
+
src.push(" return dot( v, unPackFactors );");
|
507
|
+
src.push("}");
|
508
|
+
}
|
509
|
+
|
510
|
+
if (lightsState.reflectionMaps.length > 0) {
|
511
|
+
src.push("uniform samplerCube reflectionMap;");
|
512
|
+
}
|
513
|
+
|
514
|
+
if (lightsState.lightMaps.length > 0) {
|
515
|
+
src.push("uniform samplerCube lightMap;");
|
516
|
+
}
|
517
|
+
|
518
|
+
src.push("uniform vec4 lightAmbient;");
|
519
|
+
|
520
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
521
|
+
const light = lightsState.lights[i];
|
522
|
+
if (light.type === "ambient") {
|
523
|
+
continue;
|
524
|
+
}
|
525
|
+
src.push("uniform vec4 lightColor" + i + ";");
|
526
|
+
if (light.type === "dir") {
|
527
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
528
|
+
}
|
529
|
+
if (light.type === "point") {
|
530
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
531
|
+
}
|
532
|
+
if (light.type === "spot") {
|
533
|
+
src.push("uniform vec3 lightPos" + i + ";");
|
534
|
+
src.push("uniform vec3 lightDir" + i + ";");
|
535
|
+
}
|
536
|
+
}
|
537
|
+
|
538
|
+
src.push("uniform float gammaFactor;");
|
539
|
+
src.push("vec4 linearToLinear( in vec4 value ) {");
|
540
|
+
src.push(" return value;");
|
541
|
+
src.push("}");
|
542
|
+
src.push("vec4 sRGBToLinear( in vec4 value ) {");
|
543
|
+
src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
|
544
|
+
src.push("}");
|
545
|
+
src.push("vec4 gammaToLinear( in vec4 value) {");
|
546
|
+
src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
|
547
|
+
src.push("}");
|
548
|
+
if (gammaOutput) {
|
549
|
+
src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
|
550
|
+
src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
|
551
|
+
src.push("}");
|
552
|
+
}
|
553
|
+
|
554
|
+
if (clipping) {
|
555
|
+
src.push("varying vec4 vWorldPosition;");
|
556
|
+
src.push("varying vec4 vFlags2;");
|
557
|
+
if (clippingCaps) {
|
558
|
+
src.push("varying vec4 vClipPosition;");
|
559
|
+
}
|
560
|
+
for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
|
561
|
+
src.push("uniform bool sectionPlaneActive" + i + ";");
|
562
|
+
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
563
|
+
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
564
|
+
}
|
565
|
+
}
|
566
|
+
|
567
|
+
src.push("varying vec4 vViewPosition;");
|
568
|
+
src.push("varying vec3 vViewNormal;");
|
569
|
+
src.push("varying vec4 vColor;");
|
570
|
+
src.push("varying vec2 vMetallicRoughness;");
|
571
|
+
|
572
|
+
if (lightsState.lightMaps.length > 0) {
|
573
|
+
src.push("varying vec3 vWorldNormal;");
|
574
|
+
}
|
575
|
+
|
576
|
+
src.push("uniform mat4 viewMatrix;");
|
577
|
+
|
578
|
+
// CONSTANT DEFINITIONS
|
579
|
+
|
580
|
+
src.push("#define PI 3.14159265359");
|
581
|
+
src.push("#define RECIPROCAL_PI 0.31830988618");
|
582
|
+
src.push("#define RECIPROCAL_PI2 0.15915494");
|
583
|
+
src.push("#define EPSILON 1e-6");
|
584
|
+
|
585
|
+
src.push("#define saturate(a) clamp( a, 0.0, 1.0 )");
|
586
|
+
|
587
|
+
// UTILITY DEFINITIONS
|
588
|
+
|
589
|
+
src.push("vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {");
|
590
|
+
src.push(" return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );");
|
591
|
+
src.push("}");
|
592
|
+
|
593
|
+
// STRUCTURES
|
594
|
+
|
595
|
+
src.push("struct IncidentLight {");
|
596
|
+
src.push(" vec3 color;");
|
597
|
+
src.push(" vec3 direction;");
|
598
|
+
src.push("};");
|
599
|
+
|
600
|
+
src.push("struct ReflectedLight {");
|
601
|
+
src.push(" vec3 diffuse;");
|
602
|
+
src.push(" vec3 specular;");
|
603
|
+
src.push("};");
|
604
|
+
|
605
|
+
src.push("struct Geometry {");
|
606
|
+
src.push(" vec3 position;");
|
607
|
+
src.push(" vec3 viewNormal;");
|
608
|
+
src.push(" vec3 worldNormal;");
|
609
|
+
src.push(" vec3 viewEyeDir;");
|
610
|
+
src.push("};");
|
611
|
+
|
612
|
+
src.push("struct Material {");
|
613
|
+
src.push(" vec3 diffuseColor;");
|
614
|
+
src.push(" float specularRoughness;");
|
615
|
+
src.push(" vec3 specularColor;");
|
616
|
+
src.push(" float shine;"); // Only used for Phong
|
617
|
+
src.push("};");
|
618
|
+
|
619
|
+
// IRRADIANCE EVALUATION
|
620
|
+
|
621
|
+
src.push("float GGXRoughnessToBlinnExponent(const in float ggxRoughness) {");
|
622
|
+
src.push(" float r = ggxRoughness + 0.0001;");
|
623
|
+
src.push(" return (2.0 / (r * r) - 2.0);");
|
624
|
+
src.push("}");
|
625
|
+
|
626
|
+
src.push("float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {");
|
627
|
+
src.push(" float maxMIPLevelScalar = float( maxMIPLevel );");
|
628
|
+
src.push(" float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( ( blinnShininessExponent * blinnShininessExponent ) + 1.0 );");
|
629
|
+
src.push(" return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );");
|
630
|
+
src.push("}");
|
631
|
+
|
632
|
+
if (lightsState.reflectionMaps.length > 0) {
|
633
|
+
src.push("vec3 getLightProbeIndirectRadiance(const in vec3 reflectVec, const in float blinnShininessExponent, const in int maxMIPLevel) {");
|
634
|
+
src.push(" float mipLevel = 0.5 * getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);"); //TODO: a random factor - fix this
|
635
|
+
src.push(" vec3 envMapColor = " + TEXTURE_DECODE_FUNCS[lightsState.reflectionMaps[0].encoding] + "(textureCube(reflectionMap, reflectVec, mipLevel)).rgb;");
|
636
|
+
src.push(" return envMapColor;");
|
637
|
+
src.push("}");
|
638
|
+
}
|
639
|
+
|
640
|
+
// SPECULAR BRDF EVALUATION
|
641
|
+
|
642
|
+
src.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {");
|
643
|
+
src.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );");
|
644
|
+
src.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;");
|
645
|
+
src.push("}");
|
646
|
+
|
647
|
+
src.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {");
|
648
|
+
src.push(" float a2 = ( alpha * alpha );");
|
649
|
+
src.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");
|
650
|
+
src.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");
|
651
|
+
src.push(" return 1.0 / ( gl * gv );");
|
652
|
+
src.push("}");
|
653
|
+
|
654
|
+
src.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {");
|
655
|
+
src.push(" float a2 = ( alpha * alpha );");
|
656
|
+
src.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");
|
657
|
+
src.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");
|
658
|
+
src.push(" return 0.5 / max( gv + gl, EPSILON );");
|
659
|
+
src.push("}");
|
660
|
+
|
661
|
+
src.push("float D_GGX(const in float alpha, const in float dotNH) {");
|
662
|
+
src.push(" float a2 = ( alpha * alpha );");
|
663
|
+
src.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;");
|
664
|
+
src.push(" return RECIPROCAL_PI * a2 / ( denom * denom);");
|
665
|
+
src.push("}");
|
666
|
+
|
667
|
+
src.push("vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");
|
668
|
+
src.push(" float alpha = ( roughness * roughness );");
|
669
|
+
src.push(" vec3 halfDir = normalize( incidentLight.direction + geometry.viewEyeDir );");
|
670
|
+
src.push(" float dotNL = saturate( dot( geometry.viewNormal, incidentLight.direction ) );");
|
671
|
+
src.push(" float dotNV = saturate( dot( geometry.viewNormal, geometry.viewEyeDir ) );");
|
672
|
+
src.push(" float dotNH = saturate( dot( geometry.viewNormal, halfDir ) );");
|
673
|
+
src.push(" float dotLH = saturate( dot( incidentLight.direction, halfDir ) );");
|
674
|
+
src.push(" vec3 F = F_Schlick( specularColor, dotLH );");
|
675
|
+
src.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );");
|
676
|
+
src.push(" float D = D_GGX( alpha, dotNH );");
|
677
|
+
src.push(" return F * (G * D);");
|
678
|
+
src.push("}");
|
679
|
+
|
680
|
+
src.push("vec3 BRDF_Specular_GGX_Environment(const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");
|
681
|
+
src.push(" float dotNV = saturate(dot(geometry.viewNormal, geometry.viewEyeDir));");
|
682
|
+
src.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);");
|
683
|
+
src.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);");
|
684
|
+
src.push(" vec4 r = roughness * c0 + c1;");
|
685
|
+
src.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;");
|
686
|
+
src.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;");
|
687
|
+
src.push(" return specularColor * AB.x + AB.y;");
|
688
|
+
src.push("}");
|
689
|
+
|
690
|
+
if (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0) {
|
691
|
+
|
692
|
+
src.push("void computePBRLightMapping(const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
|
693
|
+
|
694
|
+
if (lightsState.lightMaps.length > 0) {
|
695
|
+
src.push(" vec3 irradiance = " + TEXTURE_DECODE_FUNCS[lightsState.lightMaps[0].encoding] + "(textureCube(lightMap, geometry.worldNormal)).rgb;");
|
696
|
+
src.push(" irradiance *= PI;");
|
697
|
+
src.push(" vec3 diffuseBRDFContrib = (RECIPROCAL_PI * material.diffuseColor);");
|
698
|
+
src.push(" reflectedLight.diffuse += irradiance * diffuseBRDFContrib;");
|
699
|
+
}
|
700
|
+
|
701
|
+
if (lightsState.reflectionMaps.length > 0) {
|
702
|
+
src.push(" vec3 reflectVec = reflect(geometry.viewEyeDir, geometry.viewNormal);");
|
703
|
+
src.push(" reflectVec = inverseTransformDirection(reflectVec, viewMatrix);");
|
704
|
+
src.push(" float blinnExpFromRoughness = GGXRoughnessToBlinnExponent(material.specularRoughness);");
|
705
|
+
src.push(" vec3 radiance = getLightProbeIndirectRadiance(reflectVec, blinnExpFromRoughness, 8);");
|
706
|
+
src.push(" vec3 specularBRDFContrib = BRDF_Specular_GGX_Environment(geometry, material.specularColor, material.specularRoughness);");
|
707
|
+
src.push(" reflectedLight.specular += radiance * specularBRDFContrib;");
|
708
|
+
}
|
709
|
+
|
710
|
+
src.push("}");
|
711
|
+
}
|
712
|
+
|
713
|
+
// MAIN LIGHTING COMPUTATION FUNCTION
|
714
|
+
|
715
|
+
src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
|
716
|
+
src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");
|
717
|
+
src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");
|
718
|
+
src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");
|
719
|
+
src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");
|
720
|
+
src.push("}");
|
721
|
+
|
722
|
+
src.push("void main(void) {");
|
723
|
+
|
724
|
+
if (clipping) {
|
725
|
+
src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
|
726
|
+
src.push(" if (clippable) {");
|
727
|
+
src.push(" float dist = 0.0;");
|
728
|
+
for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
|
729
|
+
src.push("if (sectionPlaneActive" + i + ") {");
|
730
|
+
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
731
|
+
src.push("}");
|
732
|
+
}
|
733
|
+
if (clippingCaps) {
|
734
|
+
src.push(" if (dist > (0.002 * vClipPosition.w)) {");
|
735
|
+
src.push(" discard;");
|
736
|
+
src.push(" }");
|
737
|
+
src.push(" if (dist > 0.0) { ");
|
738
|
+
src.push(" gl_FragColor=vec4(1.0, 0.0, 0.0, 1.0);");
|
739
|
+
if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
740
|
+
src.push(" gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
741
|
+
}
|
742
|
+
src.push(" return;");
|
743
|
+
src.push("}");
|
744
|
+
} else {
|
745
|
+
src.push(" if (dist > 0.0) { ");
|
746
|
+
src.push(" discard;")
|
747
|
+
src.push(" }");
|
748
|
+
}
|
749
|
+
src.push("}");
|
750
|
+
}
|
751
|
+
|
752
|
+
src.push("IncidentLight light;");
|
753
|
+
src.push("Material material;");
|
754
|
+
src.push("Geometry geometry;");
|
755
|
+
src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");
|
756
|
+
|
757
|
+
src.push("vec3 rgb = (vec3(float(vColor.r) / 255.0, float(vColor.g) / 255.0, float(vColor.b) / 255.0));");
|
758
|
+
src.push("float alpha = float(vColor.a) / 255.0;");
|
759
|
+
|
760
|
+
src.push("vec3 diffuseColor = rgb;");
|
761
|
+
src.push("float specularF0 = 1.0;");
|
762
|
+
src.push("float metallic = float(vMetallicRoughness.r) / 255.0;");
|
763
|
+
src.push("float roughness = float(vMetallicRoughness.g) / 255.0;");
|
764
|
+
src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");
|
765
|
+
|
766
|
+
src.push("material.diffuseColor = diffuseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);");
|
767
|
+
src.push("material.specularRoughness = clamp(roughness, 0.04, 1.0);");
|
768
|
+
src.push("material.specularColor = mix(vec3(dielectricSpecular), diffuseColor, metallic);");
|
769
|
+
|
770
|
+
src.push("geometry.position = vViewPosition.xyz;");
|
771
|
+
src.push("geometry.viewNormal = -normalize(vViewNormal);");
|
772
|
+
src.push("geometry.viewEyeDir = normalize(vViewPosition.xyz);");
|
773
|
+
if (lightsState.lightMaps.length > 0) {
|
774
|
+
src.push("geometry.worldNormal = normalize(vWorldNormal);");
|
775
|
+
}
|
776
|
+
|
777
|
+
if (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0) {
|
778
|
+
src.push("computePBRLightMapping(geometry, material, reflectedLight);");
|
779
|
+
}
|
780
|
+
|
781
|
+
for (let i = 0, len = lightsState.lights.length; i < len; i++) {
|
782
|
+
|
783
|
+
const light = lightsState.lights[i];
|
784
|
+
|
785
|
+
if (light.type === "ambient") {
|
786
|
+
continue;
|
787
|
+
}
|
788
|
+
if (light.type === "dir") {
|
789
|
+
if (light.space === "view") {
|
790
|
+
src.push("light.direction = normalize(lightDir" + i + ");");
|
791
|
+
} else {
|
792
|
+
src.push("light.direction = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
793
|
+
}
|
794
|
+
} else if (light.type === "point") {
|
795
|
+
if (light.space === "view") {
|
796
|
+
src.push("light.direction = normalize(lightPos" + i + " - vViewPosition.xyz);");
|
797
|
+
} else {
|
798
|
+
src.push("light.direction = normalize((viewMatrix * vec4(lightPos" + i + ", 0.0)).xyz);");
|
799
|
+
}
|
800
|
+
} else if (light.type === "spot") {
|
801
|
+
if (light.space === "view") {
|
802
|
+
src.push("light.direction = normalize(lightDir" + i + ");");
|
803
|
+
} else {
|
804
|
+
src.push("light.direction = normalize((viewMatrix * vec4(lightDir" + i + ", 0.0)).xyz);");
|
805
|
+
}
|
806
|
+
} else {
|
807
|
+
continue;
|
808
|
+
}
|
809
|
+
|
810
|
+
src.push("light.color = lightColor" + i + ".rgb * lightColor" + i + ".a;"); // a is intensity
|
811
|
+
|
812
|
+
src.push("computePBRLighting(light, geometry, material, reflectedLight);");
|
813
|
+
}
|
814
|
+
|
815
|
+
src.push("vec3 outgoingLight = (lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedLight.diffuse) + (reflectedLight.specular);");
|
816
|
+
|
817
|
+
src.push("vec4 fragColor;");
|
818
|
+
|
819
|
+
if (this._withSAO) {
|
820
|
+
// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
821
|
+
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
822
|
+
src.push(" float viewportWidth = uSAOParams[0];");
|
823
|
+
src.push(" float viewportHeight = uSAOParams[1];");
|
824
|
+
src.push(" float blendCutoff = uSAOParams[2];");
|
825
|
+
src.push(" float blendFactor = uSAOParams[3];");
|
826
|
+
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
|
827
|
+
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBAToDepth(texture2D(uOcclusionTexture, uv))) * blendFactor;");
|
828
|
+
src.push(" fragColor = vec4(outgoingLight.rgb * ambient, alpha);");
|
829
|
+
} else {
|
830
|
+
src.push(" fragColor = vec4(outgoingLight.rgb, alpha);");
|
831
|
+
}
|
832
|
+
|
833
|
+
if (gammaOutput) {
|
834
|
+
src.push("fragColor = linearToGamma(fragColor, gammaFactor);");
|
835
|
+
}
|
836
|
+
|
837
|
+
src.push("gl_FragColor = fragColor;");
|
838
|
+
|
839
|
+
if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
|
840
|
+
src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
841
|
+
}
|
842
|
+
|
843
|
+
src.push("}");
|
844
|
+
return src;
|
845
|
+
}
|
846
|
+
|
847
|
+
webglContextRestored() {
|
848
|
+
this._program = null;
|
849
|
+
}
|
850
|
+
|
851
|
+
destroy() {
|
852
|
+
if (this._program) {
|
853
|
+
this._program.destroy();
|
854
|
+
}
|
855
|
+
this._program = null;
|
856
|
+
}
|
857
|
+
}
|
858
|
+
|
859
|
+
export {TrianglesInstancingColorQualityRenderer};
|