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,2165 @@
|
|
1
|
+
/**
|
2
|
+
Fired when this Mesh is picked via a call to {@link Scene/pick:method"}}Scene#pick(){{/crossLink}}.
|
3
|
+
|
4
|
+
The event parameters will be the hit result returned by the {@link Scene/pick:method"}}Scene#pick(){{/crossLink}} method.
|
5
|
+
@event picked
|
6
|
+
*/
|
7
|
+
import {math} from '../math/math.js';
|
8
|
+
import {Component} from '../Component.js';
|
9
|
+
import {RenderState} from '../webgl/RenderState.js';
|
10
|
+
import {DrawRenderer} from "./draw/DrawRenderer.js";
|
11
|
+
import {EmphasisFillRenderer} from "./emphasis/EmphasisFillRenderer.js";
|
12
|
+
import {EmphasisEdgesRenderer} from "./emphasis/EmphasisEdgesRenderer.js";
|
13
|
+
import {PickMeshRenderer} from "./pick/PickMeshRenderer.js";
|
14
|
+
import {PickTriangleRenderer} from "./pick/PickTriangleRenderer.js";
|
15
|
+
import {OcclusionRenderer} from "./occlusion/OcclusionRenderer.js";
|
16
|
+
import {ShadowRenderer} from "./shadow/ShadowRenderer.js";
|
17
|
+
|
18
|
+
import {geometryCompressionUtils} from '../math/geometryCompressionUtils.js';
|
19
|
+
import {RenderFlags} from "../webgl/RenderFlags.js";
|
20
|
+
|
21
|
+
const obb = math.OBB3();
|
22
|
+
const angleAxis = math.vec4();
|
23
|
+
const q1 = math.vec4();
|
24
|
+
const q2 = math.vec4();
|
25
|
+
const xAxis = math.vec3([1, 0, 0]);
|
26
|
+
const yAxis = math.vec3([0, 1, 0]);
|
27
|
+
const zAxis = math.vec3([0, 0, 1]);
|
28
|
+
|
29
|
+
const veca = math.vec3(3);
|
30
|
+
const vecb = math.vec3(3);
|
31
|
+
|
32
|
+
const identityMat = math.identityMat4();
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @desc An {@link Entity} that is a drawable element, with a {@link Geometry} and a {@link Material}, that can be
|
36
|
+
* connected into a scene graph using {@link Node}s.
|
37
|
+
*
|
38
|
+
* ## Usage
|
39
|
+
*
|
40
|
+
* The example below is the same as the one given for {@link Node}, since the two classes work together. In this example,
|
41
|
+
* we'll create a scene graph in which a root {@link Node} represents a group and the Meshes are leaves.
|
42
|
+
*
|
43
|
+
* Since {@link Node} implements {@link Entity}, we can designate the root {@link Node} as a model, causing it to be registered by its
|
44
|
+
* ID in {@link Scene#models}.
|
45
|
+
*
|
46
|
+
* Since Mesh also implements {@link Entity}, we can designate the leaf Meshes as objects, causing them to
|
47
|
+
* be registered by their IDs in {@link Scene#objects}.
|
48
|
+
*
|
49
|
+
* We can then find those {@link Entity} types in {@link Scene#models} and {@link Scene#objects}.
|
50
|
+
*
|
51
|
+
* We can also update properties of our object-Meshes via calls to {@link Scene#setObjectsHighlighted} etc.
|
52
|
+
*
|
53
|
+
* [[Run this example](http://yjkkit.github.io/yjkkit-sdk/examples/#sceneRepresentation_SceneGraph)]
|
54
|
+
*
|
55
|
+
* ````javascript
|
56
|
+
* import {Viewer, Mesh, Node, PhongMaterial, buildBoxGeometry, ReadableGeometry} from "yjkkit-sdk.es.js";
|
57
|
+
*
|
58
|
+
* const viewer = new Viewer({
|
59
|
+
* canvasId: "myCanvas"
|
60
|
+
* });
|
61
|
+
*
|
62
|
+
* viewer.scene.camera.eye = [-21.80, 4.01, 6.56];
|
63
|
+
* viewer.scene.camera.look = [0, -5.75, 0];
|
64
|
+
* viewer.scene.camera.up = [0.37, 0.91, -0.11];
|
65
|
+
*
|
66
|
+
* const boxGeometry = new ReadableGeometry(viewer.scene, buildBoxGeometry({
|
67
|
+
* xSize: 1,
|
68
|
+
* ySize: 1,
|
69
|
+
* zSize: 1
|
70
|
+
* }));
|
71
|
+
*
|
72
|
+
* new Node(viewer.scene, {
|
73
|
+
* id: "table",
|
74
|
+
* isModel: true, // <---------- Node represents a model, so is registered by ID in viewer.scene.models
|
75
|
+
* rotation: [0, 50, 0],
|
76
|
+
* position: [0, 0, 0],
|
77
|
+
* scale: [1, 1, 1],
|
78
|
+
*
|
79
|
+
* children: [
|
80
|
+
*
|
81
|
+
* new Mesh(viewer.scene, { // Red table leg
|
82
|
+
* id: "redLeg",
|
83
|
+
* isObject: true, // <------ Node represents an object, so is registered by ID in viewer.scene.objects
|
84
|
+
* position: [-4, -6, -4],
|
85
|
+
* scale: [1, 3, 1],
|
86
|
+
* rotation: [0, 0, 0],
|
87
|
+
* material: new PhongMaterial(viewer.scene, {
|
88
|
+
* diffuse: [1, 0.3, 0.3]
|
89
|
+
* }),
|
90
|
+
* geometry: boxGeometry
|
91
|
+
* }),
|
92
|
+
*
|
93
|
+
* new Mesh(viewer.scene, { // Green table leg
|
94
|
+
* id: "greenLeg",
|
95
|
+
* isObject: true, // <------ Node represents an object, so is registered by ID in viewer.scene.objects
|
96
|
+
* position: [4, -6, -4],
|
97
|
+
* scale: [1, 3, 1],
|
98
|
+
* rotation: [0, 0, 0],
|
99
|
+
* material: new PhongMaterial(viewer.scene, {
|
100
|
+
* diffuse: [0.3, 1.0, 0.3]
|
101
|
+
* }),
|
102
|
+
* geometry: boxGeometry
|
103
|
+
* }),
|
104
|
+
*
|
105
|
+
* new Mesh(viewer.scene, {// Blue table leg
|
106
|
+
* id: "blueLeg",
|
107
|
+
* isObject: true, // <------ Node represents an object, so is registered by ID in viewer.scene.objects
|
108
|
+
* position: [4, -6, 4],
|
109
|
+
* scale: [1, 3, 1],
|
110
|
+
* rotation: [0, 0, 0],
|
111
|
+
* material: new PhongMaterial(viewer.scene, {
|
112
|
+
* diffuse: [0.3, 0.3, 1.0]
|
113
|
+
* }),
|
114
|
+
* geometry: boxGeometry
|
115
|
+
* }),
|
116
|
+
*
|
117
|
+
* new Mesh(viewer.scene, { // Yellow table leg
|
118
|
+
* id: "yellowLeg",
|
119
|
+
* isObject: true, // <------ Node represents an object, so is registered by ID in viewer.scene.objects
|
120
|
+
* position: [-4, -6, 4],
|
121
|
+
* scale: [1, 3, 1],
|
122
|
+
* rotation: [0, 0, 0],
|
123
|
+
* material: new PhongMaterial(viewer.scene, {
|
124
|
+
* diffuse: [1.0, 1.0, 0.0]
|
125
|
+
* }),
|
126
|
+
* geometry: boxGeometry
|
127
|
+
* }),
|
128
|
+
*
|
129
|
+
* new Mesh(viewer.scene, { // Purple table top
|
130
|
+
* id: "tableTop",
|
131
|
+
* isObject: true, // <------ Node represents an object, so is registered by ID in viewer.scene.objects
|
132
|
+
* position: [0, -3, 0],
|
133
|
+
* scale: [6, 0.5, 6],
|
134
|
+
* rotation: [0, 0, 0],
|
135
|
+
* material: new PhongMaterial(viewer.scene, {
|
136
|
+
* diffuse: [1.0, 0.3, 1.0]
|
137
|
+
* }),
|
138
|
+
* geometry: boxGeometry
|
139
|
+
* })
|
140
|
+
* ]
|
141
|
+
* });
|
142
|
+
*
|
143
|
+
* // Find Nodes and Meshes by their IDs
|
144
|
+
*
|
145
|
+
* var table = viewer.scene.models["table"]; // Since table Node has isModel == true
|
146
|
+
*
|
147
|
+
* var redLeg = viewer.scene.objects["redLeg"]; // Since the Meshes have isObject == true
|
148
|
+
* var greenLeg = viewer.scene.objects["greenLeg"];
|
149
|
+
* var blueLeg = viewer.scene.objects["blueLeg"];
|
150
|
+
*
|
151
|
+
* // Highlight one of the table leg Meshes
|
152
|
+
*
|
153
|
+
* viewer.scene.setObjectsHighlighted(["redLeg"], true); // Since the Meshes have isObject == true
|
154
|
+
*
|
155
|
+
* // Periodically update transforms on our Nodes and Meshes
|
156
|
+
*
|
157
|
+
* viewer.scene.on("tick", function () {
|
158
|
+
*
|
159
|
+
* // Rotate legs
|
160
|
+
* redLeg.rotateY(0.5);
|
161
|
+
* greenLeg.rotateY(0.5);
|
162
|
+
* blueLeg.rotateY(0.5);
|
163
|
+
*
|
164
|
+
* // Rotate table
|
165
|
+
* table.rotateY(0.5);
|
166
|
+
* table.rotateX(0.3);
|
167
|
+
* });
|
168
|
+
* ````
|
169
|
+
*
|
170
|
+
* ## Metadata
|
171
|
+
*
|
172
|
+
* As mentioned, we can also associate {@link MetaModel}s and {@link MetaObject}s with our {@link Node}s and Meshes,
|
173
|
+
* within a {@link MetaScene}. See {@link MetaScene} for an example.
|
174
|
+
*
|
175
|
+
* @implements {Entity}
|
176
|
+
* @implements {Drawable}
|
177
|
+
*/
|
178
|
+
class Mesh extends Component {
|
179
|
+
|
180
|
+
/**
|
181
|
+
@private
|
182
|
+
*/
|
183
|
+
get type() {
|
184
|
+
return "Mesh";
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* @constructor
|
189
|
+
* @param {Component} owner Owner component. When destroyed, the owner will destroy this component as well.
|
190
|
+
* @param {*} [cfg] Configs
|
191
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent scene, generated automatically when omitted.
|
192
|
+
* @param {String} [cfg.originalSystemId] ID of the corresponding object within the originating system, if any.
|
193
|
+
* @param {Boolean} [cfg.isModel] Specify ````true```` if this Mesh represents a model, in which case the Mesh will be registered by {@link Mesh#id} in {@link Scene#models} and may also have a corresponding {@link MetaModel} with matching {@link MetaModel#id}, registered by that ID in {@link MetaScene#metaModels}.
|
194
|
+
* @param {Boolean} [cfg.isObject] Specify ````true```` if this Mesh represents an object, in which case the Mesh will be registered by {@link Mesh#id} in {@link Scene#objects} and may also have a corresponding {@link MetaObject} with matching {@link MetaObject#id}, registered by that ID in {@link MetaScene#metaObjects}.
|
195
|
+
* @param {Node} [cfg.parent] The parent Node.
|
196
|
+
* @param {Number[]} [cfg.rtcCenter] Relative-to-center (RTC) coordinate system center for this Mesh. When this is given, then ````matrix````, ````position```` and ````geometry```` are all assumed to be relative to this center.
|
197
|
+
* @param {Number[]} [cfg.position=[0,0,0]] Local 3D position.
|
198
|
+
* @param {Number[]} [cfg.scale=[1,1,1]] Local scale.
|
199
|
+
* @param {Number[]} [cfg.rotation=[0,0,0]] Local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
|
200
|
+
* @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Local modelling transform matrix. Overrides the position, scale and rotation parameters.
|
201
|
+
* @param {Number[]} [cfg.offset=[0,0,0]] World-space 3D translation offset. Translates the Mesh in World space, after modelling transforms.
|
202
|
+
* @param {Boolean} [cfg.visible=true] Indicates if the Mesh is initially visible.
|
203
|
+
* @param {Boolean} [cfg.culled=false] Indicates if the Mesh is initially culled from view.
|
204
|
+
* @param {Boolean} [cfg.pickable=true] Indicates if the Mesh is initially pickable.
|
205
|
+
* @param {Boolean} [cfg.clippable=true] Indicates if the Mesh is initially clippable.
|
206
|
+
* @param {Boolean} [cfg.collidable=true] Indicates if the Mesh is initially included in boundary calculations.
|
207
|
+
* @param {Boolean} [cfg.castsShadow=true] Indicates if the Mesh initially casts shadows.
|
208
|
+
* @param {Boolean} [cfg.receivesShadow=true] Indicates if the Mesh initially receives shadows.
|
209
|
+
* @param {Boolean} [cfg.xrayed=false] Indicates if the Mesh is initially xrayed.
|
210
|
+
* @param {Boolean} [cfg.highlighted=false] Indicates if the Mesh is initially highlighted.
|
211
|
+
* @param {Boolean} [cfg.selected=false] Indicates if the Mesh is initially selected.
|
212
|
+
* @param {Boolean} [cfg.edges=false] Indicates if the Mesh's edges are initially emphasized.
|
213
|
+
* @param {Number[]} [cfg.colorize=[1.0,1.0,1.0]] Mesh's initial RGB colorize color, multiplies by the rendered fragment colors.
|
214
|
+
* @param {Number} [cfg.opacity=1.0] Mesh's initial opacity factor, multiplies by the rendered fragment alpha.
|
215
|
+
* @param {String} [cfg.billboard="none"] Mesh's billboarding behaviour. Options are "none" for no billboarding, "spherical" to always directly face {@link Camera.eye}, rotating both vertically and horizontally, or "cylindrical" to face the {@link Camera#eye} while rotating only about its vertically axis (use that mode for things like trees on a landscape).
|
216
|
+
* @param {Geometry} [cfg.geometry] {@link Geometry} to define the shape of this Mesh. Inherits {@link Scene#geometry} by default.
|
217
|
+
* @param {Material} [cfg.material] {@link Material} to define the normal rendered appearance for this Mesh. Inherits {@link Scene#material} by default.
|
218
|
+
* @param {EmphasisMaterial} [cfg.xrayMaterial] {@link EmphasisMaterial} to define the xrayed appearance for this Mesh. Inherits {@link Scene#xrayMaterial} by default.
|
219
|
+
* @param {EmphasisMaterial} [cfg.highlightMaterial] {@link EmphasisMaterial} to define the xrayed appearance for this Mesh. Inherits {@link Scene#highlightMaterial} by default.
|
220
|
+
* @param {EmphasisMaterial} [cfg.selectedMaterial] {@link EmphasisMaterial} to define the selected appearance for this Mesh. Inherits {@link Scene#selectedMaterial} by default.
|
221
|
+
* @param {EmphasisMaterial} [cfg.edgeMaterial] {@link EdgeMaterial} to define the appearance of enhanced edges for this Mesh. Inherits {@link Scene#edgeMaterial} by default.
|
222
|
+
*/
|
223
|
+
constructor(owner, cfg = {}) {
|
224
|
+
|
225
|
+
super(owner, cfg);
|
226
|
+
|
227
|
+
/**
|
228
|
+
* ID of the corresponding object within the originating system, if any.
|
229
|
+
*
|
230
|
+
* @type {String}
|
231
|
+
* @abstract
|
232
|
+
*/
|
233
|
+
this.originalSystemId = (cfg.originalSystemId || this.id);
|
234
|
+
|
235
|
+
/** @private **/
|
236
|
+
this.renderFlags = new RenderFlags();
|
237
|
+
|
238
|
+
this._state = new RenderState({ // NOTE: Renderer gets modeling and normal matrices from Mesh#matrix and Mesh.#normalWorldMatrix
|
239
|
+
visible: true,
|
240
|
+
culled: false,
|
241
|
+
pickable: null,
|
242
|
+
clippable: null,
|
243
|
+
collidable: null,
|
244
|
+
castsShadow: null,
|
245
|
+
receivesShadow: null,
|
246
|
+
xrayed: false,
|
247
|
+
highlighted: false,
|
248
|
+
selected: false,
|
249
|
+
edges: false,
|
250
|
+
stationary: !!cfg.stationary,
|
251
|
+
billboard: this._checkBillboard(cfg.billboard),
|
252
|
+
layer: null,
|
253
|
+
colorize: null,
|
254
|
+
pickID: this.scene._renderer.getPickID(this),
|
255
|
+
drawHash: "",
|
256
|
+
pickHash: "",
|
257
|
+
offset: math.vec3(),
|
258
|
+
rtcCenter: null,
|
259
|
+
rtcCenterHash: null
|
260
|
+
});
|
261
|
+
|
262
|
+
this._drawRenderer = null;
|
263
|
+
this._shadowRenderer = null;
|
264
|
+
this._emphasisFillRenderer = null;
|
265
|
+
this._emphasisEdgesRenderer = null;
|
266
|
+
this._pickMeshRenderer = null;
|
267
|
+
this._pickTriangleRenderer = null;
|
268
|
+
this._occlusionRenderer = null;
|
269
|
+
|
270
|
+
this._geometry = cfg.geometry ? this._checkComponent2(["ReadableGeometry", "VBOGeometry"], cfg.geometry) : this.scene.geometry;
|
271
|
+
this._material = cfg.material ? this._checkComponent2(["PhongMaterial", "MetallicMaterial", "SpecularMaterial", "LambertMaterial"], cfg.material) : this.scene.material;
|
272
|
+
this._xrayMaterial = cfg.xrayMaterial ? this._checkComponent("EmphasisMaterial", cfg.xrayMaterial) : this.scene.xrayMaterial;
|
273
|
+
this._highlightMaterial = cfg.highlightMaterial ? this._checkComponent("EmphasisMaterial", cfg.highlightMaterial) : this.scene.highlightMaterial;
|
274
|
+
this._selectedMaterial = cfg.selectedMaterial ? this._checkComponent("EmphasisMaterial", cfg.selectedMaterial) : this.scene.selectedMaterial;
|
275
|
+
this._edgeMaterial = cfg.edgeMaterial ? this._checkComponent("EdgeMaterial", cfg.edgeMaterial) : this.scene.edgeMaterial;
|
276
|
+
|
277
|
+
this._parentNode = null;
|
278
|
+
|
279
|
+
this._aabb = null;
|
280
|
+
this._aabbDirty = true;
|
281
|
+
|
282
|
+
this._numTriangles = (this._geometry ? this._geometry.numTriangles : 0);
|
283
|
+
|
284
|
+
this.scene._aabbDirty = true;
|
285
|
+
|
286
|
+
this._scale = math.vec3();
|
287
|
+
this._quaternion = math.identityQuaternion();
|
288
|
+
this._rotation = math.vec3();
|
289
|
+
this._position = math.vec3();
|
290
|
+
|
291
|
+
this._worldMatrix = math.identityMat4();
|
292
|
+
this._worldNormalMatrix = math.identityMat4();
|
293
|
+
|
294
|
+
this._localMatrixDirty = true;
|
295
|
+
this._worldMatrixDirty = true;
|
296
|
+
this._worldNormalMatrixDirty = true;
|
297
|
+
|
298
|
+
if (cfg.rtcCenter) {
|
299
|
+
this._state.rtcCenter = math.vec3(cfg.rtcCenter);
|
300
|
+
this._state.rtcCenterHash = cfg.rtcCenter.join();
|
301
|
+
}
|
302
|
+
|
303
|
+
if (cfg.matrix) {
|
304
|
+
this.matrix = cfg.matrix;
|
305
|
+
} else {
|
306
|
+
this.scale = cfg.scale;
|
307
|
+
this.position = cfg.position;
|
308
|
+
if (cfg.quaternion) {
|
309
|
+
} else {
|
310
|
+
this.rotation = cfg.rotation;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
this._isObject = cfg.isObject;
|
315
|
+
if (this._isObject) {
|
316
|
+
this.scene._registerObject(this);
|
317
|
+
}
|
318
|
+
|
319
|
+
this._isModel = cfg.isModel;
|
320
|
+
if (this._isModel) {
|
321
|
+
this.scene._registerModel(this);
|
322
|
+
}
|
323
|
+
|
324
|
+
this.visible = cfg.visible;
|
325
|
+
this.culled = cfg.culled;
|
326
|
+
this.pickable = cfg.pickable;
|
327
|
+
this.clippable = cfg.clippable;
|
328
|
+
this.collidable = cfg.collidable;
|
329
|
+
this.castsShadow = cfg.castsShadow;
|
330
|
+
this.receivesShadow = cfg.receivesShadow;
|
331
|
+
this.xrayed = cfg.xrayed;
|
332
|
+
this.highlighted = cfg.highlighted;
|
333
|
+
this.selected = cfg.selected;
|
334
|
+
this.edges = cfg.edges;
|
335
|
+
this.layer = cfg.layer;
|
336
|
+
this.colorize = cfg.colorize;
|
337
|
+
this.opacity = cfg.opacity;
|
338
|
+
this.offset = cfg.offset;
|
339
|
+
|
340
|
+
if (cfg.parentId) {
|
341
|
+
const parentNode = this.scene.components[cfg.parentId];
|
342
|
+
if (!parentNode) {
|
343
|
+
this.error("Parent not found: '" + cfg.parentId + "'");
|
344
|
+
} else if (!parentNode.isNode) {
|
345
|
+
this.error("Parent is not a Node: '" + cfg.parentId + "'");
|
346
|
+
} else {
|
347
|
+
parentNode.addChild(this);
|
348
|
+
}
|
349
|
+
this._parentNode = parentNode;
|
350
|
+
} else if (cfg.parent) {
|
351
|
+
if (!cfg.parent.isNode) {
|
352
|
+
this.error("Parent is not a Node");
|
353
|
+
}
|
354
|
+
cfg.parent.addChild(this);
|
355
|
+
this._parentNode = cfg.parent;
|
356
|
+
}
|
357
|
+
|
358
|
+
this.compile();
|
359
|
+
}
|
360
|
+
|
361
|
+
//------------------------------------------------------------------------------------------------------------------
|
362
|
+
// Mesh members
|
363
|
+
//------------------------------------------------------------------------------------------------------------------
|
364
|
+
|
365
|
+
/**
|
366
|
+
* Returns true to indicate that this Component is a Mesh.
|
367
|
+
* @final
|
368
|
+
* @type {Boolean}
|
369
|
+
*/
|
370
|
+
get isMesh() {
|
371
|
+
return true;
|
372
|
+
}
|
373
|
+
|
374
|
+
/**
|
375
|
+
* The parent Node.
|
376
|
+
*
|
377
|
+
* The parent Node may also be set by passing the Mesh to the parent's {@link Node#addChild} method.
|
378
|
+
*
|
379
|
+
* @type {Node}
|
380
|
+
*/
|
381
|
+
get parent() {
|
382
|
+
return this._parentNode;
|
383
|
+
}
|
384
|
+
|
385
|
+
_checkBillboard(value) {
|
386
|
+
value = value || "none";
|
387
|
+
if (value !== "spherical" && value !== "cylindrical" && value !== "none") {
|
388
|
+
this.error("Unsupported value for 'billboard': " + value + " - accepted values are " +
|
389
|
+
"'spherical', 'cylindrical' and 'none' - defaulting to 'none'.");
|
390
|
+
value = "none";
|
391
|
+
}
|
392
|
+
return value;
|
393
|
+
}
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Called by yjkkit to compile shaders for this Mesh.
|
397
|
+
* @private
|
398
|
+
*/
|
399
|
+
compile() {
|
400
|
+
const drawHash = this._makeDrawHash();
|
401
|
+
if (this._state.drawHash !== drawHash) {
|
402
|
+
this._state.drawHash = drawHash;
|
403
|
+
this._putDrawRenderers();
|
404
|
+
this._drawRenderer = DrawRenderer.get(this);
|
405
|
+
// this._shadowRenderer = ShadowRenderer.get(this);
|
406
|
+
this._emphasisFillRenderer = EmphasisFillRenderer.get(this);
|
407
|
+
this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this);
|
408
|
+
}
|
409
|
+
const pickHash = this._makePickHash();
|
410
|
+
if (this._state.pickHash !== pickHash) {
|
411
|
+
this._state.pickHash = pickHash;
|
412
|
+
this._putPickRenderers();
|
413
|
+
this._pickMeshRenderer = PickMeshRenderer.get(this);
|
414
|
+
}
|
415
|
+
const occlusionHash = this._makeOcclusionHash();
|
416
|
+
if (this._state.occlusionHash !== occlusionHash) {
|
417
|
+
this._state.occlusionHash = occlusionHash;
|
418
|
+
this._putOcclusionRenderer();
|
419
|
+
this._occlusionRenderer = OcclusionRenderer.get(this);
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
_setLocalMatrixDirty() {
|
424
|
+
this._localMatrixDirty = true;
|
425
|
+
this._setWorldMatrixDirty();
|
426
|
+
}
|
427
|
+
|
428
|
+
_setWorldMatrixDirty() {
|
429
|
+
this._worldMatrixDirty = true;
|
430
|
+
this._worldNormalMatrixDirty = true;
|
431
|
+
}
|
432
|
+
|
433
|
+
_buildWorldMatrix() {
|
434
|
+
const localMatrix = this.matrix;
|
435
|
+
if (!this._parentNode) {
|
436
|
+
for (let i = 0, len = localMatrix.length; i < len; i++) {
|
437
|
+
this._worldMatrix[i] = localMatrix[i];
|
438
|
+
}
|
439
|
+
} else {
|
440
|
+
math.mulMat4(this._parentNode.worldMatrix, localMatrix, this._worldMatrix);
|
441
|
+
}
|
442
|
+
this._worldMatrixDirty = false;
|
443
|
+
}
|
444
|
+
|
445
|
+
_buildWorldNormalMatrix() {
|
446
|
+
if (this._worldMatrixDirty) {
|
447
|
+
this._buildWorldMatrix();
|
448
|
+
}
|
449
|
+
if (!this._worldNormalMatrix) {
|
450
|
+
this._worldNormalMatrix = math.mat4();
|
451
|
+
}
|
452
|
+
// Note: order of inverse and transpose doesn't matter
|
453
|
+
math.transposeMat4(this._worldMatrix, this._worldNormalMatrix);
|
454
|
+
math.inverseMat4(this._worldNormalMatrix);
|
455
|
+
this._worldNormalMatrixDirty = false;
|
456
|
+
}
|
457
|
+
|
458
|
+
_setAABBDirty() {
|
459
|
+
if (this.collidable) {
|
460
|
+
for (let node = this; node; node = node._parentNode) {
|
461
|
+
node._aabbDirty = true;
|
462
|
+
}
|
463
|
+
}
|
464
|
+
}
|
465
|
+
|
466
|
+
_updateAABB() {
|
467
|
+
this.scene._aabbDirty = true;
|
468
|
+
if (!this._aabb) {
|
469
|
+
this._aabb = math.AABB3();
|
470
|
+
}
|
471
|
+
this._buildAABB(this.worldMatrix, this._aabb); // Mesh or PerformanceModel
|
472
|
+
this._aabbDirty = false;
|
473
|
+
}
|
474
|
+
|
475
|
+
_webglContextRestored() {
|
476
|
+
if (this._drawRenderer) {
|
477
|
+
this._drawRenderer.webglContextRestored();
|
478
|
+
}
|
479
|
+
if (this._shadowRenderer) {
|
480
|
+
this._shadowRenderer.webglContextRestored();
|
481
|
+
}
|
482
|
+
if (this._emphasisFillRenderer) {
|
483
|
+
this._emphasisFillRenderer.webglContextRestored();
|
484
|
+
}
|
485
|
+
if (this._emphasisEdgesRenderer) {
|
486
|
+
this._emphasisEdgesRenderer.webglContextRestored();
|
487
|
+
}
|
488
|
+
if (this._pickMeshRenderer) {
|
489
|
+
this._pickMeshRenderer.webglContextRestored();
|
490
|
+
}
|
491
|
+
if (this._pickTriangleRenderer) {
|
492
|
+
this._pickMeshRenderer.webglContextRestored();
|
493
|
+
}
|
494
|
+
if (this._occlusionRenderer) {
|
495
|
+
this._occlusionRenderer.webglContextRestored();
|
496
|
+
}
|
497
|
+
}
|
498
|
+
|
499
|
+
_makeDrawHash() {
|
500
|
+
const scene = this.scene;
|
501
|
+
const hash = [
|
502
|
+
scene.canvas.canvas.id,
|
503
|
+
(scene.gammaInput ? "gi;" : ";") + (scene.gammaOutput ? "go" : ""),
|
504
|
+
scene._lightsState.getHash(),
|
505
|
+
scene._sectionPlanesState.getHash()
|
506
|
+
];
|
507
|
+
const state = this._state;
|
508
|
+
if (state.stationary) {
|
509
|
+
hash.push("/s");
|
510
|
+
}
|
511
|
+
if (state.billboard === "none") {
|
512
|
+
hash.push("/n");
|
513
|
+
} else if (state.billboard === "spherical") {
|
514
|
+
hash.push("/s");
|
515
|
+
} else if (state.billboard === "cylindrical") {
|
516
|
+
hash.push("/c");
|
517
|
+
}
|
518
|
+
if (state.receivesShadow) {
|
519
|
+
hash.push("/rs");
|
520
|
+
}
|
521
|
+
hash.push(";");
|
522
|
+
return hash.join("");
|
523
|
+
}
|
524
|
+
|
525
|
+
_makePickHash() {
|
526
|
+
const scene = this.scene;
|
527
|
+
const hash = [
|
528
|
+
scene.canvas.canvas.id,
|
529
|
+
scene._sectionPlanesState.getHash()
|
530
|
+
];
|
531
|
+
const state = this._state;
|
532
|
+
if (state.stationary) {
|
533
|
+
hash.push("/s");
|
534
|
+
}
|
535
|
+
if (state.billboard === "none") {
|
536
|
+
hash.push("/n");
|
537
|
+
} else if (state.billboard === "spherical") {
|
538
|
+
hash.push("/s");
|
539
|
+
} else if (state.billboard === "cylindrical") {
|
540
|
+
hash.push("/c");
|
541
|
+
}
|
542
|
+
hash.push(";");
|
543
|
+
return hash.join("");
|
544
|
+
}
|
545
|
+
|
546
|
+
_makeOcclusionHash() {
|
547
|
+
const scene = this.scene;
|
548
|
+
const hash = [
|
549
|
+
scene.canvas.canvas.id,
|
550
|
+
scene._sectionPlanesState.getHash()
|
551
|
+
];
|
552
|
+
const state = this._state;
|
553
|
+
if (state.stationary) {
|
554
|
+
hash.push("/s");
|
555
|
+
}
|
556
|
+
if (state.billboard === "none") {
|
557
|
+
hash.push("/n");
|
558
|
+
} else if (state.billboard === "spherical") {
|
559
|
+
hash.push("/s");
|
560
|
+
} else if (state.billboard === "cylindrical") {
|
561
|
+
hash.push("/c");
|
562
|
+
}
|
563
|
+
hash.push(";");
|
564
|
+
return hash.join("");
|
565
|
+
}
|
566
|
+
|
567
|
+
_buildAABB(worldMatrix, aabb) {
|
568
|
+
|
569
|
+
math.transformOBB3(worldMatrix, this._geometry.obb, obb);
|
570
|
+
math.OBB3ToAABB3(obb, aabb);
|
571
|
+
|
572
|
+
const offset = this._state.offset;
|
573
|
+
|
574
|
+
aabb[0] += offset[0];
|
575
|
+
aabb[1] += offset[1];
|
576
|
+
aabb[2] += offset[2];
|
577
|
+
aabb[3] += offset[0];
|
578
|
+
aabb[4] += offset[1];
|
579
|
+
aabb[5] += offset[2];
|
580
|
+
|
581
|
+
if (this._state.rtcCenter) {
|
582
|
+
const rtcCenter = this._state.rtcCenter;
|
583
|
+
aabb[0] += rtcCenter[0];
|
584
|
+
aabb[1] += rtcCenter[1];
|
585
|
+
aabb[2] += rtcCenter[2];
|
586
|
+
aabb[3] += rtcCenter[0];
|
587
|
+
aabb[4] += rtcCenter[1];
|
588
|
+
aabb[5] += rtcCenter[2];
|
589
|
+
}
|
590
|
+
}
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Defines the shape of this Mesh.
|
594
|
+
*
|
595
|
+
* Set to {@link Scene#geometry} by default.
|
596
|
+
*
|
597
|
+
* @type {Geometry}
|
598
|
+
*/
|
599
|
+
get geometry() {
|
600
|
+
return this._geometry;
|
601
|
+
}
|
602
|
+
|
603
|
+
/**
|
604
|
+
* Defines the appearance of this Mesh when rendering normally, ie. when not xrayed, highlighted or selected.
|
605
|
+
*
|
606
|
+
* Set to {@link Scene#material} by default.
|
607
|
+
*
|
608
|
+
* @type {Material}
|
609
|
+
*/
|
610
|
+
get material() {
|
611
|
+
return this._material;
|
612
|
+
}
|
613
|
+
|
614
|
+
/**
|
615
|
+
* Sets the Mesh's local translation.
|
616
|
+
*
|
617
|
+
* Default value is ````[0,0,0]````.
|
618
|
+
*
|
619
|
+
* @type {Number[]}
|
620
|
+
*/
|
621
|
+
set position(value) {
|
622
|
+
this._position.set(value || [0, 0, 0]);
|
623
|
+
this._setLocalMatrixDirty();
|
624
|
+
this._setAABBDirty();
|
625
|
+
this.glRedraw();
|
626
|
+
}
|
627
|
+
|
628
|
+
/**
|
629
|
+
* Gets the Mesh's local translation.
|
630
|
+
*
|
631
|
+
* Default value is ````[0,0,0]````.
|
632
|
+
*
|
633
|
+
* @type {Number[]}
|
634
|
+
*/
|
635
|
+
get position() {
|
636
|
+
return this._position;
|
637
|
+
}
|
638
|
+
|
639
|
+
/**
|
640
|
+
* Sets the Mesh's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
|
641
|
+
*
|
642
|
+
* Default value is ````[0,0,0]````.
|
643
|
+
*
|
644
|
+
* @type {Number[]}
|
645
|
+
*/
|
646
|
+
set rotation(value) {
|
647
|
+
this._rotation.set(value || [0, 0, 0]);
|
648
|
+
math.eulerToQuaternion(this._rotation, "XYZ", this._quaternion);
|
649
|
+
this._setLocalMatrixDirty();
|
650
|
+
this._setAABBDirty();
|
651
|
+
this.glRedraw();
|
652
|
+
}
|
653
|
+
|
654
|
+
/**
|
655
|
+
* Gets the Mesh's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
|
656
|
+
*
|
657
|
+
* Default value is ````[0,0,0]````.
|
658
|
+
*
|
659
|
+
* @type {Number[]}
|
660
|
+
*/
|
661
|
+
get rotation() {
|
662
|
+
return this._rotation;
|
663
|
+
}
|
664
|
+
|
665
|
+
/**
|
666
|
+
* Sets the Mesh's local rotation quaternion.
|
667
|
+
*
|
668
|
+
* Default value is ````[0,0,0,1]````.
|
669
|
+
*
|
670
|
+
* @type {Number[]}
|
671
|
+
*/
|
672
|
+
set quaternion(value) {
|
673
|
+
this._quaternion.set(value || [0, 0, 0, 1]);
|
674
|
+
math.quaternionToEuler(this._quaternion, "XYZ", this._rotation);
|
675
|
+
this._setLocalMatrixDirty();
|
676
|
+
this._setAABBDirty();
|
677
|
+
this.glRedraw();
|
678
|
+
}
|
679
|
+
|
680
|
+
/**
|
681
|
+
* Gets the Mesh's local rotation quaternion.
|
682
|
+
*
|
683
|
+
* Default value is ````[0,0,0,1]````.
|
684
|
+
*
|
685
|
+
* @type {Number[]}
|
686
|
+
*/
|
687
|
+
get quaternion() {
|
688
|
+
return this._quaternion;
|
689
|
+
}
|
690
|
+
|
691
|
+
/**
|
692
|
+
* Sets the Mesh's local scale.
|
693
|
+
*
|
694
|
+
* Default value is ````[1,1,1]````.
|
695
|
+
*
|
696
|
+
* @type {Number[]}
|
697
|
+
*/
|
698
|
+
set scale(value) {
|
699
|
+
this._scale.set(value || [1, 1, 1]);
|
700
|
+
this._setLocalMatrixDirty();
|
701
|
+
this._setAABBDirty();
|
702
|
+
this.glRedraw();
|
703
|
+
}
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Gets the Mesh's local scale.
|
707
|
+
*
|
708
|
+
* Default value is ````[1,1,1]````.
|
709
|
+
*
|
710
|
+
* @type {Number[]}
|
711
|
+
*/
|
712
|
+
get scale() {
|
713
|
+
return this._scale;
|
714
|
+
}
|
715
|
+
|
716
|
+
/**
|
717
|
+
* Sets the Mesh's local modeling transform matrix.
|
718
|
+
*
|
719
|
+
* Default value is ````[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]````.
|
720
|
+
*
|
721
|
+
* @type {Number[]}
|
722
|
+
*/
|
723
|
+
set matrix(value) {
|
724
|
+
if (!this.__localMatrix) {
|
725
|
+
this.__localMatrix = math.identityMat4();
|
726
|
+
}
|
727
|
+
this.__localMatrix.set(value || identityMat);
|
728
|
+
math.decomposeMat4(this.__localMatrix, this._position, this._quaternion, this._scale);
|
729
|
+
this._localMatrixDirty = false;
|
730
|
+
this._setWorldMatrixDirty();
|
731
|
+
this._setAABBDirty();
|
732
|
+
this.glRedraw();
|
733
|
+
}
|
734
|
+
|
735
|
+
/**
|
736
|
+
* Gets the Mesh's local modeling transform matrix.
|
737
|
+
*
|
738
|
+
* Default value is ````[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]````.
|
739
|
+
*
|
740
|
+
* @type {Number[]}
|
741
|
+
*/
|
742
|
+
get matrix() {
|
743
|
+
if (this._localMatrixDirty) {
|
744
|
+
if (!this.__localMatrix) {
|
745
|
+
this.__localMatrix = math.identityMat4();
|
746
|
+
}
|
747
|
+
math.composeMat4(this._position, this._quaternion, this._scale, this.__localMatrix);
|
748
|
+
this._localMatrixDirty = false;
|
749
|
+
}
|
750
|
+
return this.__localMatrix;
|
751
|
+
}
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Gets the Mesh's World matrix.
|
755
|
+
*
|
756
|
+
* @property worldMatrix
|
757
|
+
* @type {Number[]}
|
758
|
+
*/
|
759
|
+
get worldMatrix() {
|
760
|
+
if (this._worldMatrixDirty) {
|
761
|
+
this._buildWorldMatrix();
|
762
|
+
}
|
763
|
+
return this._worldMatrix;
|
764
|
+
}
|
765
|
+
|
766
|
+
/**
|
767
|
+
* Gets the Mesh's World normal matrix.
|
768
|
+
*
|
769
|
+
* @type {Number[]}
|
770
|
+
*/
|
771
|
+
get worldNormalMatrix() {
|
772
|
+
if (this._worldNormalMatrixDirty) {
|
773
|
+
this._buildWorldNormalMatrix();
|
774
|
+
}
|
775
|
+
return this._worldNormalMatrix;
|
776
|
+
}
|
777
|
+
|
778
|
+
/**
|
779
|
+
* Rotates the Mesh about the given local axis by the given increment.
|
780
|
+
*
|
781
|
+
* @param {Number[]} axis Local axis about which to rotate.
|
782
|
+
* @param {Number} angle Angle increment in degrees.
|
783
|
+
*/
|
784
|
+
rotate(axis, angle) {
|
785
|
+
angleAxis[0] = axis[0];
|
786
|
+
angleAxis[1] = axis[1];
|
787
|
+
angleAxis[2] = axis[2];
|
788
|
+
angleAxis[3] = angle * math.DEGTORAD;
|
789
|
+
math.angleAxisToQuaternion(angleAxis, q1);
|
790
|
+
math.mulQuaternions(this.quaternion, q1, q2);
|
791
|
+
this.quaternion = q2;
|
792
|
+
this._setLocalMatrixDirty();
|
793
|
+
this._setAABBDirty();
|
794
|
+
this.glRedraw();
|
795
|
+
return this;
|
796
|
+
}
|
797
|
+
|
798
|
+
/**
|
799
|
+
* Rotates the Mesh about the given World-space axis by the given increment.
|
800
|
+
*
|
801
|
+
* @param {Number[]} axis Local axis about which to rotate.
|
802
|
+
* @param {Number} angle Angle increment in degrees.
|
803
|
+
*/
|
804
|
+
rotateOnWorldAxis(axis, angle) {
|
805
|
+
angleAxis[0] = axis[0];
|
806
|
+
angleAxis[1] = axis[1];
|
807
|
+
angleAxis[2] = axis[2];
|
808
|
+
angleAxis[3] = angle * math.DEGTORAD;
|
809
|
+
math.angleAxisToQuaternion(angleAxis, q1);
|
810
|
+
math.mulQuaternions(q1, this.quaternion, q1);
|
811
|
+
//this.quaternion.premultiply(q1);
|
812
|
+
return this;
|
813
|
+
}
|
814
|
+
|
815
|
+
/**
|
816
|
+
* Rotates the Mesh about the local X-axis by the given increment.
|
817
|
+
*
|
818
|
+
* @param {Number} angle Angle increment in degrees.
|
819
|
+
*/
|
820
|
+
rotateX(angle) {
|
821
|
+
return this.rotate(xAxis, angle);
|
822
|
+
}
|
823
|
+
|
824
|
+
/**
|
825
|
+
* Rotates the Mesh about the local Y-axis by the given increment.
|
826
|
+
*
|
827
|
+
* @param {Number} angle Angle increment in degrees.
|
828
|
+
*/
|
829
|
+
rotateY(angle) {
|
830
|
+
return this.rotate(yAxis, angle);
|
831
|
+
}
|
832
|
+
|
833
|
+
/**
|
834
|
+
* Rotates the Mesh about the local Z-axis by the given increment.
|
835
|
+
*
|
836
|
+
* @param {Number} angle Angle increment in degrees.
|
837
|
+
*/
|
838
|
+
rotateZ(angle) {
|
839
|
+
return this.rotate(zAxis, angle);
|
840
|
+
}
|
841
|
+
|
842
|
+
/**
|
843
|
+
* Translates the Mesh along local space vector by the given increment.
|
844
|
+
*
|
845
|
+
* @param {Number[]} axis Normalized local space 3D vector along which to translate.
|
846
|
+
* @param {Number} distance Distance to translate along the vector.
|
847
|
+
*/
|
848
|
+
translate(axis, distance) {
|
849
|
+
math.vec3ApplyQuaternion(this.quaternion, axis, veca);
|
850
|
+
math.mulVec3Scalar(veca, distance, vecb);
|
851
|
+
math.addVec3(this.position, vecb, this.position);
|
852
|
+
this._setLocalMatrixDirty();
|
853
|
+
this._setAABBDirty();
|
854
|
+
this.glRedraw();
|
855
|
+
return this;
|
856
|
+
}
|
857
|
+
|
858
|
+
/**
|
859
|
+
* Translates the Mesh along the local X-axis by the given increment.
|
860
|
+
*
|
861
|
+
* @param {Number} distance Distance to translate along the X-axis.
|
862
|
+
*/
|
863
|
+
translateX(distance) {
|
864
|
+
return this.translate(xAxis, distance);
|
865
|
+
}
|
866
|
+
|
867
|
+
/**
|
868
|
+
* Translates the Mesh along the local Y-axis by the given increment.
|
869
|
+
*
|
870
|
+
* @param {Number} distance Distance to translate along the Y-axis.
|
871
|
+
*/
|
872
|
+
translateY(distance) {
|
873
|
+
return this.translate(yAxis, distance);
|
874
|
+
}
|
875
|
+
|
876
|
+
/**
|
877
|
+
* Translates the Mesh along the local Z-axis by the given increment.
|
878
|
+
*
|
879
|
+
* @param {Number} distance Distance to translate along the Z-axis.
|
880
|
+
*/
|
881
|
+
translateZ(distance) {
|
882
|
+
return this.translate(zAxis, distance);
|
883
|
+
}
|
884
|
+
|
885
|
+
_putDrawRenderers() {
|
886
|
+
if (this._drawRenderer) {
|
887
|
+
this._drawRenderer.put();
|
888
|
+
this._drawRenderer = null;
|
889
|
+
}
|
890
|
+
if (this._shadowRenderer) {
|
891
|
+
this._shadowRenderer.put();
|
892
|
+
this._shadowRenderer = null;
|
893
|
+
}
|
894
|
+
if (this._emphasisFillRenderer) {
|
895
|
+
this._emphasisFillRenderer.put();
|
896
|
+
this._emphasisFillRenderer = null;
|
897
|
+
}
|
898
|
+
if (this._emphasisEdgesRenderer) {
|
899
|
+
this._emphasisEdgesRenderer.put();
|
900
|
+
this._emphasisEdgesRenderer = null;
|
901
|
+
}
|
902
|
+
}
|
903
|
+
|
904
|
+
_putPickRenderers() {
|
905
|
+
if (this._pickMeshRenderer) {
|
906
|
+
this._pickMeshRenderer.put();
|
907
|
+
this._pickMeshRenderer = null;
|
908
|
+
}
|
909
|
+
if (this._pickTriangleRenderer) {
|
910
|
+
this._pickTriangleRenderer.put();
|
911
|
+
this._pickTriangleRenderer = null;
|
912
|
+
}
|
913
|
+
}
|
914
|
+
|
915
|
+
_putOcclusionRenderer() {
|
916
|
+
if (this._occlusionRenderer) {
|
917
|
+
this._occlusionRenderer.put();
|
918
|
+
this._occlusionRenderer = null;
|
919
|
+
}
|
920
|
+
}
|
921
|
+
|
922
|
+
//------------------------------------------------------------------------------------------------------------------
|
923
|
+
// Entity members
|
924
|
+
//------------------------------------------------------------------------------------------------------------------
|
925
|
+
|
926
|
+
/**
|
927
|
+
* Returns true to indicate that Mesh implements {@link Entity}.
|
928
|
+
*
|
929
|
+
* @returns {Boolean}
|
930
|
+
*/
|
931
|
+
get isEntity() {
|
932
|
+
return true;
|
933
|
+
}
|
934
|
+
|
935
|
+
/**
|
936
|
+
* Returns ````true```` if this Mesh represents a model.
|
937
|
+
*
|
938
|
+
* When this returns ````true````, the Mesh will be registered by {@link Mesh#id} in {@link Scene#models} and
|
939
|
+
* may also have a corresponding {@link MetaModel}.
|
940
|
+
*
|
941
|
+
* @type {Boolean}
|
942
|
+
*/
|
943
|
+
get isModel() {
|
944
|
+
return this._isModel;
|
945
|
+
}
|
946
|
+
|
947
|
+
/**
|
948
|
+
* Returns ````true```` if this Mesh represents an object.
|
949
|
+
*
|
950
|
+
* When this returns ````true````, the Mesh will be registered by {@link Mesh#id} in {@link Scene#objects} and
|
951
|
+
* may also have a corresponding {@link MetaObject}.
|
952
|
+
*
|
953
|
+
* @type {Boolean}
|
954
|
+
*/
|
955
|
+
get isObject() {
|
956
|
+
return this._isObject;
|
957
|
+
}
|
958
|
+
|
959
|
+
/**
|
960
|
+
* Gets the Mesh's World-space 3D axis-aligned bounding box.
|
961
|
+
*
|
962
|
+
* Represented by a six-element Float64Array containing the min/max extents of the
|
963
|
+
* axis-aligned volume, ie. ````[xmin, ymin,zmin,xmax,ymax, zmax]````.
|
964
|
+
*
|
965
|
+
* @type {Number[]}
|
966
|
+
*/
|
967
|
+
get aabb() {
|
968
|
+
if (this._aabbDirty) {
|
969
|
+
this._updateAABB();
|
970
|
+
}
|
971
|
+
return this._aabb;
|
972
|
+
}
|
973
|
+
|
974
|
+
/**
|
975
|
+
* Center of the relative-to-center (RTC) coordinate system for this Mesh.
|
976
|
+
*
|
977
|
+
* When this is given, then {@link Mesh#matrix}, {@link Mesh#position} and {@link Mesh#geometry} are all assumed to be relative to this center position.
|
978
|
+
*
|
979
|
+
* @type {Float64Array}
|
980
|
+
*/
|
981
|
+
set rtcCenter(rtcCenter) {
|
982
|
+
if (rtcCenter) {
|
983
|
+
if (!this._state.rtcCenter) {
|
984
|
+
this._state.rtcCenter = math.vec3();
|
985
|
+
}
|
986
|
+
this._state.rtcCenter.set(rtcCenter);
|
987
|
+
this._state.rtcCenterHash = rtcCenter.join();
|
988
|
+
this._setAABBDirty();
|
989
|
+
this.scene._aabbDirty = true;
|
990
|
+
} else {
|
991
|
+
if (this._state.rtcCenter) {
|
992
|
+
this._state.rtcCenter = null;
|
993
|
+
this._state.rtcCenterHash = null;
|
994
|
+
this._setAABBDirty();
|
995
|
+
this.scene._aabbDirty = true;
|
996
|
+
}
|
997
|
+
}
|
998
|
+
}
|
999
|
+
|
1000
|
+
/**
|
1001
|
+
* 3D origin of the Mesh's {@link Geometry}'s vertex positions.
|
1002
|
+
*
|
1003
|
+
* When this is defined, then the positions are RTC, which means that they are relative to this position.
|
1004
|
+
*
|
1005
|
+
* @type {Float64Array}
|
1006
|
+
*/
|
1007
|
+
get rtcCenter() {
|
1008
|
+
return this._state.rtcCenter;
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
/**
|
1012
|
+
* The approximate number of triangles in this Mesh.
|
1013
|
+
*
|
1014
|
+
* @type {Number}
|
1015
|
+
*/
|
1016
|
+
get numTriangles() {
|
1017
|
+
return this._numTriangles;
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
/**
|
1021
|
+
* Sets if this Mesh is visible.
|
1022
|
+
*
|
1023
|
+
* Only rendered when {@link Mesh#visible} is ````true```` and {@link Mesh#culled} is ````false````.
|
1024
|
+
*
|
1025
|
+
* When {@link Mesh#isObject} and {@link Mesh#visible} are both ````true```` the Mesh will be
|
1026
|
+
* registered by {@link Mesh#id} in {@link Scene#visibleObjects}.
|
1027
|
+
*
|
1028
|
+
* @type {Boolean}
|
1029
|
+
*/
|
1030
|
+
set visible(visible) {
|
1031
|
+
visible = visible !== false;
|
1032
|
+
this._state.visible = visible;
|
1033
|
+
if (this._isObject) {
|
1034
|
+
this.scene._objectVisibilityUpdated(this);
|
1035
|
+
}
|
1036
|
+
this.glRedraw();
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
/**
|
1040
|
+
* Gets if this Mesh is visible.
|
1041
|
+
*
|
1042
|
+
* Only rendered when {@link Mesh#visible} is ````true```` and {@link Mesh#culled} is ````false````.
|
1043
|
+
*
|
1044
|
+
* When {@link Mesh#isObject} and {@link Mesh#visible} are both ````true```` the Mesh will be
|
1045
|
+
* registered by {@link Mesh#id} in {@link Scene#visibleObjects}.
|
1046
|
+
*
|
1047
|
+
* @type {Boolean}
|
1048
|
+
*/
|
1049
|
+
get visible() {
|
1050
|
+
return this._state.visible;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
/**
|
1054
|
+
* Sets if this Mesh is xrayed.
|
1055
|
+
*
|
1056
|
+
* XRayed appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#xrayMaterial}.
|
1057
|
+
*
|
1058
|
+
* When {@link Mesh#isObject} and {@link Mesh#xrayed} are both ````true``` the Mesh will be
|
1059
|
+
* registered by {@link Mesh#id} in {@link Scene#xrayedObjects}.
|
1060
|
+
*
|
1061
|
+
* @type {Boolean}
|
1062
|
+
*/
|
1063
|
+
set xrayed(xrayed) {
|
1064
|
+
xrayed = !!xrayed;
|
1065
|
+
if (this._state.xrayed === xrayed) {
|
1066
|
+
return;
|
1067
|
+
}
|
1068
|
+
this._state.xrayed = xrayed;
|
1069
|
+
if (this._isObject) {
|
1070
|
+
this.scene._objectXRayedUpdated(this);
|
1071
|
+
}
|
1072
|
+
this.glRedraw();
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
/**
|
1076
|
+
* Gets if this Mesh is xrayed.
|
1077
|
+
*
|
1078
|
+
* XRayed appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#xrayMaterial}.
|
1079
|
+
*
|
1080
|
+
* When {@link Mesh#isObject} and {@link Mesh#xrayed} are both ````true``` the Mesh will be
|
1081
|
+
* registered by {@link Mesh#id} in {@link Scene#xrayedObjects}.
|
1082
|
+
*
|
1083
|
+
* @type {Boolean}
|
1084
|
+
*/
|
1085
|
+
get xrayed() {
|
1086
|
+
return this._state.xrayed;
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
/**
|
1090
|
+
* Sets if this Mesh is highlighted.
|
1091
|
+
*
|
1092
|
+
* Highlighted appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#highlightMaterial}.
|
1093
|
+
*
|
1094
|
+
* When {@link Mesh#isObject} and {@link Mesh#highlighted} are both ````true```` the Mesh will be
|
1095
|
+
* registered by {@link Mesh#id} in {@link Scene#highlightedObjects}.
|
1096
|
+
*
|
1097
|
+
* @type {Boolean}
|
1098
|
+
*/
|
1099
|
+
set highlighted(highlighted) {
|
1100
|
+
highlighted = !!highlighted;
|
1101
|
+
if (highlighted === this._state.highlighted) {
|
1102
|
+
return;
|
1103
|
+
}
|
1104
|
+
this._state.highlighted = highlighted;
|
1105
|
+
if (this._isObject) {
|
1106
|
+
this.scene._objectHighlightedUpdated(this);
|
1107
|
+
}
|
1108
|
+
this.glRedraw();
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
/**
|
1112
|
+
* Gets if this Mesh is highlighted.
|
1113
|
+
*
|
1114
|
+
* Highlighted appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#highlightMaterial}.
|
1115
|
+
*
|
1116
|
+
* When {@link Mesh#isObject} and {@link Mesh#highlighted} are both ````true```` the Mesh will be
|
1117
|
+
* registered by {@link Mesh#id} in {@link Scene#highlightedObjects}.
|
1118
|
+
*
|
1119
|
+
* @type {Boolean}
|
1120
|
+
*/
|
1121
|
+
get highlighted() {
|
1122
|
+
return this._state.highlighted;
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
/**
|
1126
|
+
* Sets if this Mesh is selected.
|
1127
|
+
*
|
1128
|
+
* Selected appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#selectedMaterial}.
|
1129
|
+
*
|
1130
|
+
* When {@link Mesh#isObject} and {@link Mesh#selected} are both ````true``` the Mesh will be
|
1131
|
+
* registered by {@link Mesh#id} in {@link Scene#selectedObjects}.
|
1132
|
+
*
|
1133
|
+
* @type {Boolean}
|
1134
|
+
*/
|
1135
|
+
set selected(selected) {
|
1136
|
+
selected = !!selected;
|
1137
|
+
if (selected === this._state.selected) {
|
1138
|
+
return;
|
1139
|
+
}
|
1140
|
+
this._state.selected = selected;
|
1141
|
+
if (this._isObject) {
|
1142
|
+
this.scene._objectSelectedUpdated(this);
|
1143
|
+
}
|
1144
|
+
this.glRedraw();
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
/**
|
1148
|
+
* Gets if this Mesh is selected.
|
1149
|
+
*
|
1150
|
+
* Selected appearance is configured by the {@link EmphasisMaterial} referenced by {@link Mesh#selectedMaterial}.
|
1151
|
+
*
|
1152
|
+
* When {@link Mesh#isObject} and {@link Mesh#selected} are both ````true``` the Mesh will be
|
1153
|
+
* registered by {@link Mesh#id} in {@link Scene#selectedObjects}.
|
1154
|
+
*
|
1155
|
+
* @type {Boolean}
|
1156
|
+
*/
|
1157
|
+
get selected() {
|
1158
|
+
return this._state.selected;
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
/**
|
1162
|
+
* Sets if this Mesh is edge-enhanced.
|
1163
|
+
*
|
1164
|
+
* Edge appearance is configured by the {@link EdgeMaterial} referenced by {@link Mesh#edgeMaterial}.
|
1165
|
+
*
|
1166
|
+
* @type {Boolean}
|
1167
|
+
*/
|
1168
|
+
set edges(edges) {
|
1169
|
+
edges = !!edges;
|
1170
|
+
if (edges === this._state.edges) {
|
1171
|
+
return;
|
1172
|
+
}
|
1173
|
+
this._state.edges = edges;
|
1174
|
+
this.glRedraw();
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
/**
|
1178
|
+
* Gets if this Mesh is edge-enhanced.
|
1179
|
+
*
|
1180
|
+
* Edge appearance is configured by the {@link EdgeMaterial} referenced by {@link Mesh#edgeMaterial}.
|
1181
|
+
*
|
1182
|
+
* @type {Boolean}
|
1183
|
+
*/
|
1184
|
+
get edges() {
|
1185
|
+
return this._state.edges;
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
/**
|
1189
|
+
* Sets if this Mesh is culled.
|
1190
|
+
*
|
1191
|
+
* Only rendered when {@link Mesh#visible} is ````true```` and {@link Mesh#culled} is ````false````.
|
1192
|
+
*
|
1193
|
+
* @type {Boolean}
|
1194
|
+
*/
|
1195
|
+
set culled(value) {
|
1196
|
+
this._state.culled = !!value;
|
1197
|
+
this.glRedraw();
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
/**
|
1201
|
+
* Gets if this Mesh is culled.
|
1202
|
+
*
|
1203
|
+
* Only rendered when {@link Mesh#visible} is ````true```` and {@link Mesh#culled} is ````false````.
|
1204
|
+
*
|
1205
|
+
* @type {Boolean}
|
1206
|
+
*/
|
1207
|
+
get culled() {
|
1208
|
+
return this._state.culled;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
/**
|
1212
|
+
* Sets if this Mesh is clippable.
|
1213
|
+
*
|
1214
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
|
1215
|
+
*
|
1216
|
+
* @type {Boolean}
|
1217
|
+
*/
|
1218
|
+
set clippable(value) {
|
1219
|
+
value = value !== false;
|
1220
|
+
if (this._state.clippable === value) {
|
1221
|
+
return;
|
1222
|
+
}
|
1223
|
+
this._state.clippable = value;
|
1224
|
+
this.glRedraw();
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
/**
|
1228
|
+
* Gets if this Mesh is clippable.
|
1229
|
+
*
|
1230
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
|
1231
|
+
*
|
1232
|
+
* @type {Boolean}
|
1233
|
+
*/
|
1234
|
+
get clippable() {
|
1235
|
+
return this._state.clippable;
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
/**
|
1239
|
+
* Sets if this Mesh included in boundary calculations.
|
1240
|
+
*
|
1241
|
+
* @type {Boolean}
|
1242
|
+
*/
|
1243
|
+
set collidable(value) {
|
1244
|
+
value = value !== false;
|
1245
|
+
if (value === this._state.collidable) {
|
1246
|
+
return;
|
1247
|
+
}
|
1248
|
+
this._state.collidable = value;
|
1249
|
+
this._setAABBDirty();
|
1250
|
+
this.scene._aabbDirty = true;
|
1251
|
+
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
/**
|
1255
|
+
* Gets if this Mesh included in boundary calculations.
|
1256
|
+
*
|
1257
|
+
* @type {Boolean}
|
1258
|
+
*/
|
1259
|
+
get collidable() {
|
1260
|
+
return this._state.collidable;
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
/**
|
1264
|
+
* Sets if this Mesh is pickable.
|
1265
|
+
*
|
1266
|
+
* Picking is done via calls to {@link Scene#pick}.
|
1267
|
+
*
|
1268
|
+
* @type {Boolean}
|
1269
|
+
*/
|
1270
|
+
set pickable(value) {
|
1271
|
+
value = value !== false;
|
1272
|
+
if (this._state.pickable === value) {
|
1273
|
+
return;
|
1274
|
+
}
|
1275
|
+
this._state.pickable = value;
|
1276
|
+
// No need to trigger a render;
|
1277
|
+
// state is only used when picking
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
/**
|
1281
|
+
* Gets if this Mesh is pickable.
|
1282
|
+
*
|
1283
|
+
* Picking is done via calls to {@link Scene#pick}.
|
1284
|
+
*
|
1285
|
+
* @type {Boolean}
|
1286
|
+
*/
|
1287
|
+
get pickable() {
|
1288
|
+
return this._state.pickable;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
/**
|
1292
|
+
* Sets if this Mesh casts shadows.
|
1293
|
+
*
|
1294
|
+
* @type {Boolean}
|
1295
|
+
*/
|
1296
|
+
set castsShadow(value) {
|
1297
|
+
value = value !== false;
|
1298
|
+
if (value === this._state.castsShadow) {
|
1299
|
+
return;
|
1300
|
+
}
|
1301
|
+
this._state.castsShadow = value;
|
1302
|
+
this.glRedraw();
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
/**
|
1306
|
+
* Gets if this Mesh casts shadows.
|
1307
|
+
*
|
1308
|
+
* @type {Boolean}
|
1309
|
+
*/
|
1310
|
+
get castsShadow() {
|
1311
|
+
return this._state.castsShadow;
|
1312
|
+
}
|
1313
|
+
|
1314
|
+
/**
|
1315
|
+
* Sets if this Mesh can have shadows cast upon it.
|
1316
|
+
*
|
1317
|
+
* @type {Boolean}
|
1318
|
+
*/
|
1319
|
+
set receivesShadow(value) {
|
1320
|
+
value = value !== false;
|
1321
|
+
if (value === this._state.receivesShadow) {
|
1322
|
+
return;
|
1323
|
+
}
|
1324
|
+
this._state.receivesShadow = value;
|
1325
|
+
this._state.hash = value ? "/mod/rs;" : "/mod;";
|
1326
|
+
this.fire("dirty", this); // Now need to (re)compile objectRenderers to include/exclude shadow mapping
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
/**
|
1330
|
+
* Gets if this Mesh can have shadows cast upon it.
|
1331
|
+
*
|
1332
|
+
* @type {Boolean}
|
1333
|
+
*/
|
1334
|
+
get receivesShadow() {
|
1335
|
+
return this._state.receivesShadow;
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
/**
|
1339
|
+
* Gets if this Mesh can have Scalable Ambient Obscurance (SAO) applied to it.
|
1340
|
+
*
|
1341
|
+
* SAO is configured by {@link SAO}.
|
1342
|
+
*
|
1343
|
+
* @type {Boolean}
|
1344
|
+
* @abstract
|
1345
|
+
*/
|
1346
|
+
get saoEnabled() {
|
1347
|
+
return false; // TODO: Support SAO on Meshes
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
/**
|
1351
|
+
* Sets the RGB colorize color for this Mesh.
|
1352
|
+
*
|
1353
|
+
* Multiplies by rendered fragment colors.
|
1354
|
+
*
|
1355
|
+
* Each element of the color is in range ````[0..1]````.
|
1356
|
+
*
|
1357
|
+
* @type {Number[]}
|
1358
|
+
*/
|
1359
|
+
set colorize(value) {
|
1360
|
+
let colorize = this._state.colorize;
|
1361
|
+
if (!colorize) {
|
1362
|
+
colorize = this._state.colorize = new Float32Array(4);
|
1363
|
+
colorize[3] = 1;
|
1364
|
+
}
|
1365
|
+
if (value) {
|
1366
|
+
colorize[0] = value[0];
|
1367
|
+
colorize[1] = value[1];
|
1368
|
+
colorize[2] = value[2];
|
1369
|
+
} else {
|
1370
|
+
colorize[0] = 1;
|
1371
|
+
colorize[1] = 1;
|
1372
|
+
colorize[2] = 1;
|
1373
|
+
}
|
1374
|
+
const colorized = (!!value);
|
1375
|
+
this.scene._objectColorizeUpdated(this, colorized);
|
1376
|
+
this.glRedraw();
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
/**
|
1380
|
+
* Gets the RGB colorize color for this Mesh.
|
1381
|
+
*
|
1382
|
+
* Multiplies by rendered fragment colors.
|
1383
|
+
*
|
1384
|
+
* Each element of the color is in range ````[0..1]````.
|
1385
|
+
*
|
1386
|
+
* @type {Number[]}
|
1387
|
+
*/
|
1388
|
+
get colorize() {
|
1389
|
+
return this._state.colorize;
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
/**
|
1393
|
+
* Sets the opacity factor for this Mesh.
|
1394
|
+
*
|
1395
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
1396
|
+
*
|
1397
|
+
* @type {Number}
|
1398
|
+
*/
|
1399
|
+
set opacity(opacity) {
|
1400
|
+
let colorize = this._state.colorize;
|
1401
|
+
if (!colorize) {
|
1402
|
+
colorize = this._state.colorize = new Float32Array(4);
|
1403
|
+
colorize[0] = 1;
|
1404
|
+
colorize[1] = 1;
|
1405
|
+
colorize[2] = 1;
|
1406
|
+
}
|
1407
|
+
const opacityUpdated = (opacity !== null && opacity !== undefined);
|
1408
|
+
colorize[3] = opacityUpdated ? opacity : 1.0;
|
1409
|
+
this.scene._objectOpacityUpdated(this, opacityUpdated);
|
1410
|
+
this.glRedraw();
|
1411
|
+
}
|
1412
|
+
|
1413
|
+
/**
|
1414
|
+
* Gets the opacity factor for this Mesh.
|
1415
|
+
*
|
1416
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
1417
|
+
*
|
1418
|
+
* @type {Number}
|
1419
|
+
*/
|
1420
|
+
get opacity() {
|
1421
|
+
return this._state.colorize[3];
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
/**
|
1425
|
+
* Gets if this Mesh is transparent.
|
1426
|
+
* @returns {Boolean}
|
1427
|
+
*/
|
1428
|
+
get transparent() {
|
1429
|
+
return this._material.alphaMode === 2 /* blend */ || this._state.colorize[3] < 1
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
/**
|
1433
|
+
* Sets the Mesh's rendering order relative to other Meshes.
|
1434
|
+
*
|
1435
|
+
* Default value is ````0````.
|
1436
|
+
*
|
1437
|
+
* This can be set on multiple transparent Meshes, to make them render in a specific order for correct alpha blending.
|
1438
|
+
*
|
1439
|
+
* @type {Number}
|
1440
|
+
*/
|
1441
|
+
set layer(value) {
|
1442
|
+
// TODO: Only accept rendering layer in range [0...MAX_layer]
|
1443
|
+
value = value || 0;
|
1444
|
+
value = Math.round(value);
|
1445
|
+
if (value === this._state.layer) {
|
1446
|
+
return;
|
1447
|
+
}
|
1448
|
+
this._state.layer = value;
|
1449
|
+
this._renderer.needStateSort();
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
/**
|
1453
|
+
* Gets the Mesh's rendering order relative to other Meshes.
|
1454
|
+
*
|
1455
|
+
* Default value is ````0````.
|
1456
|
+
*
|
1457
|
+
* This can be set on multiple transparent Meshes, to make them render in a specific order for correct alpha blending.
|
1458
|
+
*
|
1459
|
+
* @type {Number}
|
1460
|
+
*/
|
1461
|
+
get layer() {
|
1462
|
+
return this._state.layer;
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
/**
|
1466
|
+
* Gets if the Node's position is stationary.
|
1467
|
+
*
|
1468
|
+
* When true, will disable the effect of {@link Camera} translations for this Mesh, while still allowing it to rotate. This is useful for skyboxes.
|
1469
|
+
*
|
1470
|
+
* @type {Boolean}
|
1471
|
+
*/
|
1472
|
+
get stationary() {
|
1473
|
+
return this._state.stationary;
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
/**
|
1477
|
+
* Gets the Node's billboarding behaviour.
|
1478
|
+
*
|
1479
|
+
* Options are:
|
1480
|
+
* * ````"none"```` - (default) - No billboarding.
|
1481
|
+
* * ````"spherical"```` - Mesh is billboarded to face the viewpoint, rotating both vertically and horizontally.
|
1482
|
+
* * ````"cylindrical"```` - Mesh is billboarded to face the viewpoint, rotating only about its vertically axis. Use this mode for things like trees on a landscape.
|
1483
|
+
* @type {String}
|
1484
|
+
*/
|
1485
|
+
get billboard() {
|
1486
|
+
return this._state.billboard;
|
1487
|
+
}
|
1488
|
+
|
1489
|
+
/**
|
1490
|
+
* Sets the Mesh's 3D World-space offset.
|
1491
|
+
*
|
1492
|
+
* The offset dynamically translates the Mesh in World-space.
|
1493
|
+
*
|
1494
|
+
* Default value is ````[0, 0, 0]````.
|
1495
|
+
*
|
1496
|
+
* Provide a null or undefined value to reset to the default value.
|
1497
|
+
*
|
1498
|
+
* @type {Number[]}
|
1499
|
+
*/
|
1500
|
+
set offset(value) {
|
1501
|
+
this._state.offset.set(value || [0, 0, 0]);
|
1502
|
+
this._setAABBDirty();
|
1503
|
+
this.glRedraw();
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
/**
|
1507
|
+
* Gets the Mesh's 3D World-space offset.
|
1508
|
+
*
|
1509
|
+
* Default value is ````[0,0,0]````.
|
1510
|
+
*
|
1511
|
+
* @type {Number[]}
|
1512
|
+
*/
|
1513
|
+
get offset() {
|
1514
|
+
return this._state.offset;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
//------------------------------------------------------------------------------------------------------------------
|
1518
|
+
// Drawable members
|
1519
|
+
//------------------------------------------------------------------------------------------------------------------
|
1520
|
+
|
1521
|
+
/**
|
1522
|
+
* Returns true to indicate that Mesh implements {@link Drawable}.
|
1523
|
+
* @final
|
1524
|
+
* @type {Boolean}
|
1525
|
+
*/
|
1526
|
+
get isDrawable() {
|
1527
|
+
return true;
|
1528
|
+
}
|
1529
|
+
|
1530
|
+
/**
|
1531
|
+
* Property with final value ````true```` to indicate that yjkkit should render this Mesh in sorted order, relative to other Meshes.
|
1532
|
+
*
|
1533
|
+
* The sort order is determined by {@link Mesh#stateSortCompare}.
|
1534
|
+
*
|
1535
|
+
* Sorting is essential for rendering performance, so that yjkkit is able to avoid applying runs of the same state changes to the GPU, ie. can collapse them.
|
1536
|
+
*
|
1537
|
+
* @type {Boolean}
|
1538
|
+
*/
|
1539
|
+
get isStateSortable() {
|
1540
|
+
return true;
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
/**
|
1544
|
+
* Comparison function used by the renderer to determine the order in which yjkkit should render the Mesh, relative to to other Meshes.
|
1545
|
+
*
|
1546
|
+
* yjkkit requires this method because Mesh implements {@link Drawable}.
|
1547
|
+
*
|
1548
|
+
* Sorting is essential for rendering performance, so that yjkkit is able to avoid needlessly applying runs of the same rendering state changes to the GPU, ie. can collapse them.
|
1549
|
+
*
|
1550
|
+
* @param {Mesh} mesh1
|
1551
|
+
* @param {Mesh} mesh2
|
1552
|
+
* @returns {number}
|
1553
|
+
*/
|
1554
|
+
stateSortCompare(mesh1, mesh2) {
|
1555
|
+
return (mesh1._state.layer - mesh2._state.layer)
|
1556
|
+
|| (mesh1._drawRenderer.id - mesh2._drawRenderer.id) // Program state
|
1557
|
+
|| (mesh1._material._state.id - mesh2._material._state.id) // Material state
|
1558
|
+
|| (mesh1._geometry._state.id - mesh2._geometry._state.id); // Geometry state
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
/** @private */
|
1562
|
+
rebuildRenderFlags() {
|
1563
|
+
this.renderFlags.reset();
|
1564
|
+
if (!this._getActiveSectionPlanes()) {
|
1565
|
+
this.renderFlags.culled = true;
|
1566
|
+
return;
|
1567
|
+
}
|
1568
|
+
this.renderFlags.numLayers = 1;
|
1569
|
+
this.renderFlags.numVisibleLayers = 1;
|
1570
|
+
this.renderFlags.visibleLayers[0] = 0;
|
1571
|
+
this._updateRenderFlags();
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
/**
|
1575
|
+
* @private
|
1576
|
+
*/
|
1577
|
+
_updateRenderFlags() {
|
1578
|
+
|
1579
|
+
const renderFlags = this.renderFlags;
|
1580
|
+
const state = this._state;
|
1581
|
+
|
1582
|
+
if (state.xrayed) {
|
1583
|
+
const xrayMaterial = this._xrayMaterial._state;
|
1584
|
+
if (xrayMaterial.fill) {
|
1585
|
+
if (xrayMaterial.fillAlpha < 1.0) {
|
1586
|
+
renderFlags.xrayedSilhouetteTransparent = true;
|
1587
|
+
} else {
|
1588
|
+
renderFlags.xrayedSilhouetteOpaque = true;
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
if (xrayMaterial.edges) {
|
1592
|
+
if (xrayMaterial.edgeAlpha < 1.0) {
|
1593
|
+
renderFlags.xrayedEdgesTransparent = true;
|
1594
|
+
} else {
|
1595
|
+
renderFlags.xrayedEdgesOpaque = true;
|
1596
|
+
}
|
1597
|
+
}
|
1598
|
+
} else {
|
1599
|
+
const normalMaterial = this._material._state;
|
1600
|
+
if (normalMaterial.alpha < 1.0 || state.colorize[3] < 1.0) {
|
1601
|
+
renderFlags.colorTransparent = true;
|
1602
|
+
} else {
|
1603
|
+
renderFlags.colorOpaque = true;
|
1604
|
+
}
|
1605
|
+
if (state.edges) {
|
1606
|
+
const edgeMaterial = this._edgeMaterial._state;
|
1607
|
+
if (edgeMaterial.alpha < 1.0) {
|
1608
|
+
renderFlags.edgesTransparent = true;
|
1609
|
+
} else {
|
1610
|
+
renderFlags.edgesOpaque = true;
|
1611
|
+
}
|
1612
|
+
}
|
1613
|
+
if (state.selected) {
|
1614
|
+
const selectedMaterial = this._selectedMaterial._state;
|
1615
|
+
if (selectedMaterial.fill) {
|
1616
|
+
if (selectedMaterial.fillAlpha < 1.0) {
|
1617
|
+
renderFlags.selectedSilhouetteTransparent = true;
|
1618
|
+
} else {
|
1619
|
+
renderFlags.selectedSilhouetteOpaque = true;
|
1620
|
+
}
|
1621
|
+
}
|
1622
|
+
if (selectedMaterial.edges) {
|
1623
|
+
if (selectedMaterial.edgeAlpha < 1.0) {
|
1624
|
+
renderFlags.selectedEdgesTransparent = true;
|
1625
|
+
} else {
|
1626
|
+
renderFlags.selectedEdgesOpaque = true;
|
1627
|
+
}
|
1628
|
+
}
|
1629
|
+
} else if (state.highlighted) {
|
1630
|
+
const highlightMaterial = this._highlightMaterial._state;
|
1631
|
+
if (highlightMaterial.fill) {
|
1632
|
+
if (highlightMaterial.fillAlpha < 1.0) {
|
1633
|
+
renderFlags.highlightedSilhouetteTransparent = true;
|
1634
|
+
} else {
|
1635
|
+
renderFlags.highlightedSilhouetteOpaque = true;
|
1636
|
+
}
|
1637
|
+
}
|
1638
|
+
if (highlightMaterial.edges) {
|
1639
|
+
if (highlightMaterial.edgeAlpha < 1.0) {
|
1640
|
+
renderFlags.highlightedEdgesTransparent = true;
|
1641
|
+
} else {
|
1642
|
+
renderFlags.highlightedEdgesOpaque = true;
|
1643
|
+
}
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
}
|
1648
|
+
|
1649
|
+
_getActiveSectionPlanes() {
|
1650
|
+
|
1651
|
+
if (this._state.clippable) {
|
1652
|
+
|
1653
|
+
const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
|
1654
|
+
const numSectionPlanes = sectionPlanes.length;
|
1655
|
+
|
1656
|
+
if (numSectionPlanes > 0) {
|
1657
|
+
for (let i = 0; i < numSectionPlanes; i++) {
|
1658
|
+
|
1659
|
+
const sectionPlane = sectionPlanes[i];
|
1660
|
+
const renderFlags = this.renderFlags;
|
1661
|
+
|
1662
|
+
if (!sectionPlane.active) {
|
1663
|
+
renderFlags.sectionPlanesActivePerLayer[i] = false;
|
1664
|
+
|
1665
|
+
} else {
|
1666
|
+
|
1667
|
+
if (this._state.rtcCenter) {
|
1668
|
+
|
1669
|
+
const intersect = math.planeAABB3Intersect(sectionPlane.dir, sectionPlane.dist, this.aabb);
|
1670
|
+
const outside = (intersect === -1);
|
1671
|
+
|
1672
|
+
if (outside) {
|
1673
|
+
return false;
|
1674
|
+
}
|
1675
|
+
|
1676
|
+
const intersecting = (intersect === 0);
|
1677
|
+
renderFlags.sectionPlanesActivePerLayer[i] = intersecting;
|
1678
|
+
|
1679
|
+
} else {
|
1680
|
+
renderFlags.sectionPlanesActivePerLayer[i] = true;
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
}
|
1684
|
+
}
|
1685
|
+
}
|
1686
|
+
|
1687
|
+
return true;
|
1688
|
+
}
|
1689
|
+
|
1690
|
+
/**
|
1691
|
+
* Defines the appearance of this Mesh when xrayed.
|
1692
|
+
*
|
1693
|
+
* Mesh is xrayed when {@link Mesh#xrayed} is ````true````.
|
1694
|
+
*
|
1695
|
+
* Set to {@link Scene#xrayMaterial} by default.
|
1696
|
+
*
|
1697
|
+
* @type {EmphasisMaterial}
|
1698
|
+
*/
|
1699
|
+
get xrayMaterial() {
|
1700
|
+
return this._xrayMaterial;
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
/**
|
1704
|
+
* Defines the appearance of this Mesh when highlighted.
|
1705
|
+
*
|
1706
|
+
* Mesh is xrayed when {@link Mesh#highlighted} is ````true````.
|
1707
|
+
*
|
1708
|
+
* Set to {@link Scene#highlightMaterial} by default.
|
1709
|
+
*
|
1710
|
+
* @type {EmphasisMaterial}
|
1711
|
+
*/
|
1712
|
+
get highlightMaterial() {
|
1713
|
+
return this._highlightMaterial;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
/**
|
1717
|
+
* Defines the appearance of this Mesh when selected.
|
1718
|
+
*
|
1719
|
+
* Mesh is xrayed when {@link Mesh#selected} is ````true````.
|
1720
|
+
*
|
1721
|
+
* Set to {@link Scene#selectedMaterial} by default.
|
1722
|
+
*
|
1723
|
+
* @type {EmphasisMaterial}
|
1724
|
+
*/
|
1725
|
+
get selectedMaterial() {
|
1726
|
+
return this._selectedMaterial;
|
1727
|
+
}
|
1728
|
+
|
1729
|
+
/**
|
1730
|
+
* Defines the appearance of this Mesh when edges are enhanced.
|
1731
|
+
*
|
1732
|
+
* Mesh is xrayed when {@link Mesh#edges} is ````true````.
|
1733
|
+
*
|
1734
|
+
* Set to {@link Scene#edgeMaterial} by default.
|
1735
|
+
*
|
1736
|
+
* @type {EdgeMaterial}
|
1737
|
+
*/
|
1738
|
+
get edgeMaterial() {
|
1739
|
+
return this._edgeMaterial;
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
// ---------------------- NORMAL RENDERING -----------------------------------
|
1743
|
+
|
1744
|
+
/** @private */
|
1745
|
+
drawColorOpaque(frameCtx) {
|
1746
|
+
if (this._drawRenderer || (this._drawRenderer = DrawRenderer.get(this))) {
|
1747
|
+
this._drawRenderer.drawMesh(frameCtx, this);
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
/** @private */
|
1752
|
+
drawColorTransparent(frameCtx) {
|
1753
|
+
if (this._drawRenderer || (this._drawRenderer = DrawRenderer.get(this))) {
|
1754
|
+
this._drawRenderer.drawMesh(frameCtx, this);
|
1755
|
+
}
|
1756
|
+
}
|
1757
|
+
|
1758
|
+
// ---------------------- RENDERING SAO POST EFFECT TARGETS --------------
|
1759
|
+
|
1760
|
+
// TODO
|
1761
|
+
|
1762
|
+
// ---------------------- EMPHASIS RENDERING -----------------------------------
|
1763
|
+
|
1764
|
+
/** @private */
|
1765
|
+
drawSilhouetteXRayed(frameCtx) {
|
1766
|
+
if (this._emphasisFillRenderer || (this._emphasisFillRenderer = EmphasisFillRenderer.get(this))) {
|
1767
|
+
this._emphasisFillRenderer.drawMesh(frameCtx, this, 0); // 0 == xray
|
1768
|
+
}
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
/** @private */
|
1772
|
+
drawSilhouetteHighlighted(frameCtx) {
|
1773
|
+
if (this._emphasisFillRenderer || (this._emphasisFillRenderer = EmphasisFillRenderer.get(this))) {
|
1774
|
+
this._emphasisFillRenderer.drawMesh(frameCtx, this, 1); // 1 == highlight
|
1775
|
+
}
|
1776
|
+
}
|
1777
|
+
|
1778
|
+
/** @private */
|
1779
|
+
drawSilhouetteSelected(frameCtx) {
|
1780
|
+
if (this._emphasisFillRenderer || (this._emphasisFillRenderer = EmphasisFillRenderer.get(this))) {
|
1781
|
+
this._emphasisFillRenderer.drawMesh(frameCtx, this, 2); // 2 == selected
|
1782
|
+
}
|
1783
|
+
}
|
1784
|
+
|
1785
|
+
// ---------------------- EDGES RENDERING -----------------------------------
|
1786
|
+
|
1787
|
+
/** @private */
|
1788
|
+
drawEdgesColorOpaque(frameCtx) {
|
1789
|
+
if (this._emphasisEdgesRenderer || (this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this))) {
|
1790
|
+
this._emphasisEdgesRenderer.drawMesh(frameCtx, this, 3); // 3 == edges
|
1791
|
+
}
|
1792
|
+
}
|
1793
|
+
|
1794
|
+
/** @private */
|
1795
|
+
drawEdgesColorTransparent(frameCtx) {
|
1796
|
+
if (this._emphasisEdgesRenderer || (this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this))) {
|
1797
|
+
this._emphasisEdgesRenderer.drawMesh(frameCtx, this, 3); // 3 == edges
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
|
1801
|
+
/** @private */
|
1802
|
+
drawEdgesXRayed(frameCtx) {
|
1803
|
+
if (this._emphasisEdgesRenderer || (this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this))) {
|
1804
|
+
this._emphasisEdgesRenderer.drawMesh(frameCtx, this, 0); // 0 == xray
|
1805
|
+
}
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
/** @private */
|
1809
|
+
drawEdgesHighlighted(frameCtx) {
|
1810
|
+
if (this._emphasisEdgesRenderer || (this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this))) {
|
1811
|
+
this._emphasisEdgesRenderer.drawMesh(frameCtx, this, 1); // 1 == highlight
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
/** @private */
|
1816
|
+
drawEdgesSelected(frameCtx) {
|
1817
|
+
if (this._emphasisEdgesRenderer || (this._emphasisEdgesRenderer = EmphasisEdgesRenderer.get(this))) {
|
1818
|
+
this._emphasisEdgesRenderer.drawMesh(frameCtx, this, 2); // 2 == selected
|
1819
|
+
}
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
// ---------------------- OCCLUSION CULL RENDERING -----------------------------------
|
1823
|
+
|
1824
|
+
/** @private */
|
1825
|
+
drawOcclusion(frameCtx) {
|
1826
|
+
if (this._occlusionRenderer || (this._occlusionRenderer = OcclusionRenderer.get(this))) {
|
1827
|
+
this._occlusionRenderer.drawMesh(frameCtx, this);
|
1828
|
+
}
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
// ---------------------- SHADOW BUFFER RENDERING -----------------------------------
|
1832
|
+
|
1833
|
+
/** @private */
|
1834
|
+
drawShadow(frameCtx) {
|
1835
|
+
if (this._shadowRenderer || (this._shadowRenderer = ShadowRenderer.get(this))) {
|
1836
|
+
this._shadowRenderer.drawMesh(frameCtx, this);
|
1837
|
+
}
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
// ---------------------- PICKING RENDERING ----------------------------------
|
1841
|
+
|
1842
|
+
/** @private */
|
1843
|
+
drawPickMesh(frameCtx) {
|
1844
|
+
if (this._pickMeshRenderer || (this._pickMeshRenderer = PickMeshRenderer.get(this))) {
|
1845
|
+
this._pickMeshRenderer.drawMesh(frameCtx, this);
|
1846
|
+
}
|
1847
|
+
}
|
1848
|
+
|
1849
|
+
/** @private
|
1850
|
+
*/
|
1851
|
+
canPickTriangle() {
|
1852
|
+
return this._geometry.isReadableGeometry; // VBOGeometry does not support surface picking because it has no geometry data in browser memory
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
/** @private */
|
1856
|
+
drawPickTriangles(frameCtx) {
|
1857
|
+
if (this._pickTriangleRenderer || (this._pickTriangleRenderer = PickTriangleRenderer.get(this))) {
|
1858
|
+
this._pickTriangleRenderer.drawMesh(frameCtx, this);
|
1859
|
+
}
|
1860
|
+
}
|
1861
|
+
|
1862
|
+
/** @private */
|
1863
|
+
pickTriangleSurface(pickViewMatrix, pickProjMatrix, pickResult) {
|
1864
|
+
pickTriangleSurface(this, pickViewMatrix, pickProjMatrix, pickResult);
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
/** @private */
|
1868
|
+
drawPickVertices(frameCtx) {
|
1869
|
+
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
/**
|
1873
|
+
* @private
|
1874
|
+
* @returns {PerformanceNode}
|
1875
|
+
*/
|
1876
|
+
delegatePickedEntity() {
|
1877
|
+
return this;
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
//------------------------------------------------------------------------------------------------------------------
|
1881
|
+
// Component members
|
1882
|
+
//------------------------------------------------------------------------------------------------------------------
|
1883
|
+
|
1884
|
+
/**
|
1885
|
+
* Destroys this Mesh.
|
1886
|
+
*/
|
1887
|
+
destroy() {
|
1888
|
+
super.destroy(); // yjkkit.Object
|
1889
|
+
this._putDrawRenderers();
|
1890
|
+
this._putPickRenderers();
|
1891
|
+
this._putOcclusionRenderer();
|
1892
|
+
this.scene._renderer.putPickID(this._state.pickID); // TODO: somehow puch this down into yjkkit framework?
|
1893
|
+
if (this._isObject) {
|
1894
|
+
this.scene._deregisterObject(this);
|
1895
|
+
if (this._visible) {
|
1896
|
+
this.scene._objectVisibilityUpdated(this, false);
|
1897
|
+
}
|
1898
|
+
if (this._xrayed) {
|
1899
|
+
this.scene._objectXRayedUpdated(this, false);
|
1900
|
+
}
|
1901
|
+
if (this._selected) {
|
1902
|
+
this.scene._objectSelectedUpdated(this, false);
|
1903
|
+
}
|
1904
|
+
if (this._highlighted) {
|
1905
|
+
this.scene._objectHighlightedUpdated(this, false);
|
1906
|
+
}
|
1907
|
+
this.scene._objectColorizeUpdated(this, false);
|
1908
|
+
this.scene._objectOpacityUpdated(this, false);
|
1909
|
+
this.scene._objectOffsetUpdated(this, false);
|
1910
|
+
}
|
1911
|
+
if (this._isModel) {
|
1912
|
+
this.scene._deregisterModel(this);
|
1913
|
+
}
|
1914
|
+
this.glRedraw();
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
|
1920
|
+
const pickTriangleSurface = (function () {
|
1921
|
+
|
1922
|
+
// Cached vars to avoid garbage collection
|
1923
|
+
|
1924
|
+
const localRayOrigin = math.vec3();
|
1925
|
+
const localRayDir = math.vec3();
|
1926
|
+
const positionA = math.vec3();
|
1927
|
+
const positionB = math.vec3();
|
1928
|
+
const positionC = math.vec3();
|
1929
|
+
const triangleVertices = math.vec3();
|
1930
|
+
const position = math.vec4();
|
1931
|
+
const worldPos = math.vec3();
|
1932
|
+
const viewPos = math.vec3();
|
1933
|
+
const bary = math.vec3();
|
1934
|
+
const normalA = math.vec3();
|
1935
|
+
const normalB = math.vec3();
|
1936
|
+
const normalC = math.vec3();
|
1937
|
+
const uva = math.vec3();
|
1938
|
+
const uvb = math.vec3();
|
1939
|
+
const uvc = math.vec3();
|
1940
|
+
const tempVec4a = math.vec4();
|
1941
|
+
const tempVec4b = math.vec4();
|
1942
|
+
const tempVec4c = math.vec4();
|
1943
|
+
const tempVec3 = math.vec3();
|
1944
|
+
const tempVec3b = math.vec3();
|
1945
|
+
const tempVec3c = math.vec3();
|
1946
|
+
const tempVec3d = math.vec3();
|
1947
|
+
const tempVec3e = math.vec3();
|
1948
|
+
const tempVec3f = math.vec3();
|
1949
|
+
const tempVec3g = math.vec3();
|
1950
|
+
const tempVec3h = math.vec3();
|
1951
|
+
const tempVec3i = math.vec3();
|
1952
|
+
const tempVec3j = math.vec3();
|
1953
|
+
const tempVec3k = math.vec3();
|
1954
|
+
|
1955
|
+
return function (mesh, pickViewMatrix, pickProjMatrix, pickResult) {
|
1956
|
+
|
1957
|
+
var primIndex = pickResult.primIndex;
|
1958
|
+
|
1959
|
+
if (primIndex !== undefined && primIndex !== null && primIndex > -1) {
|
1960
|
+
|
1961
|
+
const geometry = mesh.geometry._state;
|
1962
|
+
const scene = mesh.scene;
|
1963
|
+
const camera = scene.camera;
|
1964
|
+
const canvas = scene.canvas;
|
1965
|
+
|
1966
|
+
if (geometry.primitiveName === "triangles") {
|
1967
|
+
|
1968
|
+
// Triangle picked; this only happens when the
|
1969
|
+
// Mesh has a Geometry that has primitives of type "triangle"
|
1970
|
+
|
1971
|
+
pickResult.primitive = "triangle";
|
1972
|
+
|
1973
|
+
// Get the World-space positions of the triangle's vertices
|
1974
|
+
|
1975
|
+
const i = primIndex; // Indicates the first triangle index in the indices array
|
1976
|
+
|
1977
|
+
const indices = geometry.indices; // Indices into geometry arrays, not into shared VertexBufs
|
1978
|
+
const positions = geometry.positions;
|
1979
|
+
|
1980
|
+
let ia3;
|
1981
|
+
let ib3;
|
1982
|
+
let ic3;
|
1983
|
+
|
1984
|
+
if (indices) {
|
1985
|
+
|
1986
|
+
var ia = indices[i + 0];
|
1987
|
+
var ib = indices[i + 1];
|
1988
|
+
var ic = indices[i + 2];
|
1989
|
+
|
1990
|
+
triangleVertices[0] = ia;
|
1991
|
+
triangleVertices[1] = ib;
|
1992
|
+
triangleVertices[2] = ic;
|
1993
|
+
|
1994
|
+
pickResult.indices = triangleVertices;
|
1995
|
+
|
1996
|
+
ia3 = ia * 3;
|
1997
|
+
ib3 = ib * 3;
|
1998
|
+
ic3 = ic * 3;
|
1999
|
+
|
2000
|
+
} else {
|
2001
|
+
|
2002
|
+
ia3 = i * 3;
|
2003
|
+
ib3 = ia3 + 3;
|
2004
|
+
ic3 = ib3 + 3;
|
2005
|
+
}
|
2006
|
+
|
2007
|
+
positionA[0] = positions[ia3 + 0];
|
2008
|
+
positionA[1] = positions[ia3 + 1];
|
2009
|
+
positionA[2] = positions[ia3 + 2];
|
2010
|
+
|
2011
|
+
positionB[0] = positions[ib3 + 0];
|
2012
|
+
positionB[1] = positions[ib3 + 1];
|
2013
|
+
positionB[2] = positions[ib3 + 2];
|
2014
|
+
|
2015
|
+
positionC[0] = positions[ic3 + 0];
|
2016
|
+
positionC[1] = positions[ic3 + 1];
|
2017
|
+
positionC[2] = positions[ic3 + 2];
|
2018
|
+
|
2019
|
+
if (geometry.compressGeometry) {
|
2020
|
+
|
2021
|
+
// Decompress vertex positions
|
2022
|
+
|
2023
|
+
const positionsDecodeMatrix = geometry.positionsDecodeMatrix;
|
2024
|
+
if (positionsDecodeMatrix) {
|
2025
|
+
geometryCompressionUtils.decompressPosition(positionA, positionsDecodeMatrix, positionA);
|
2026
|
+
geometryCompressionUtils.decompressPosition(positionB, positionsDecodeMatrix, positionB);
|
2027
|
+
geometryCompressionUtils.decompressPosition(positionC, positionsDecodeMatrix, positionC);
|
2028
|
+
}
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
// Attempt to ray-pick the triangle in local space
|
2032
|
+
|
2033
|
+
let canvasPos;
|
2034
|
+
|
2035
|
+
if (pickResult.canvasPos) {
|
2036
|
+
canvasPos = pickResult.canvasPos;
|
2037
|
+
math.canvasPosToLocalRay(canvas.canvas, pickViewMatrix, pickProjMatrix, mesh.worldMatrix, canvasPos, localRayOrigin, localRayDir);
|
2038
|
+
|
2039
|
+
} else if (pickResult.origin && pickResult.direction) {
|
2040
|
+
math.worldRayToLocalRay(mesh.worldMatrix, pickResult.origin, pickResult.direction, localRayOrigin, localRayDir);
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
math.normalizeVec3(localRayDir);
|
2044
|
+
math.rayPlaneIntersect(localRayOrigin, localRayDir, positionA, positionB, positionC, position);
|
2045
|
+
|
2046
|
+
// Get Local-space cartesian coordinates of the ray-triangle intersection
|
2047
|
+
|
2048
|
+
pickResult.localPos = position;
|
2049
|
+
pickResult.position = position;
|
2050
|
+
|
2051
|
+
// Get interpolated World-space coordinates
|
2052
|
+
|
2053
|
+
// Need to transform homogeneous coords
|
2054
|
+
|
2055
|
+
tempVec4a[0] = position[0];
|
2056
|
+
tempVec4a[1] = position[1];
|
2057
|
+
tempVec4a[2] = position[2];
|
2058
|
+
tempVec4a[3] = 1;
|
2059
|
+
|
2060
|
+
// Get World-space cartesian coordinates of the ray-triangle intersection
|
2061
|
+
|
2062
|
+
math.transformVec4(mesh.worldMatrix, tempVec4a, tempVec4b);
|
2063
|
+
|
2064
|
+
worldPos[0] = tempVec4b[0];
|
2065
|
+
worldPos[1] = tempVec4b[1];
|
2066
|
+
worldPos[2] = tempVec4b[2];
|
2067
|
+
|
2068
|
+
pickResult.worldPos = worldPos;
|
2069
|
+
|
2070
|
+
// Get View-space cartesian coordinates of the ray-triangle intersection
|
2071
|
+
|
2072
|
+
math.transformVec4(camera.matrix, tempVec4b, tempVec4c);
|
2073
|
+
|
2074
|
+
viewPos[0] = tempVec4c[0];
|
2075
|
+
viewPos[1] = tempVec4c[1];
|
2076
|
+
viewPos[2] = tempVec4c[2];
|
2077
|
+
|
2078
|
+
pickResult.viewPos = viewPos;
|
2079
|
+
|
2080
|
+
// Get barycentric coordinates of the ray-triangle intersection
|
2081
|
+
|
2082
|
+
math.cartesianToBarycentric(position, positionA, positionB, positionC, bary);
|
2083
|
+
|
2084
|
+
pickResult.bary = bary;
|
2085
|
+
|
2086
|
+
// Get interpolated normal vector
|
2087
|
+
|
2088
|
+
const normals = geometry.normals;
|
2089
|
+
|
2090
|
+
if (normals) {
|
2091
|
+
|
2092
|
+
if (geometry.compressGeometry) {
|
2093
|
+
|
2094
|
+
// Decompress vertex normals
|
2095
|
+
|
2096
|
+
const ia2 = ia * 3;
|
2097
|
+
const ib2 = ib * 3;
|
2098
|
+
const ic2 = ic * 3;
|
2099
|
+
|
2100
|
+
geometryCompressionUtils.decompressNormal(normals.subarray(ia2, ia2 + 2), normalA);
|
2101
|
+
geometryCompressionUtils.decompressNormal(normals.subarray(ib2, ib2 + 2), normalB);
|
2102
|
+
geometryCompressionUtils.decompressNormal(normals.subarray(ic2, ic2 + 2), normalC);
|
2103
|
+
|
2104
|
+
} else {
|
2105
|
+
|
2106
|
+
normalA[0] = normals[ia3];
|
2107
|
+
normalA[1] = normals[ia3 + 1];
|
2108
|
+
normalA[2] = normals[ia3 + 2];
|
2109
|
+
|
2110
|
+
normalB[0] = normals[ib3];
|
2111
|
+
normalB[1] = normals[ib3 + 1];
|
2112
|
+
normalB[2] = normals[ib3 + 2];
|
2113
|
+
|
2114
|
+
normalC[0] = normals[ic3];
|
2115
|
+
normalC[1] = normals[ic3 + 1];
|
2116
|
+
normalC[2] = normals[ic3 + 2];
|
2117
|
+
}
|
2118
|
+
|
2119
|
+
const normal = math.addVec3(math.addVec3(
|
2120
|
+
math.mulVec3Scalar(normalA, bary[0], tempVec3),
|
2121
|
+
math.mulVec3Scalar(normalB, bary[1], tempVec3b), tempVec3c),
|
2122
|
+
math.mulVec3Scalar(normalC, bary[2], tempVec3d), tempVec3e);
|
2123
|
+
|
2124
|
+
pickResult.worldNormal = math.normalizeVec3(math.transformVec3(mesh.worldNormalMatrix, normal, tempVec3f));
|
2125
|
+
}
|
2126
|
+
|
2127
|
+
// Get interpolated UV coordinates
|
2128
|
+
|
2129
|
+
const uvs = geometry.uv;
|
2130
|
+
|
2131
|
+
if (uvs) {
|
2132
|
+
|
2133
|
+
uva[0] = uvs[(ia * 2)];
|
2134
|
+
uva[1] = uvs[(ia * 2) + 1];
|
2135
|
+
|
2136
|
+
uvb[0] = uvs[(ib * 2)];
|
2137
|
+
uvb[1] = uvs[(ib * 2) + 1];
|
2138
|
+
|
2139
|
+
uvc[0] = uvs[(ic * 2)];
|
2140
|
+
uvc[1] = uvs[(ic * 2) + 1];
|
2141
|
+
|
2142
|
+
if (geometry.compressGeometry) {
|
2143
|
+
|
2144
|
+
// Decompress vertex UVs
|
2145
|
+
|
2146
|
+
const uvDecodeMatrix = geometry.uvDecodeMatrix;
|
2147
|
+
if (uvDecodeMatrix) {
|
2148
|
+
geometryCompressionUtils.decompressUV(uva, uvDecodeMatrix, uva);
|
2149
|
+
geometryCompressionUtils.decompressUV(uvb, uvDecodeMatrix, uvb);
|
2150
|
+
geometryCompressionUtils.decompressUV(uvc, uvDecodeMatrix, uvc);
|
2151
|
+
}
|
2152
|
+
}
|
2153
|
+
|
2154
|
+
pickResult.uv = math.addVec3(
|
2155
|
+
math.addVec3(
|
2156
|
+
math.mulVec2Scalar(uva, bary[0], tempVec3g),
|
2157
|
+
math.mulVec2Scalar(uvb, bary[1], tempVec3h), tempVec3i),
|
2158
|
+
math.mulVec2Scalar(uvc, bary[2], tempVec3j), tempVec3k);
|
2159
|
+
}
|
2160
|
+
}
|
2161
|
+
}
|
2162
|
+
}
|
2163
|
+
})();
|
2164
|
+
|
2165
|
+
export {Mesh};
|