csyjk 1.2.2 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/app.js → app.js} +0 -0
- package/{dist/index.html → index.html} +0 -0
- package/package.json +5 -40
- package/{dist/style.css → style.css} +0 -0
- package/.babelrc +0 -7
- package/.idea/modules.xml +0 -8
- package/.idea/xx.iml +0 -12
- package/public/gltf.js +0 -2241
- package/public/index.html +0 -10
- package/src/index.js +0 -3
- package/src/lib/gltf/assets/check.jpg +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.css +0 -358
- package/src/lib/gltf/assets/iconfont/iconfont.eot +0 -0
- package/src/lib/gltf/assets/iconfont/iconfont.js +0 -1
- package/src/lib/gltf/assets/iconfont/iconfont.json +0 -604
- package/src/lib/gltf/assets/iconfont/iconfont.svg +0 -189
- 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 +0 -15
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/ContextMenu.js +0 -863
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/extras/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/index.js +0 -3
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +0 -462
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.js +0 -279
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.js +0 -262
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/Annotation.js +0 -362
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +0 -575
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/AxisGizmoPlugin.js +0 -333
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +0 -777
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +0 -525
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.js +0 -242
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +0 -297
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/FastNavPlugin.js +0 -345
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +0 -122
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +0 -462
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFPerformanceModelLoader.js +0 -508
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFSceneGraphLoader.js +0 -922
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/CubeTextureCanvas.js +0 -273
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/NavCubePlugin.js +0 -687
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJLoaderPlugin.js +0 -145
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJSceneGraphLoader.js +0 -777
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLDefaultDataSource.js +0 -33
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLLoaderPlugin.js +0 -273
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLSceneGraphLoader.js +0 -313
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Control.js +0 -1328
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Overview.js +0 -249
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Plane.js +0 -169
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js +0 -403
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +0 -134
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/IFCStoreyPlanObjectStates.js +0 -77
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/Storey.js +0 -61
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyMap.js +0 -57
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +0 -822
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/ModelTreeView.js +0 -888
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewNode.js +0 -88
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewPlugin.js +0 -624
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/modelValidation.js +0 -87
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/ViewCullPlugin.js +0 -295
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +0 -78
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +0 -847
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +0 -167
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +0 -228
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +0 -220
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +0 -279
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +0 -244
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +0 -301
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +0 -426
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +0 -479
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/lib/pako.js +0 -6818
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DLoaderPlugin.js +0 -238
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DSceneGraphLoader.js +0 -1279
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/.jshintrc +0 -11
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/deflate.js +0 -2060
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/inflate.js +0 -2155
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/mime-types.js +0 -1002
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/pako/codecs.js +0 -64
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/z-worker.js +0 -153
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-ext.js +0 -267
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-fs.js +0 -553
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip.js +0 -991
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zlib-asm/codecs.js +0 -49
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/index.js +0 -17
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/culling/ObjectCullStates.js +0 -205
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Dot.js +0 -78
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Label.js +0 -97
- package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Wire.js +0 -95
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Plugin.js +0 -112
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Viewer.js +0 -372
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/index.js +0 -3
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaultColors.js +0 -162
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaults.js +0 -39
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaModel.js +0 -145
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaObject.js +0 -215
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaScene.js +0 -311
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/CameraControl.js +0 -1669
- 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 +0 -312
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PanController.js +0 -112
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PickController.js +0 -193
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PivotController.js +0 -289
- 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 +0 -122
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +0 -186
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MouseMiscHandler.js +0 -68
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +0 -439
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +0 -361
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +0 -258
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPickHandler.js +0 -197
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/mouspan.js +0 -498
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Component.js +0 -908
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Entity.js +0 -475
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/ImagePlane.js +0 -570
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/PerformanceModel.js +0 -2623
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ENTITY_FLAGS.js +0 -21
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceMesh.js +0 -262
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceNode.js +0 -697
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/RENDER_PASSES.js +0 -34
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ScratchMemory.js +0 -63
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/compression.js +0 -183
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingBuffer.js +0 -33
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingLayer.js +0 -736
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingRenderers.js +0 -68
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingColorRenderer.js +0 -295
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +0 -327
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingLayer.js +0 -698
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingRenderers.js +0 -68
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingColorRenderer.js +0 -364
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +0 -356
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingBuffer.js +0 -33
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingLayer.js +0 -776
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingRenderers.js +0 -113
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingColorRenderer.js +0 -340
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +0 -312
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +0 -343
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +0 -331
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingShadowRenderer.js +0 -242
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +0 -348
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingLayer.js +0 -737
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingRenderers.js +0 -143
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingColorRenderer.js +0 -373
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +0 -366
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +0 -370
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +0 -386
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +0 -376
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +0 -293
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +0 -382
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingBuffer.js +0 -37
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingLayer.js +0 -1017
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingRenderers.js +0 -246
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorQualityRenderer.js +0 -809
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +0 -504
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +0 -297
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +0 -300
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +0 -322
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +0 -311
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +0 -291
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +0 -319
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +0 -305
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +0 -300
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +0 -242
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +0 -323
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingLayer.js +0 -969
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingRenderers.js +0 -246
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorQualityRenderer.js +0 -859
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +0 -557
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +0 -341
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +0 -338
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +0 -356
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +0 -354
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +0 -329
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +0 -358
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +0 -349
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +0 -363
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +0 -284
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +0 -354
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Camera.js +0 -880
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraFlightAnimation.js +0 -669
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPath.js +0 -194
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPathAnimation.js +0 -326
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CustomProjection.js +0 -149
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Frustum.js +0 -316
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Ortho.js +0 -286
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Perspective.js +0 -302
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Canvas.js +0 -464
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Spinner.js +0 -323
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/core.js +0 -234
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/Geometry.js +0 -33
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/ReadableGeometry.js +0 -689
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/VBOGeometry.js +0 -327
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxGeometry.js +0 -238
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +0 -106
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildCylinderGeometry.js +0 -271
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildGridGeometry.js +0 -102
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +0 -168
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildSphereGeometry.js +0 -161
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildTorusGeometry.js +0 -172
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildVectorTextGeometry.js +0 -1721
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/index.js +0 -8
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/index.js +0 -4
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/load3DSGeometry.js +0 -103
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/loadOBJGeometry.js +0 -130
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/index.js +0 -18
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/input/Input.js +0 -1475
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/canvas2image.js +0 -218
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/k3d.js +0 -1032
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/AmbientLight.js +0 -175
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/CubeTexture.js +0 -156
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/DirLight.js +0 -314
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Light.js +0 -29
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/LightMap.js +0 -77
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/PointLight.js +0 -395
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/ReflectionMap.js +0 -79
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Shadow.js +0 -138
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/index.js +0 -5
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/Marker.js +0 -382
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EdgeMaterial.js +0 -359
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EmphasisMaterial.js +0 -577
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Fresnel.js +0 -222
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LambertMaterial.js +0 -378
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LinesMaterial.js +0 -169
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Material.js +0 -39
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/MetallicMaterial.js +0 -820
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PhongMaterial.js +0 -860
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PointsMaterial.js +0 -320
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/SpecularMaterial.js +0 -807
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Texture.js +0 -522
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/index.js +0 -8
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/Frustum.js +0 -118
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/buildEdgeIndices.js +0 -162
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/geometryCompressionUtils.js +0 -353
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/math.js +0 -5302
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/rtcCoords.js +0 -132
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/CameraMemento.js +0 -200
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ModelMemento.js +0 -272
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ObjectsMemento.js +0 -259
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/index.js +0 -3
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/Mesh.js +0 -2165
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawRenderer.js +0 -978
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawShaderSource.js +0 -1566
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +0 -249
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +0 -163
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +0 -276
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +0 -269
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +0 -207
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +0 -156
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshRenderer.js +0 -210
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +0 -146
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +0 -186
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +0 -120
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowRenderer.js +0 -214
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +0 -96
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/metriqs/Metriqs.js +0 -259
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/Node.js +0 -1356
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/CubicBezierCurve.js +0 -194
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Curve.js +0 -183
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Path.js +0 -239
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/QuadraticBezierCurve.js +0 -161
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/SplineCurve.js +0 -133
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/index.js +0 -5
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/postfx/SAO.js +0 -547
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/scene/Scene.js +0 -2481
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/SectionPlane.js +0 -194
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/Skybox.js +0 -119
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/index.js +0 -1
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/stats.js +0 -45
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Map.js +0 -45
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Queue.js +0 -56
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/index.js +0 -2
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils.js +0 -452
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/viewport/Viewport.js +0 -212
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/ArrayBuf.js +0 -121
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Attribute.js +0 -23
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Drawable.js +0 -270
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/FrameContext.js +0 -259
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/PickResult.js +0 -317
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Pickable.js +0 -69
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Program.js +0 -179
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderBuffer.js +0 -315
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderFlags.js +0 -203
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderState.js +0 -40
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Renderer.js +0 -1300
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Sampler.js +0 -18
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Shader.js +0 -49
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Texture2D.js +0 -217
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +0 -214
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionTester.js +0 -432
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +0 -326
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +0 -375
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/webglEnums.js +0 -61
- package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webglInfo.js +0 -48
- package/src/lib/gltf/gltf.css +0 -392
- package/src/lib/gltf/gltf.js +0 -2241
- package/webpack.config.js +0 -70
|
@@ -1,2481 +0,0 @@
|
|
|
1
|
-
import {core} from '../core.js';
|
|
2
|
-
import {utils} from '../utils.js';
|
|
3
|
-
import {math} from '../math/math.js';
|
|
4
|
-
import {Component} from '../Component.js';
|
|
5
|
-
import {Canvas} from '../canvas/Canvas.js';
|
|
6
|
-
import {Renderer} from '../webgl/Renderer.js';
|
|
7
|
-
import {Input} from '../input/Input.js';
|
|
8
|
-
import {Viewport} from '../viewport/Viewport.js';
|
|
9
|
-
import {Camera} from '../camera/Camera.js';
|
|
10
|
-
import {DirLight} from '../lights/DirLight.js';
|
|
11
|
-
import {AmbientLight} from '../lights/AmbientLight.js';
|
|
12
|
-
import {ReadableGeometry} from "../geometry/ReadableGeometry.js";
|
|
13
|
-
import {buildBoxGeometry} from '../geometry/builders/buildBoxGeometry.js';
|
|
14
|
-
import {PhongMaterial} from '../materials/PhongMaterial.js';
|
|
15
|
-
import {EmphasisMaterial} from '../materials/EmphasisMaterial.js';
|
|
16
|
-
import {EdgeMaterial} from '../materials/EdgeMaterial.js';
|
|
17
|
-
import {Metrics} from "../metriqs/Metriqs.js";
|
|
18
|
-
import {SAO} from "../postfx/SAO.js";
|
|
19
|
-
import {PointsMaterial} from "../materials/PointsMaterial.js";
|
|
20
|
-
import {LinesMaterial} from "../materials/LinesMaterial.js";
|
|
21
|
-
|
|
22
|
-
// Enables runtime check for redundant calls to object state update methods, eg. Scene#_objectVisibilityUpdated
|
|
23
|
-
const ASSERT_OBJECT_STATE_UPDATE = false;
|
|
24
|
-
|
|
25
|
-
// Cached vars to avoid garbage collection
|
|
26
|
-
|
|
27
|
-
function getEntityIDMap(scene, entityIds) {
|
|
28
|
-
const map = {};
|
|
29
|
-
let entityId;
|
|
30
|
-
let entity;
|
|
31
|
-
for (let i = 0, len = entityIds.length; i < len; i++) {
|
|
32
|
-
entityId = entityIds[i];
|
|
33
|
-
entity = scene.component[entityId];
|
|
34
|
-
if (!entity) {
|
|
35
|
-
scene.warn("pick(): Component not found: " + entityId);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (!entity.isEntity) {
|
|
39
|
-
scene.warn("pick(): Component is not an Entity: " + entityId);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
map[entityId] = true;
|
|
43
|
-
}
|
|
44
|
-
return map;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Fired whenever a debug message is logged on a component within this Scene.
|
|
49
|
-
* @event log
|
|
50
|
-
* @param {String} value The debug message
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Fired whenever an error is logged on a component within this Scene.
|
|
55
|
-
* @event error
|
|
56
|
-
* @param {String} value The error message
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Fired whenever a warning is logged on a component within this Scene.
|
|
61
|
-
* @event warn
|
|
62
|
-
* @param {String} value The warning message
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @desc Contains the components that comprise a 3D scene.
|
|
67
|
-
*
|
|
68
|
-
* * A {@link Viewer} has a single Scene, which it provides in {@link Viewer#scene}.
|
|
69
|
-
* * Plugins like {@link AxisGizmoPlugin} also have their own private Scenes.
|
|
70
|
-
* * Each Scene has a corresponding {@link MetaScene}, which the Viewer provides in {@link Viewer#metaScene}.
|
|
71
|
-
*
|
|
72
|
-
* ## Getting a Viewer's Scene
|
|
73
|
-
*
|
|
74
|
-
* ````javascript
|
|
75
|
-
* var scene = viewer.scene;
|
|
76
|
-
* ````
|
|
77
|
-
*
|
|
78
|
-
* ## Creating and accessing Scene components
|
|
79
|
-
*
|
|
80
|
-
* As a brief introduction to creating Scene components, we'll create a {@link Mesh} that has a
|
|
81
|
-
* {@link buildTorusGeometry} and a {@link PhongMaterial}:
|
|
82
|
-
*
|
|
83
|
-
* ````javascript
|
|
84
|
-
* var teapotMesh = new Mesh(scene, {
|
|
85
|
-
* id: "myMesh", // <<---------- ID automatically generated if not provided
|
|
86
|
-
* geometry: new TorusGeometry(scene),
|
|
87
|
-
* material: new PhongMaterial(scene, {
|
|
88
|
-
* id: "myMaterial",
|
|
89
|
-
* diffuse: [0.2, 0.2, 1.0]
|
|
90
|
-
* })
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* teapotMesh.scene.camera.eye = [45, 45, 45];
|
|
94
|
-
* ````
|
|
95
|
-
*
|
|
96
|
-
* Find components by ID in their Scene's {@link Scene#components} map:
|
|
97
|
-
*
|
|
98
|
-
* ````javascript
|
|
99
|
-
* var teapotMesh = scene.components["myMesh"];
|
|
100
|
-
* teapotMesh.visible = false;
|
|
101
|
-
*
|
|
102
|
-
* var teapotMaterial = scene.components["myMaterial"];
|
|
103
|
-
* teapotMaterial.diffuse = [1,0,0]; // Change to red
|
|
104
|
-
* ````
|
|
105
|
-
*
|
|
106
|
-
* A Scene also has a map of component instances for each {@link Component} subtype:
|
|
107
|
-
*
|
|
108
|
-
* ````javascript
|
|
109
|
-
* var meshes = scene.types["Mesh"];
|
|
110
|
-
* var teapotMesh = meshes["myMesh"];
|
|
111
|
-
* teapotMesh.xrayed = true;
|
|
112
|
-
*
|
|
113
|
-
* var phongMaterials = scene.types["PhongMaterial"];
|
|
114
|
-
* var teapotMaterial = phongMaterials["myMaterial"];
|
|
115
|
-
* teapotMaterial.diffuse = [0,1,0]; // Change to green
|
|
116
|
-
* ````
|
|
117
|
-
*
|
|
118
|
-
* See {@link Node}, {@link Node} and {@link Model} for how to create and access more sophisticated content.
|
|
119
|
-
*
|
|
120
|
-
* ## Controlling the camera
|
|
121
|
-
*
|
|
122
|
-
* Use the Scene's {@link Camera} to control the current viewpoint and projection:
|
|
123
|
-
*
|
|
124
|
-
* ````javascript
|
|
125
|
-
* var camera = myScene.camera;
|
|
126
|
-
*
|
|
127
|
-
* camera.eye = [-10,0,0];
|
|
128
|
-
* camera.look = [-10,0,0];
|
|
129
|
-
* camera.up = [0,1,0];
|
|
130
|
-
*
|
|
131
|
-
* camera.projection = "perspective";
|
|
132
|
-
* camera.perspective.fov = 45;
|
|
133
|
-
* //...
|
|
134
|
-
* ````
|
|
135
|
-
*
|
|
136
|
-
* ## Managing the canvas
|
|
137
|
-
*
|
|
138
|
-
* The Scene's {@link Canvas} component provides various conveniences relevant to the WebGL canvas, such
|
|
139
|
-
* as firing resize events etc:
|
|
140
|
-
*
|
|
141
|
-
* ````javascript
|
|
142
|
-
* var canvas = scene.canvas;
|
|
143
|
-
*
|
|
144
|
-
* canvas.on("boundary", function(boundary) {
|
|
145
|
-
* //...
|
|
146
|
-
* });
|
|
147
|
-
* ````
|
|
148
|
-
*
|
|
149
|
-
* ## Picking
|
|
150
|
-
*
|
|
151
|
-
* Use {@link Scene#pick} to pick and raycast entites.
|
|
152
|
-
*
|
|
153
|
-
* For example, to pick a point on the surface of the closest entity at the given canvas coordinates:
|
|
154
|
-
*
|
|
155
|
-
* ````javascript
|
|
156
|
-
* var pickResult = scene.pick({
|
|
157
|
-
* pickSurface: true,
|
|
158
|
-
* canvasPos: [23, 131]
|
|
159
|
-
* });
|
|
160
|
-
*
|
|
161
|
-
* if (pickResult) { // Picked an entity
|
|
162
|
-
*
|
|
163
|
-
* var entity = pickResult.entity;
|
|
164
|
-
*
|
|
165
|
-
* var primitive = pickResult.primitive; // Type of primitive that was picked, usually "triangles"
|
|
166
|
-
* var primIndex = pickResult.primIndex; // Position of triangle's first index in the picked Mesh's Geometry's indices array
|
|
167
|
-
* var indices = pickResult.indices; // UInt32Array containing the triangle's vertex indices
|
|
168
|
-
* var localPos = pickResult.localPos; // Float64Array containing the picked Local-space position on the triangle
|
|
169
|
-
* var worldPos = pickResult.worldPos; // Float64Array containing the picked World-space position on the triangle
|
|
170
|
-
* var viewPos = pickResult.viewPos; // Float64Array containing the picked View-space position on the triangle
|
|
171
|
-
* var bary = pickResult.bary; // Float64Array containing the picked barycentric position within the triangle
|
|
172
|
-
* var normal = pickResult.normal; // Float64Array containing the interpolated normal vector at the picked position on the triangle
|
|
173
|
-
* var uv = pickResult.uv; // Float64Array containing the interpolated UV coordinates at the picked position on the triangle
|
|
174
|
-
* }
|
|
175
|
-
* ````
|
|
176
|
-
*
|
|
177
|
-
* ## Pick masking
|
|
178
|
-
*
|
|
179
|
-
* We can use {@link Scene#pick}'s ````includeEntities```` and ````excludeEntities```` options to mask which {@link Mesh}es we attempt to pick.
|
|
180
|
-
*
|
|
181
|
-
* This is useful for picking through things, to pick only the Entities of interest.
|
|
182
|
-
*
|
|
183
|
-
* To pick only Entities ````"gearbox#77.0"```` and ````"gearbox#79.0"````, picking through any other Entities that are
|
|
184
|
-
* in the way, as if they weren't there:
|
|
185
|
-
*
|
|
186
|
-
* ````javascript
|
|
187
|
-
* var pickResult = scene.pick({
|
|
188
|
-
* canvasPos: [23, 131],
|
|
189
|
-
* includeEntities: ["gearbox#77.0", "gearbox#79.0"]
|
|
190
|
-
* });
|
|
191
|
-
*
|
|
192
|
-
* if (pickResult) {
|
|
193
|
-
* // Entity will always be either "gearbox#77.0" or "gearbox#79.0"
|
|
194
|
-
* var entity = pickResult.entity;
|
|
195
|
-
* }
|
|
196
|
-
* ````
|
|
197
|
-
*
|
|
198
|
-
* To pick any pickable Entity, except for ````"gearbox#77.0"```` and ````"gearbox#79.0"````, picking through those
|
|
199
|
-
* Entities if they happen to be in the way:
|
|
200
|
-
*
|
|
201
|
-
* ````javascript
|
|
202
|
-
* var pickResult = scene.pick({
|
|
203
|
-
* canvasPos: [23, 131],
|
|
204
|
-
* excludeEntities: ["gearbox#77.0", "gearbox#79.0"]
|
|
205
|
-
* });
|
|
206
|
-
*
|
|
207
|
-
* if (pickResult) {
|
|
208
|
-
* // Entity will never be "gearbox#77.0" or "gearbox#79.0"
|
|
209
|
-
* var entity = pickResult.entity;
|
|
210
|
-
* }
|
|
211
|
-
* ````
|
|
212
|
-
*
|
|
213
|
-
* See {@link Scene#pick} for more info on picking.
|
|
214
|
-
*
|
|
215
|
-
* ## Querying and tracking boundaries
|
|
216
|
-
*
|
|
217
|
-
* Getting a Scene's World-space axis-aligned boundary (AABB):
|
|
218
|
-
*
|
|
219
|
-
* ````javascript
|
|
220
|
-
* var aabb = scene.aabb; // [xmin, ymin, zmin, xmax, ymax, zmax]
|
|
221
|
-
* ````
|
|
222
|
-
*
|
|
223
|
-
* Subscribing to updates to the AABB, which occur whenever {@link Entity}s are transformed, their
|
|
224
|
-
* {@link ReadableGeometry}s have been updated, or the {@link Camera} has moved:
|
|
225
|
-
*
|
|
226
|
-
* ````javascript
|
|
227
|
-
* scene.on("boundary", function() {
|
|
228
|
-
* var aabb = scene.aabb;
|
|
229
|
-
* });
|
|
230
|
-
* ````
|
|
231
|
-
*
|
|
232
|
-
* Getting the AABB of the {@link Entity}s with the given IDs:
|
|
233
|
-
*
|
|
234
|
-
* ````JavaScript
|
|
235
|
-
* scene.getAABB(); // Gets collective boundary of all Entities in the scene
|
|
236
|
-
* scene.getAABB("saw"); // Gets boundary of an Object
|
|
237
|
-
* scene.getAABB(["saw", "gearbox"]); // Gets collective boundary of two Objects
|
|
238
|
-
* ````
|
|
239
|
-
*
|
|
240
|
-
* See {@link Scene#getAABB} and {@link Entity} for more info on querying and tracking boundaries.
|
|
241
|
-
*
|
|
242
|
-
* ## Managing the viewport
|
|
243
|
-
*
|
|
244
|
-
* The Scene's {@link Viewport} component manages the WebGL viewport:
|
|
245
|
-
*
|
|
246
|
-
* ````javascript
|
|
247
|
-
* var viewport = scene.viewport
|
|
248
|
-
* viewport.boundary = [0, 0, 500, 400];;
|
|
249
|
-
* ````
|
|
250
|
-
*
|
|
251
|
-
* ## Controlling rendering
|
|
252
|
-
*
|
|
253
|
-
* You can configure a Scene to perform multiple "passes" (renders) per frame. This is useful when we want to render the
|
|
254
|
-
* scene to multiple viewports, such as for stereo effects.
|
|
255
|
-
*
|
|
256
|
-
* In the example, below, we'll configure the Scene to render twice on each frame, each time to different viewport. We'll do this
|
|
257
|
-
* with a callback that intercepts the Scene before each render and sets its {@link Viewport} to a
|
|
258
|
-
* different portion of the canvas. By default, the Scene will clear the canvas only before the first render, allowing the
|
|
259
|
-
* two views to be shown on the canvas at the same time.
|
|
260
|
-
*
|
|
261
|
-
* ````Javascript
|
|
262
|
-
* var viewport = scene.viewport;
|
|
263
|
-
*
|
|
264
|
-
* // Configure Scene to render twice for each frame
|
|
265
|
-
* scene.passes = 2; // Default is 1
|
|
266
|
-
* scene.clearEachPass = false; // Default is false
|
|
267
|
-
*
|
|
268
|
-
* // Render to a separate viewport on each render
|
|
269
|
-
*
|
|
270
|
-
* var viewport = scene.viewport;
|
|
271
|
-
* viewport.autoBoundary = false;
|
|
272
|
-
*
|
|
273
|
-
* scene.on("rendering", function (e) {
|
|
274
|
-
* switch (e.pass) {
|
|
275
|
-
* case 0:
|
|
276
|
-
* viewport.boundary = [0, 0, 200, 200]; // xmin, ymin, width, height
|
|
277
|
-
* break;
|
|
278
|
-
*
|
|
279
|
-
* case 1:
|
|
280
|
-
* viewport.boundary = [200, 0, 200, 200];
|
|
281
|
-
* break;
|
|
282
|
-
* }
|
|
283
|
-
* });
|
|
284
|
-
*
|
|
285
|
-
* // We can also intercept the Scene after each render,
|
|
286
|
-
* // (though we're not using this for anything here)
|
|
287
|
-
* scene.on("rendered", function (e) {
|
|
288
|
-
* switch (e.pass) {
|
|
289
|
-
* case 0:
|
|
290
|
-
* break;
|
|
291
|
-
*
|
|
292
|
-
* case 1:
|
|
293
|
-
* break;
|
|
294
|
-
* }
|
|
295
|
-
* });
|
|
296
|
-
* ````
|
|
297
|
-
*
|
|
298
|
-
* ## Gamma correction
|
|
299
|
-
*
|
|
300
|
-
* Within its shaders, yjkkit performs shading calculations in linear space.
|
|
301
|
-
*
|
|
302
|
-
* By default, the Scene expects color textures (eg. {@link PhongMaterial#diffuseMap},
|
|
303
|
-
* {@link MetallicMaterial#baseColorMap} and {@link SpecularMaterial#diffuseMap}) to
|
|
304
|
-
* be in pre-multipled gamma space, so will convert those to linear space before they are used in shaders. Other textures are
|
|
305
|
-
* always expected to be in linear space.
|
|
306
|
-
*
|
|
307
|
-
* By default, the Scene will also gamma-correct its rendered output.
|
|
308
|
-
*
|
|
309
|
-
* You can configure the Scene to expect all those color textures to be linear space, so that it does not gamma-correct them:
|
|
310
|
-
*
|
|
311
|
-
* ````javascript
|
|
312
|
-
* scene.gammaInput = false;
|
|
313
|
-
* ````
|
|
314
|
-
*
|
|
315
|
-
* You would still need to gamma-correct the output, though, if it's going straight to the canvas, so normally we would
|
|
316
|
-
* leave that enabled:
|
|
317
|
-
*
|
|
318
|
-
* ````javascript
|
|
319
|
-
* scene.gammaOutput = true;
|
|
320
|
-
* ````
|
|
321
|
-
*
|
|
322
|
-
* See {@link Texture} for more information on texture encoding and gamma.
|
|
323
|
-
*
|
|
324
|
-
* @class Scene
|
|
325
|
-
*/
|
|
326
|
-
class Scene extends Component {
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
@private
|
|
330
|
-
*/
|
|
331
|
-
get type() {
|
|
332
|
-
return "Scene";
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* @private
|
|
337
|
-
* @constructor
|
|
338
|
-
* @param {Viewer} viewer The Viewer this Scene belongs to.
|
|
339
|
-
* @param {Object} cfg Scene configuration.
|
|
340
|
-
* @param {String} [cfg.canvasId] ID of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasElement is mandatory. When both values are given, the element reference is always preferred to the ID.
|
|
341
|
-
* @param {HTMLCanvasElement} [cfg.canvasElement] Reference of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasId is mandatory. When both values are given, the element reference is always preferred to the ID.
|
|
342
|
-
* @throws {String} Throws an exception when both canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
|
|
343
|
-
*/
|
|
344
|
-
constructor(viewer, cfg = {}) {
|
|
345
|
-
|
|
346
|
-
super(null, cfg);
|
|
347
|
-
|
|
348
|
-
const canvas = cfg.canvasElement || document.getElementById(cfg.canvasId);
|
|
349
|
-
|
|
350
|
-
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
351
|
-
throw "Mandatory config expected: valid canvasId or canvasElement";
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const transparent = (!!cfg.transparent);
|
|
355
|
-
const alphaDepthMask = (!!cfg.alphaDepthMask);
|
|
356
|
-
|
|
357
|
-
this._aabbDirty = true;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* The {@link Viewer} this Scene belongs to.
|
|
361
|
-
* @type {Viewer}
|
|
362
|
-
*/
|
|
363
|
-
this.viewer = viewer;
|
|
364
|
-
|
|
365
|
-
/** Decremented each frame, triggers occlusion test for occludable {@link Marker}s when zero.
|
|
366
|
-
* @private
|
|
367
|
-
* @type {number}
|
|
368
|
-
*/
|
|
369
|
-
this.occlusionTestCountdown = 0;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
The number of models currently loading.
|
|
373
|
-
|
|
374
|
-
@property loading
|
|
375
|
-
@final
|
|
376
|
-
@type {Number}
|
|
377
|
-
*/
|
|
378
|
-
this.loading = 0;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
The epoch time (in milliseconds since 1970) when this Scene was instantiated.
|
|
382
|
-
|
|
383
|
-
@property timeCreated
|
|
384
|
-
@final
|
|
385
|
-
@type {Number}
|
|
386
|
-
*/
|
|
387
|
-
this.startTime = (new Date()).getTime();
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Map of {@link Entity}s that represent models.
|
|
391
|
-
*
|
|
392
|
-
* Each {@link Entity} is mapped here by {@link Entity#id} when {@link Entity#isModel} is ````true````.
|
|
393
|
-
*
|
|
394
|
-
* @property models
|
|
395
|
-
* @final
|
|
396
|
-
* @type {{String:Entity}}
|
|
397
|
-
*/
|
|
398
|
-
this.models = {};
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Map of {@link Entity}s that represents objects.
|
|
402
|
-
*
|
|
403
|
-
* Each {@link Entity} is mapped here by {@link Entity#id} when {@link Entity#isObject} is ````true````.
|
|
404
|
-
*
|
|
405
|
-
* @property objects
|
|
406
|
-
* @final
|
|
407
|
-
* @type {{String:Entity}}
|
|
408
|
-
*/
|
|
409
|
-
this.objects = {};
|
|
410
|
-
this._numObjects = 0;
|
|
411
|
-
/**
|
|
412
|
-
* YJKNodes 盈建科构件
|
|
413
|
-
*/
|
|
414
|
-
this.yjkObjects = {};
|
|
415
|
-
this._numYJKObjects = 0;
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Map of currently visible {@link Entity}s that represent objects.
|
|
419
|
-
*
|
|
420
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true````, and is visible when {@link Entity#visible} is true.
|
|
421
|
-
*
|
|
422
|
-
* @property visibleObjects
|
|
423
|
-
* @final
|
|
424
|
-
* @type {{String:Object}}
|
|
425
|
-
*/
|
|
426
|
-
this.visibleObjects = {};
|
|
427
|
-
this._numVisibleObjects = 0;
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Map of currently xrayed {@link Entity}s that represent objects.
|
|
431
|
-
*
|
|
432
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true````, and is xrayed when {@link Entity#xrayed} is true.
|
|
433
|
-
*
|
|
434
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
435
|
-
*
|
|
436
|
-
* @property xrayedObjects
|
|
437
|
-
* @final
|
|
438
|
-
* @type {{String:Object}}
|
|
439
|
-
*/
|
|
440
|
-
this.xrayedObjects = {};
|
|
441
|
-
this._numXRayedObjects = 0;
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Map of currently highlighted {@link Entity}s that represent objects.
|
|
445
|
-
*
|
|
446
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true```` is true, and is highlighted when {@link Entity#highlighted} is true.
|
|
447
|
-
*
|
|
448
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
449
|
-
*
|
|
450
|
-
* @property highlightedObjects
|
|
451
|
-
* @final
|
|
452
|
-
* @type {{String:Object}}
|
|
453
|
-
*/
|
|
454
|
-
this.highlightedObjects = {};
|
|
455
|
-
this._numHighlightedObjects = 0;
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Map of currently selected {@link Entity}s that represent objects.
|
|
459
|
-
*
|
|
460
|
-
* An Entity represents an object if {@link Entity#isObject} is true, and is selected while {@link Entity#selected} is true.
|
|
461
|
-
*
|
|
462
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
463
|
-
*
|
|
464
|
-
* @property selectedObjects
|
|
465
|
-
* @final
|
|
466
|
-
* @type {{String:Object}}
|
|
467
|
-
*/
|
|
468
|
-
this.selectedObjects = {};
|
|
469
|
-
this._numSelectedObjects = 0;
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Map of currently colorized {@link Entity}s that represent objects.
|
|
473
|
-
*
|
|
474
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true````.
|
|
475
|
-
*
|
|
476
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
477
|
-
*
|
|
478
|
-
* @property colorizedObjects
|
|
479
|
-
* @final
|
|
480
|
-
* @type {{String:Object}}
|
|
481
|
-
*/
|
|
482
|
-
this.colorizedObjects = {};
|
|
483
|
-
this._numColorizedObjects = 0;
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Map of {@link Entity}s that represent objects whose opacity was updated.
|
|
487
|
-
*
|
|
488
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true````.
|
|
489
|
-
*
|
|
490
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
491
|
-
*
|
|
492
|
-
* @property opacityObjects
|
|
493
|
-
* @final
|
|
494
|
-
* @type {{String:Object}}
|
|
495
|
-
*/
|
|
496
|
-
this.opacityObjects = {};
|
|
497
|
-
this._numOpacityObjects = 0;
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Map of {@link Entity}s that represent objects whose {@link Entity#offset}s were updated.
|
|
501
|
-
*
|
|
502
|
-
* An Entity represents an object if {@link Entity#isObject} is ````true````.
|
|
503
|
-
*
|
|
504
|
-
* Each {@link Entity} is mapped here by {@link Entity#id}.
|
|
505
|
-
*
|
|
506
|
-
* @property offsetObjects
|
|
507
|
-
* @final
|
|
508
|
-
* @type {{String:Object}}
|
|
509
|
-
*/
|
|
510
|
-
this.offsetObjects = {};
|
|
511
|
-
this._numOffsetObjects = 0;
|
|
512
|
-
|
|
513
|
-
// Cached ID arrays, lazy-rebuilt as needed when stale after map updates
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
Lazy-regenerated ID lists.
|
|
517
|
-
*/
|
|
518
|
-
this._modelIds = null;
|
|
519
|
-
this._objectIds = null;
|
|
520
|
-
this._visibleObjectIds = null;
|
|
521
|
-
this._xrayedObjectIds = null;
|
|
522
|
-
this._highlightedObjectIds = null;
|
|
523
|
-
this._selectedObjectIds = null;
|
|
524
|
-
this._colorizedObjectIds = null;
|
|
525
|
-
this._opacityObjectIds = null;
|
|
526
|
-
this._offsetObjectIds = null;
|
|
527
|
-
|
|
528
|
-
this._collidables = {}; // Components that contribute to the Scene AABB
|
|
529
|
-
this._compilables = {}; // Components that require shader compilation
|
|
530
|
-
|
|
531
|
-
this._needRecompile = false;
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* For each {@link Component} type, a map of IDs to {@link Component} instances of that type.
|
|
535
|
-
*
|
|
536
|
-
* @type {{String:{String:Component}}}
|
|
537
|
-
*/
|
|
538
|
-
this.types = {};
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* The {@link Component}s within this Scene, each mapped to its {@link Component#id}.
|
|
542
|
-
*
|
|
543
|
-
* *@type {{String:Component}}
|
|
544
|
-
*/
|
|
545
|
-
this.components = {};
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* The {@link SectionPlane}s in this Scene, each mapped to its {@link SectionPlane#id}.
|
|
549
|
-
*
|
|
550
|
-
* @type {{String:SectionPlane}}
|
|
551
|
-
*/
|
|
552
|
-
this.sectionPlanes = {};
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* The {@link Light}s in this Scene, each mapped to its {@link Light#id}.
|
|
556
|
-
*
|
|
557
|
-
* @type {{String:Light}}
|
|
558
|
-
*/
|
|
559
|
-
this.lights = {};
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* The {@link LightMap}s in this Scene, each mapped to its {@link LightMap#id}.
|
|
563
|
-
*
|
|
564
|
-
* @type {{String:LightMap}}
|
|
565
|
-
*/
|
|
566
|
-
this.lightMaps = {};
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* The {@link ReflectionMap}s in this Scene, each mapped to its {@link ReflectionMap#id}.
|
|
570
|
-
*
|
|
571
|
-
* @type {{String:ReflectionMap}}
|
|
572
|
-
*/
|
|
573
|
-
this.reflectionMaps = {};
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* The real world offset for this Scene
|
|
577
|
-
*
|
|
578
|
-
* @type {Number[]}
|
|
579
|
-
*/
|
|
580
|
-
this.realWorldOffset = cfg.realWorldOffset || new Float64Array([0, 0, 0]);
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Manages the HTML5 canvas for this Scene.
|
|
584
|
-
*
|
|
585
|
-
* @type {Canvas}
|
|
586
|
-
*/
|
|
587
|
-
this.canvas = new Canvas(this, {
|
|
588
|
-
dontClear: true, // Never destroy this component with Scene#clear();
|
|
589
|
-
canvas: canvas,
|
|
590
|
-
spinnerElementId: cfg.spinnerElementId,
|
|
591
|
-
transparent: transparent,
|
|
592
|
-
webgl2: cfg.webgl2 !== false,
|
|
593
|
-
contextAttr: cfg.contextAttr || {},
|
|
594
|
-
backgroundColor: cfg.backgroundColor,
|
|
595
|
-
backgroundColorFromAmbientLight: cfg.backgroundColorFromAmbientLight,
|
|
596
|
-
premultipliedAlpha: cfg.premultipliedAlpha
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
this.canvas.on("boundary", () => {
|
|
600
|
-
this.glRedraw();
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
this.canvas.on("webglContextFailed", () => {
|
|
604
|
-
alert("yjkkit failed to find WebGL!");
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
this._renderer = new Renderer(this, {
|
|
608
|
-
transparent: transparent,
|
|
609
|
-
alphaDepthMask: alphaDepthMask
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
this._sectionPlanesState = new (function () {
|
|
613
|
-
|
|
614
|
-
this.sectionPlanes = [];
|
|
615
|
-
|
|
616
|
-
this.clippingCaps = false;
|
|
617
|
-
|
|
618
|
-
let hash = null;
|
|
619
|
-
|
|
620
|
-
this.getHash = function () {
|
|
621
|
-
if (hash) {
|
|
622
|
-
return hash;
|
|
623
|
-
}
|
|
624
|
-
const sectionPlanes = this.sectionPlanes;
|
|
625
|
-
if (sectionPlanes.length === 0) {
|
|
626
|
-
return this.hash = ";";
|
|
627
|
-
}
|
|
628
|
-
let sectionPlane;
|
|
629
|
-
|
|
630
|
-
const hashParts = [];
|
|
631
|
-
for (let i = 0, len = sectionPlanes.length; i < len; i++) {
|
|
632
|
-
sectionPlane = sectionPlanes[i];
|
|
633
|
-
hashParts.push("cp");
|
|
634
|
-
}
|
|
635
|
-
hashParts.push(";");
|
|
636
|
-
hash = hashParts.join("");
|
|
637
|
-
return hash;
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
this.addSectionPlane = function (sectionPlane) {
|
|
641
|
-
this.sectionPlanes.push(sectionPlane);
|
|
642
|
-
hash = null;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
this.removeSectionPlane = function (sectionPlane) {
|
|
646
|
-
for (let i = 0, len = this.sectionPlanes.length; i < len; i++) {
|
|
647
|
-
if (this.sectionPlanes[i].id === sectionPlane.id) {
|
|
648
|
-
this.sectionPlanes.splice(i, 1);
|
|
649
|
-
hash = null;
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
})();
|
|
655
|
-
|
|
656
|
-
this._lightsState = new (function () {
|
|
657
|
-
|
|
658
|
-
const DEFAULT_AMBIENT = math.vec4([0, 0, 0, 0]);
|
|
659
|
-
const ambientColorIntensity = math.vec4();
|
|
660
|
-
|
|
661
|
-
this.lights = [];
|
|
662
|
-
this.reflectionMaps = [];
|
|
663
|
-
this.lightMaps = [];
|
|
664
|
-
|
|
665
|
-
let hash = null;
|
|
666
|
-
let ambientLight = null;
|
|
667
|
-
|
|
668
|
-
this.getHash = function () {
|
|
669
|
-
if (hash) {
|
|
670
|
-
return hash;
|
|
671
|
-
}
|
|
672
|
-
const hashParts = [];
|
|
673
|
-
const lights = this.lights;
|
|
674
|
-
let light;
|
|
675
|
-
for (let i = 0, len = lights.length; i < len; i++) {
|
|
676
|
-
light = lights[i];
|
|
677
|
-
hashParts.push("/");
|
|
678
|
-
hashParts.push(light.type);
|
|
679
|
-
hashParts.push((light.space === "world") ? "w" : "v");
|
|
680
|
-
if (light.castsShadow) {
|
|
681
|
-
hashParts.push("sh");
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
if (this.lightMaps.length > 0) {
|
|
685
|
-
hashParts.push("/lm");
|
|
686
|
-
}
|
|
687
|
-
if (this.reflectionMaps.length > 0) {
|
|
688
|
-
hashParts.push("/rm");
|
|
689
|
-
}
|
|
690
|
-
hashParts.push(";");
|
|
691
|
-
hash = hashParts.join("");
|
|
692
|
-
return hash;
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
this.addLight = function (state) {
|
|
696
|
-
this.lights.push(state);
|
|
697
|
-
ambientLight = null;
|
|
698
|
-
hash = null;
|
|
699
|
-
};
|
|
700
|
-
|
|
701
|
-
this.removeLight = function (state) {
|
|
702
|
-
for (let i = 0, len = this.lights.length; i < len; i++) {
|
|
703
|
-
const light = this.lights[i];
|
|
704
|
-
if (light.id === state.id) {
|
|
705
|
-
this.lights.splice(i, 1);
|
|
706
|
-
if (ambientLight && ambientLight.id === state.id) {
|
|
707
|
-
ambientLight = null;
|
|
708
|
-
}
|
|
709
|
-
hash = null;
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
this.addReflectionMap = function (state) {
|
|
716
|
-
this.reflectionMaps.push(state);
|
|
717
|
-
hash = null;
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
this.removeReflectionMap = function (state) {
|
|
721
|
-
for (let i = 0, len = this.reflectionMaps.length; i < len; i++) {
|
|
722
|
-
if (this.reflectionMaps[i].id === state.id) {
|
|
723
|
-
this.reflectionMaps.splice(i, 1);
|
|
724
|
-
hash = null;
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
this.addLightMap = function (state) {
|
|
731
|
-
this.lightMaps.push(state);
|
|
732
|
-
hash = null;
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
this.removeLightMap = function (state) {
|
|
736
|
-
for (let i = 0, len = this.lightMaps.length; i < len; i++) {
|
|
737
|
-
if (this.lightMaps[i].id === state.id) {
|
|
738
|
-
this.lightMaps.splice(i, 1);
|
|
739
|
-
hash = null;
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
this.getAmbientColorAndIntensity = function () {
|
|
746
|
-
if (!ambientLight) {
|
|
747
|
-
for (let i = 0, len = this.lights.length; i < len; i++) {
|
|
748
|
-
const light = this.lights[i];
|
|
749
|
-
if (light.type === "ambient") {
|
|
750
|
-
ambientLight = light;
|
|
751
|
-
break;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
if (ambientLight) {
|
|
756
|
-
const color = ambientLight.color;
|
|
757
|
-
const intensity = ambientLight.intensity;
|
|
758
|
-
ambientColorIntensity[0] = color[0] * intensity;
|
|
759
|
-
ambientColorIntensity[1] = color[1] * intensity;
|
|
760
|
-
ambientColorIntensity[2] = color[2] * intensity;
|
|
761
|
-
ambientColorIntensity[3] = intensity;
|
|
762
|
-
return ambientColorIntensity;
|
|
763
|
-
} else {
|
|
764
|
-
return DEFAULT_AMBIENT;
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
})();
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Publishes input events that occur on this Scene's canvas.
|
|
772
|
-
*
|
|
773
|
-
* @property input
|
|
774
|
-
* @type {Input}
|
|
775
|
-
* @final
|
|
776
|
-
*/
|
|
777
|
-
this.input = new Input(this, {
|
|
778
|
-
dontClear: true, // Never destroy this component with Scene#clear();
|
|
779
|
-
element: this.canvas.canvas
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Configures this Scene's units of measurement and coordinate mapping between Real-space and World-space 3D coordinate systems.
|
|
784
|
-
*
|
|
785
|
-
* @property metrics
|
|
786
|
-
* @type {Metrics}
|
|
787
|
-
* @final
|
|
788
|
-
*/
|
|
789
|
-
this.metrics = new Metrics(this, {
|
|
790
|
-
units: cfg.units,
|
|
791
|
-
scale: cfg.scale,
|
|
792
|
-
origin: cfg.origin
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
/** Configures Scalable Ambient Obscurance (SAO) for this Scene.
|
|
796
|
-
* @type {SAO}
|
|
797
|
-
* @final
|
|
798
|
-
*/
|
|
799
|
-
this.sao = new SAO(this, {
|
|
800
|
-
enabled: cfg.saoEnabled
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
this.ticksPerRender = cfg.ticksPerRender;
|
|
804
|
-
this.ticksPerOcclusionTest = cfg.ticksPerOcclusionTest;
|
|
805
|
-
this.passes = cfg.passes;
|
|
806
|
-
this.clearEachPass = cfg.clearEachPass;
|
|
807
|
-
this.gammaInput = cfg.gammaInput;
|
|
808
|
-
this.gammaOutput = cfg.gammaOutput;
|
|
809
|
-
this.gammaFactor = cfg.gammaFactor;
|
|
810
|
-
|
|
811
|
-
this._entityOffsetsEnabled = !!cfg.entityOffsetsEnabled;
|
|
812
|
-
this._logarithmicDepthBufferEnabled = !!cfg.logarithmicDepthBufferEnabled;
|
|
813
|
-
|
|
814
|
-
this._pbrEnabled = !!cfg.pbrEnabled;
|
|
815
|
-
|
|
816
|
-
// Register Scene on yjkkit
|
|
817
|
-
// Do this BEFORE we add components below
|
|
818
|
-
core._addScene(this);
|
|
819
|
-
|
|
820
|
-
this._initDefaults();
|
|
821
|
-
|
|
822
|
-
// Global components
|
|
823
|
-
|
|
824
|
-
this._viewport = new Viewport(this, {
|
|
825
|
-
id: "default.viewport",
|
|
826
|
-
autoBoundary: true,
|
|
827
|
-
dontClear: true // Never destroy this component with Scene#clear();
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
this._camera = new Camera(this, {
|
|
831
|
-
id: "default.camera",
|
|
832
|
-
dontClear: true // Never destroy this component with Scene#clear();
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
// Default lights
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
new AmbientLight(this, {
|
|
840
|
-
color: [1.0, 1.0, 1.0],
|
|
841
|
-
intensity: 0.7
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
new DirLight(this, {
|
|
845
|
-
dir: [0.8, -0.6, -0.8],
|
|
846
|
-
color: [1.0, 1.0, 1.0],
|
|
847
|
-
intensity: 0.9,
|
|
848
|
-
space: "view"
|
|
849
|
-
});
|
|
850
|
-
|
|
851
|
-
new DirLight(this, {
|
|
852
|
-
dir: [-0.8, -0.4, -0.4],
|
|
853
|
-
color: [1.0, 1.0, 1.0],
|
|
854
|
-
intensity: 0.7,
|
|
855
|
-
space: "view"
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
new DirLight(this, {
|
|
859
|
-
dir: [0.2, -0.8, 0.8],
|
|
860
|
-
color: [0.7, 0.7, 0.7],
|
|
861
|
-
intensity: 0.9,
|
|
862
|
-
space: "view"
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this._camera.on("dirty", () => {
|
|
867
|
-
this._renderer.imageDirty();
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
_initDefaults() {
|
|
872
|
-
|
|
873
|
-
// Call this Scene's property accessors to lazy-init their properties
|
|
874
|
-
|
|
875
|
-
let dummy; // Keeps Codacy happy
|
|
876
|
-
|
|
877
|
-
dummy = this.geometry;
|
|
878
|
-
dummy = this.material;
|
|
879
|
-
dummy = this.xrayMaterial;
|
|
880
|
-
dummy = this.edgeMaterial;
|
|
881
|
-
dummy = this.selectedMaterial;
|
|
882
|
-
dummy = this.highlightMaterial;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
_addComponent(component) {
|
|
886
|
-
if (component.id) { // Manual ID
|
|
887
|
-
if (this.components[component.id]) {
|
|
888
|
-
this.error("Component " + utils.inQuotes(component.id) + " already exists in Scene - ignoring ID, will randomly-generate instead");
|
|
889
|
-
component.id = null;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
if (!component.id) { // Auto ID
|
|
893
|
-
if (window.nextID === undefined) {
|
|
894
|
-
window.nextID = 0;
|
|
895
|
-
}
|
|
896
|
-
//component.id = math.createUUID();
|
|
897
|
-
component.id = "__" + window.nextID++;
|
|
898
|
-
while (this.components[component.id]) {
|
|
899
|
-
component.id = math.createUUID();
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
this.components[component.id] = component;
|
|
903
|
-
|
|
904
|
-
// Register for class type
|
|
905
|
-
const type = component.type;
|
|
906
|
-
let types = this.types[component.type];
|
|
907
|
-
if (!types) {
|
|
908
|
-
types = this.types[type] = {};
|
|
909
|
-
}
|
|
910
|
-
types[component.id] = component;
|
|
911
|
-
|
|
912
|
-
if (component.compile) {
|
|
913
|
-
this._compilables[component.id] = component;
|
|
914
|
-
}
|
|
915
|
-
if (component.isDrawable) {
|
|
916
|
-
this._renderer.addDrawable(component.id, component);
|
|
917
|
-
this._collidables[component.id] = component;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
_removeComponent(component) {
|
|
922
|
-
var id = component.id;
|
|
923
|
-
var type = component.type;
|
|
924
|
-
delete this.components[id];
|
|
925
|
-
// Unregister for types
|
|
926
|
-
const types = this.types[type];
|
|
927
|
-
if (types) {
|
|
928
|
-
delete types[id];
|
|
929
|
-
if (utils.isEmptyObject(types)) {
|
|
930
|
-
delete this.types[type];
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
if (component.compile) {
|
|
934
|
-
delete this._compilables[component.id];
|
|
935
|
-
}
|
|
936
|
-
if (component.isDrawable) {
|
|
937
|
-
this._renderer.removeDrawable(component.id);
|
|
938
|
-
delete this._collidables[component.id];
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// Methods below are called by various component types to register themselves on their
|
|
943
|
-
// Scene. Violates Hollywood Principle, where we could just filter on type in _addComponent,
|
|
944
|
-
// but this is faster than checking the type of each component in such a filter.
|
|
945
|
-
|
|
946
|
-
_sectionPlaneCreated(sectionPlane) {
|
|
947
|
-
this.sectionPlanes[sectionPlane.id] = sectionPlane;
|
|
948
|
-
this.scene._sectionPlanesState.addSectionPlane(sectionPlane._state);
|
|
949
|
-
this.scene.fire("sectionPlaneCreated", sectionPlane, true /* Don't retain event */);
|
|
950
|
-
this._needRecompile = true;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
_lightCreated(light) {
|
|
954
|
-
this.lights[light.id] = light;
|
|
955
|
-
this.scene._lightsState.addLight(light._state);
|
|
956
|
-
this._needRecompile = true;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
_lightMapCreated(lightMap) {
|
|
960
|
-
this.lightMaps[lightMap.id] = lightMap;
|
|
961
|
-
this.scene._lightsState.addLightMap(lightMap._state);
|
|
962
|
-
this._needRecompile = true;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
_reflectionMapCreated(reflectionMap) {
|
|
966
|
-
this.reflectionMaps[reflectionMap.id] = reflectionMap;
|
|
967
|
-
this.scene._lightsState.addReflectionMap(reflectionMap._state);
|
|
968
|
-
this._needRecompile = true;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
_sectionPlaneDestroyed(sectionPlane) {
|
|
972
|
-
delete this.sectionPlanes[sectionPlane.id];
|
|
973
|
-
this.scene._sectionPlanesState.removeSectionPlane(sectionPlane._state);
|
|
974
|
-
this.scene.fire("sectionPlaneDestroyed", sectionPlane, true /* Don't retain event */);
|
|
975
|
-
this._needRecompile = true;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
_lightDestroyed(light) {
|
|
979
|
-
delete this.lights[light.id];
|
|
980
|
-
this.scene._lightsState.removeLight(light._state);
|
|
981
|
-
this._needRecompile = true;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
_lightMapDestroyed(lightMap) {
|
|
985
|
-
delete this.lightMaps[lightMap.id];
|
|
986
|
-
this.scene._lightsState.removeLightMap(lightMap._state);
|
|
987
|
-
this._needRecompile = true;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
_reflectionMapDestroyed(reflectionMap) {
|
|
991
|
-
delete this.reflectionMaps[reflectionMap.id];
|
|
992
|
-
this.scene._lightsState.removeReflectionMap(reflectionMap._state);
|
|
993
|
-
this._needRecompile = true;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
_registerModel(entity) {
|
|
997
|
-
this.models[entity.id] = entity;
|
|
998
|
-
this._modelIds = null; // Lazy regenerate
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
_deregisterModel(entity) {
|
|
1002
|
-
delete this.models[entity.id];
|
|
1003
|
-
this._modelIds = null; // Lazy regenerate
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
_registerObject(entity) {
|
|
1007
|
-
this.objects[entity.id] = entity;
|
|
1008
|
-
this._numObjects++;
|
|
1009
|
-
this._objectIds = null; // Lazy regenerate
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
_deregisterObject(entity) {
|
|
1013
|
-
delete this.objects[entity.id];
|
|
1014
|
-
this._numObjects--;
|
|
1015
|
-
this._objectIds = null; // Lazy regenerate
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* 注册 yjkObject
|
|
1020
|
-
* @param entity
|
|
1021
|
-
* @private
|
|
1022
|
-
*/
|
|
1023
|
-
_registeryjkObject(entity) {
|
|
1024
|
-
this.yjkObjects[entity.yjkElementId] = entity;
|
|
1025
|
-
this._numYJKObjects++;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* 取消 yjkObject
|
|
1030
|
-
* @param entity
|
|
1031
|
-
* @private
|
|
1032
|
-
*/
|
|
1033
|
-
_deregisteryjkObject(entity) {
|
|
1034
|
-
delete this.yjkObjects[entity.yjkElementId];
|
|
1035
|
-
this._numYJKObjects--;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
_objectVisibilityUpdated(entity, notify = true) {
|
|
1039
|
-
if (entity.visible) {
|
|
1040
|
-
if (ASSERT_OBJECT_STATE_UPDATE && this.visibleObjects[entity.id]) {
|
|
1041
|
-
console.error("Redundant object visibility update (visible=true)");
|
|
1042
|
-
return;
|
|
1043
|
-
}
|
|
1044
|
-
this.visibleObjects[entity.id] = entity;
|
|
1045
|
-
this._numVisibleObjects++;
|
|
1046
|
-
} else {
|
|
1047
|
-
if (ASSERT_OBJECT_STATE_UPDATE && (!this.visibleObjects[entity.id])) {
|
|
1048
|
-
console.error("Redundant object visibility update (visible=false)");
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
delete this.visibleObjects[entity.id];
|
|
1052
|
-
this._numVisibleObjects--;
|
|
1053
|
-
}
|
|
1054
|
-
this._visibleObjectIds = null; // Lazy regenerate
|
|
1055
|
-
if (notify) {
|
|
1056
|
-
this.fire("objectVisibility", entity, true);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
_objectXRayedUpdated(entity) {
|
|
1061
|
-
if (entity.xrayed) {
|
|
1062
|
-
if (ASSERT_OBJECT_STATE_UPDATE && this.xrayedObjects[entity.id]) {
|
|
1063
|
-
console.error("Redundant object xray update (xrayed=true)");
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
this.xrayedObjects[entity.id] = entity;
|
|
1067
|
-
this._numXRayedObjects++;
|
|
1068
|
-
} else {
|
|
1069
|
-
if (ASSERT_OBJECT_STATE_UPDATE && (!this.xrayedObjects[entity.id])) {
|
|
1070
|
-
console.error("Redundant object xray update (xrayed=false)");
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1073
|
-
delete this.xrayedObjects[entity.id];
|
|
1074
|
-
this._numXRayedObjects--;
|
|
1075
|
-
}
|
|
1076
|
-
this._xrayedObjectIds = null; // Lazy regenerate
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
_objectHighlightedUpdated(entity) {
|
|
1080
|
-
if (entity.highlighted) {
|
|
1081
|
-
if (ASSERT_OBJECT_STATE_UPDATE && this.highlightedObjects[entity.id]) {
|
|
1082
|
-
console.error("Redundant object highlight update (highlighted=true)");
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
this.highlightedObjects[entity.id] = entity;
|
|
1086
|
-
this._numHighlightedObjects++;
|
|
1087
|
-
} else {
|
|
1088
|
-
if (ASSERT_OBJECT_STATE_UPDATE && (!this.highlightedObjects[entity.id])) {
|
|
1089
|
-
console.error("Redundant object highlight update (highlighted=false)");
|
|
1090
|
-
return;
|
|
1091
|
-
}
|
|
1092
|
-
delete this.highlightedObjects[entity.id];
|
|
1093
|
-
this._numHighlightedObjects--;
|
|
1094
|
-
}
|
|
1095
|
-
this._highlightedObjectIds = null; // Lazy regenerate
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
_objectSelectedUpdated(entity) {
|
|
1099
|
-
if (entity.selected) {
|
|
1100
|
-
if (ASSERT_OBJECT_STATE_UPDATE && this.selectedObjects[entity.id]) {
|
|
1101
|
-
console.error("Redundant object select update (selected=true)");
|
|
1102
|
-
return;
|
|
1103
|
-
}
|
|
1104
|
-
this.selectedObjects[entity.id] = entity;
|
|
1105
|
-
this._numSelectedObjects++;
|
|
1106
|
-
} else {
|
|
1107
|
-
if (ASSERT_OBJECT_STATE_UPDATE && (!this.selectedObjects[entity.id])) {
|
|
1108
|
-
console.error("Redundant object select update (selected=false)");
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
delete this.selectedObjects[entity.id];
|
|
1112
|
-
this._numSelectedObjects--;
|
|
1113
|
-
}
|
|
1114
|
-
this._selectedObjectIds = null; // Lazy regenerate
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
_objectColorizeUpdated(entity, colorized) {
|
|
1118
|
-
if (colorized) {
|
|
1119
|
-
this.colorizedObjects[entity.id] = entity;
|
|
1120
|
-
this._numColorizedObjects++;
|
|
1121
|
-
} else {
|
|
1122
|
-
delete this.colorizedObjects[entity.id];
|
|
1123
|
-
this._numColorizedObjects--;
|
|
1124
|
-
}
|
|
1125
|
-
this._colorizedObjectIds = null; // Lazy regenerate
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
_objectOpacityUpdated(entity, opacityUpdated) {
|
|
1129
|
-
if (opacityUpdated) {
|
|
1130
|
-
this.opacityObjects[entity.id] = entity;
|
|
1131
|
-
this._numOpacityObjects++;
|
|
1132
|
-
} else {
|
|
1133
|
-
delete this.opacityObjects[entity.id];
|
|
1134
|
-
this._numOpacityObjects--;
|
|
1135
|
-
}
|
|
1136
|
-
this._opacityObjectIds = null; // Lazy regenerate
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
_objectOffsetUpdated(entity, offset) {
|
|
1140
|
-
if (!offset || offset[0] === 0 && offset[1] === 0 && offset[2] === 0) {
|
|
1141
|
-
this.offsetObjects[entity.id] = entity;
|
|
1142
|
-
this._numOffsetObjects++;
|
|
1143
|
-
} else {
|
|
1144
|
-
delete this.offsetObjects[entity.id];
|
|
1145
|
-
this._numOffsetObjects--;
|
|
1146
|
-
}
|
|
1147
|
-
this._offsetObjectIds = null; // Lazy regenerate
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
_webglContextLost() {
|
|
1151
|
-
// this.loading++;
|
|
1152
|
-
this.canvas.spinner.processes++;
|
|
1153
|
-
for (const id in this.components) {
|
|
1154
|
-
if (this.components.hasOwnProperty(id)) {
|
|
1155
|
-
const component = this.components[id];
|
|
1156
|
-
if (component._webglContextLost) {
|
|
1157
|
-
component._webglContextLost();
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
this._renderer.webglContextLost();
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
_webglContextRestored() {
|
|
1165
|
-
const gl = this.canvas.gl;
|
|
1166
|
-
for (const id in this.components) {
|
|
1167
|
-
if (this.components.hasOwnProperty(id)) {
|
|
1168
|
-
const component = this.components[id];
|
|
1169
|
-
if (component._webglContextRestored) {
|
|
1170
|
-
component._webglContextRestored(gl);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
this._renderer.webglContextRestored(gl);
|
|
1175
|
-
//this.loading--;
|
|
1176
|
-
this.canvas.spinner.processes--;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* Whether {@link Entity#offset} is enabled.
|
|
1181
|
-
*
|
|
1182
|
-
* This is set via the {@link Viewer} constructor and is ````false```` by default.
|
|
1183
|
-
*
|
|
1184
|
-
* @returns {Boolean} True if {@link Entity#offset} is enabled.
|
|
1185
|
-
*/
|
|
1186
|
-
get entityOffsetsEnabled() {
|
|
1187
|
-
return this._entityOffsetsEnabled;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
/**
|
|
1191
|
-
* Whether logarithmic depth buffer is enabled.
|
|
1192
|
-
*
|
|
1193
|
-
* This is set via the {@link Viewer} constructor and is ````false```` by default.
|
|
1194
|
-
*
|
|
1195
|
-
* @returns {Boolean} True if logarithmic depth buffer is enabled.
|
|
1196
|
-
*/
|
|
1197
|
-
get logarithmicDepthBufferEnabled() {
|
|
1198
|
-
return this._logarithmicDepthBufferEnabled;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
/**
|
|
1202
|
-
* Sets whether physically-based rendering is enabled.
|
|
1203
|
-
*
|
|
1204
|
-
* Default is ````false````.
|
|
1205
|
-
*
|
|
1206
|
-
* @returns {Boolean} True if quality rendering is enabled.
|
|
1207
|
-
*/
|
|
1208
|
-
set pbrEnabled(pbrEnabled) {
|
|
1209
|
-
this._pbrEnabled = !!pbrEnabled;
|
|
1210
|
-
this.glRedraw();
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Sets whether quality rendering is enabled.
|
|
1215
|
-
*
|
|
1216
|
-
* Default is ````false````.
|
|
1217
|
-
*
|
|
1218
|
-
* @returns {Boolean} True if quality rendering is enabled.
|
|
1219
|
-
*/
|
|
1220
|
-
get pbrEnabled() {
|
|
1221
|
-
return this._pbrEnabled;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
/**
|
|
1225
|
-
* Performs an occlusion test on all {@link Marker}s in this {@link Scene}.
|
|
1226
|
-
*
|
|
1227
|
-
* Sets each {@link Marker#visible} ````true```` if the Marker is currently not occluded by any opaque {@link Entity}s
|
|
1228
|
-
* in the Scene, or ````false```` if an Entity is occluding it.
|
|
1229
|
-
*/
|
|
1230
|
-
doOcclusionTest() {
|
|
1231
|
-
if (this._needRecompile) {
|
|
1232
|
-
this._recompile();
|
|
1233
|
-
this._needRecompile = false;
|
|
1234
|
-
}
|
|
1235
|
-
this._renderer.doOcclusionTest();
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* Renders a single frame of this Scene.
|
|
1240
|
-
*
|
|
1241
|
-
* The Scene will periodically render itself after any updates, but you can call this method to force a render
|
|
1242
|
-
* if required.
|
|
1243
|
-
*
|
|
1244
|
-
* @param {Boolean} [forceRender=false] Forces a render when true, otherwise only renders if something has changed in this Scene
|
|
1245
|
-
* since the last render.
|
|
1246
|
-
*/
|
|
1247
|
-
render(forceRender) {
|
|
1248
|
-
|
|
1249
|
-
if (forceRender) {
|
|
1250
|
-
core.runTasks();
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
const renderEvent = {
|
|
1254
|
-
sceneId: null,
|
|
1255
|
-
pass: 0
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
|
-
if (this._needRecompile) {
|
|
1259
|
-
this._recompile();
|
|
1260
|
-
this._renderer.imageDirty();
|
|
1261
|
-
this._needRecompile = false;
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
renderEvent.sceneId = this.id;
|
|
1265
|
-
|
|
1266
|
-
const passes = this._passes;
|
|
1267
|
-
const clearEachPass = this._clearEachPass;
|
|
1268
|
-
let pass;
|
|
1269
|
-
let clear;
|
|
1270
|
-
|
|
1271
|
-
for (pass = 0; pass < passes; pass++) {
|
|
1272
|
-
|
|
1273
|
-
renderEvent.pass = pass;
|
|
1274
|
-
|
|
1275
|
-
/**
|
|
1276
|
-
* Fired when about to render a frame for a Scene.
|
|
1277
|
-
*
|
|
1278
|
-
* @event rendering
|
|
1279
|
-
* @param {String} sceneID The ID of this Scene.
|
|
1280
|
-
* @param {Number} pass Index of the pass we are about to render (see {@link Scene#passes}).
|
|
1281
|
-
*/
|
|
1282
|
-
this.fire("rendering", renderEvent, true);
|
|
1283
|
-
|
|
1284
|
-
clear = clearEachPass || (pass === 0);
|
|
1285
|
-
|
|
1286
|
-
this._renderer.render({pass: pass, clear: clear, force: forceRender});
|
|
1287
|
-
|
|
1288
|
-
/**
|
|
1289
|
-
* Fired when we have just rendered a frame for a Scene.
|
|
1290
|
-
*
|
|
1291
|
-
* @event rendering
|
|
1292
|
-
* @param {String} sceneID The ID of this Scene.
|
|
1293
|
-
* @param {Number} pass Index of the pass we rendered (see {@link Scene#passes}).
|
|
1294
|
-
*/
|
|
1295
|
-
this.fire("rendered", renderEvent, true);
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
this._saveAmbientColor();
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
_recompile() {
|
|
1302
|
-
for (const id in this._compilables) {
|
|
1303
|
-
if (this._compilables.hasOwnProperty(id)) {
|
|
1304
|
-
this._compilables[id].compile();
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
this._renderer.shadowsDirty();
|
|
1308
|
-
this.fire("compile", this, true);
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
_saveAmbientColor() {
|
|
1312
|
-
const canvas = this.canvas;
|
|
1313
|
-
if (!canvas.transparent && !canvas.backgroundImage && !canvas.backgroundColor) {
|
|
1314
|
-
const ambientColorIntensity = this._lightsState.getAmbientColorAndIntensity();
|
|
1315
|
-
if (!this._lastAmbientColor ||
|
|
1316
|
-
this._lastAmbientColor[0] !== ambientColorIntensity[0] ||
|
|
1317
|
-
this._lastAmbientColor[1] !== ambientColorIntensity[1] ||
|
|
1318
|
-
this._lastAmbientColor[2] !== ambientColorIntensity[2] ||
|
|
1319
|
-
this._lastAmbientColor[3] !== ambientColorIntensity[3]) {
|
|
1320
|
-
canvas.backgroundColor = ambientColorIntensity;
|
|
1321
|
-
if (!this._lastAmbientColor) {
|
|
1322
|
-
this._lastAmbientColor = math.vec4([0, 0, 0, 1]);
|
|
1323
|
-
}
|
|
1324
|
-
this._lastAmbientColor.set(ambientColorIntensity);
|
|
1325
|
-
}
|
|
1326
|
-
} else {
|
|
1327
|
-
this._lastAmbientColor = null;
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#models}.
|
|
1333
|
-
*
|
|
1334
|
-
* @type {String[]}
|
|
1335
|
-
*/
|
|
1336
|
-
get modelIds() {
|
|
1337
|
-
if (!this._modelIds) {
|
|
1338
|
-
this._modelIds = Object.keys(this.models);
|
|
1339
|
-
}
|
|
1340
|
-
return this._modelIds;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Gets the number of {@link Entity}s in {@link Scene#objects}.
|
|
1345
|
-
*
|
|
1346
|
-
* @type {Number}
|
|
1347
|
-
*/
|
|
1348
|
-
get numObjects() {
|
|
1349
|
-
return this._numObjects;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
/**
|
|
1353
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#objects}.
|
|
1354
|
-
*
|
|
1355
|
-
* @type {String[]}
|
|
1356
|
-
*/
|
|
1357
|
-
get objectIds() {
|
|
1358
|
-
if (!this._objectIds) {
|
|
1359
|
-
this._objectIds = Object.keys(this.objects);
|
|
1360
|
-
}
|
|
1361
|
-
return this._objectIds;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
/**
|
|
1365
|
-
* Gets the number of {@link Entity}s in {@link Scene#visibleObjects}.
|
|
1366
|
-
*
|
|
1367
|
-
* @type {Number}
|
|
1368
|
-
*/
|
|
1369
|
-
get numVisibleObjects() {
|
|
1370
|
-
return this._numVisibleObjects;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
/**
|
|
1374
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#visibleObjects}.
|
|
1375
|
-
*
|
|
1376
|
-
* @type {String[]}
|
|
1377
|
-
*/
|
|
1378
|
-
get visibleObjectIds() {
|
|
1379
|
-
if (!this._visibleObjectIds) {
|
|
1380
|
-
this._visibleObjectIds = Object.keys(this.visibleObjects);
|
|
1381
|
-
}
|
|
1382
|
-
return this._visibleObjectIds;
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* Gets the number of {@link Entity}s in {@link Scene#xrayedObjects}.
|
|
1387
|
-
*
|
|
1388
|
-
* @type {Number}
|
|
1389
|
-
*/
|
|
1390
|
-
get numXRayedObjects() {
|
|
1391
|
-
return this._numXRayedObjects;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
/**
|
|
1395
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#xrayedObjects}.
|
|
1396
|
-
*
|
|
1397
|
-
* @type {String[]}
|
|
1398
|
-
*/
|
|
1399
|
-
get xrayedObjectIds() {
|
|
1400
|
-
if (!this._xrayedObjectIds) {
|
|
1401
|
-
this._xrayedObjectIds = Object.keys(this.xrayedObjects);
|
|
1402
|
-
}
|
|
1403
|
-
return this._xrayedObjectIds;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
/**
|
|
1407
|
-
* Gets the number of {@link Entity}s in {@link Scene#highlightedObjects}.
|
|
1408
|
-
*
|
|
1409
|
-
* @type {Number}
|
|
1410
|
-
*/
|
|
1411
|
-
get numHighlightedObjects() {
|
|
1412
|
-
return this._numHighlightedObjects;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
/**
|
|
1416
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#highlightedObjects}.
|
|
1417
|
-
*
|
|
1418
|
-
* @type {String[]}
|
|
1419
|
-
*/
|
|
1420
|
-
get highlightedObjectIds() {
|
|
1421
|
-
if (!this._highlightedObjectIds) {
|
|
1422
|
-
this._highlightedObjectIds = Object.keys(this.highlightedObjects);
|
|
1423
|
-
}
|
|
1424
|
-
return this._highlightedObjectIds;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
/**
|
|
1428
|
-
* Gets the number of {@link Entity}s in {@link Scene#selectedObjects}.
|
|
1429
|
-
*
|
|
1430
|
-
* @type {Number}
|
|
1431
|
-
*/
|
|
1432
|
-
get numSelectedObjects() {
|
|
1433
|
-
return this._numSelectedObjects;
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
/**
|
|
1437
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#selectedObjects}.
|
|
1438
|
-
*
|
|
1439
|
-
* @type {String[]}
|
|
1440
|
-
*/
|
|
1441
|
-
get selectedObjectIds() {
|
|
1442
|
-
if (!this._selectedObjectIds) {
|
|
1443
|
-
this._selectedObjectIds = Object.keys(this.selectedObjects);
|
|
1444
|
-
}
|
|
1445
|
-
return this._selectedObjectIds;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
/**
|
|
1449
|
-
* Gets the number of {@link Entity}s in {@link Scene#colorizedObjects}.
|
|
1450
|
-
*
|
|
1451
|
-
* @type {Number}
|
|
1452
|
-
*/
|
|
1453
|
-
get numColorizedObjects() {
|
|
1454
|
-
return this._numColorizedObjects;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
/**
|
|
1458
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#colorizedObjects}.
|
|
1459
|
-
*
|
|
1460
|
-
* @type {String[]}
|
|
1461
|
-
*/
|
|
1462
|
-
get colorizedObjectIds() {
|
|
1463
|
-
if (!this._colorizedObjectIds) {
|
|
1464
|
-
this._colorizedObjectIds = Object.keys(this.colorizedObjects);
|
|
1465
|
-
}
|
|
1466
|
-
return this._colorizedObjectIds;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
/**
|
|
1470
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#opacityObjects}.
|
|
1471
|
-
*
|
|
1472
|
-
* @type {String[]}
|
|
1473
|
-
*/
|
|
1474
|
-
get opacityObjectIds() {
|
|
1475
|
-
if (!this._opacityObjectIds) {
|
|
1476
|
-
this._opacityObjectIds = Object.keys(this.opacityObjects);
|
|
1477
|
-
}
|
|
1478
|
-
return this._opacityObjectIds;
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
/**
|
|
1482
|
-
* Gets the IDs of the {@link Entity}s in {@link Scene#offsetObjects}.
|
|
1483
|
-
*
|
|
1484
|
-
* @type {String[]}
|
|
1485
|
-
*/
|
|
1486
|
-
get offsetObjectIds() {
|
|
1487
|
-
if (!this._offsetObjectIds) {
|
|
1488
|
-
this._offsetObjectIds = Object.keys(this.offsetObjects);
|
|
1489
|
-
}
|
|
1490
|
-
return this._offsetObjectIds;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
/**
|
|
1494
|
-
* Sets the number of "ticks" that happen between each render or this Scene.
|
|
1495
|
-
*
|
|
1496
|
-
* Default value is ````1````.
|
|
1497
|
-
*
|
|
1498
|
-
* @type {Number}
|
|
1499
|
-
*/
|
|
1500
|
-
set ticksPerRender(value) {
|
|
1501
|
-
if (value === undefined || value === null) {
|
|
1502
|
-
value = 1;
|
|
1503
|
-
} else if (!utils.isNumeric(value) || value <= 0) {
|
|
1504
|
-
this.error("Unsupported value for 'ticksPerRender': '" + value +
|
|
1505
|
-
"' - should be an integer greater than zero.");
|
|
1506
|
-
value = 1;
|
|
1507
|
-
}
|
|
1508
|
-
if (value === this._ticksPerRender) {
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
this._ticksPerRender = value;
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* Gets the number of "ticks" that happen between each render or this Scene.
|
|
1516
|
-
*
|
|
1517
|
-
* Default value is ````1````.
|
|
1518
|
-
*
|
|
1519
|
-
* @type {Number}
|
|
1520
|
-
*/
|
|
1521
|
-
get ticksPerRender() {
|
|
1522
|
-
return this._ticksPerRender;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
/**
|
|
1526
|
-
* Sets the number of "ticks" that happen between occlusion testing for {@link Marker}s.
|
|
1527
|
-
*
|
|
1528
|
-
* Default value is ````20````.
|
|
1529
|
-
*
|
|
1530
|
-
* @type {Number}
|
|
1531
|
-
*/
|
|
1532
|
-
set ticksPerOcclusionTest(value) {
|
|
1533
|
-
if (value === undefined || value === null) {
|
|
1534
|
-
value = 20;
|
|
1535
|
-
} else if (!utils.isNumeric(value) || value <= 0) {
|
|
1536
|
-
this.error("Unsupported value for 'ticksPerOcclusionTest': '" + value +
|
|
1537
|
-
"' - should be an integer greater than zero.");
|
|
1538
|
-
value = 20;
|
|
1539
|
-
}
|
|
1540
|
-
if (value === this._ticksPerOcclusionTest) {
|
|
1541
|
-
return;
|
|
1542
|
-
}
|
|
1543
|
-
this._ticksPerOcclusionTest = value;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
/**
|
|
1547
|
-
* Gets the number of "ticks" that happen between each render of this Scene.
|
|
1548
|
-
*
|
|
1549
|
-
* Default value is ````1````.
|
|
1550
|
-
*
|
|
1551
|
-
* @type {Number}
|
|
1552
|
-
*/
|
|
1553
|
-
get ticksPerOcclusionTest() {
|
|
1554
|
-
return this._ticksPerOcclusionTest;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* Sets the number of times this Scene renders per frame.
|
|
1559
|
-
*
|
|
1560
|
-
* Default value is ````1````.
|
|
1561
|
-
*
|
|
1562
|
-
* @type {Number}
|
|
1563
|
-
*/
|
|
1564
|
-
set passes(value) {
|
|
1565
|
-
if (value === undefined || value === null) {
|
|
1566
|
-
value = 1;
|
|
1567
|
-
} else if (!utils.isNumeric(value) || value <= 0) {
|
|
1568
|
-
this.error("Unsupported value for 'passes': '" + value +
|
|
1569
|
-
"' - should be an integer greater than zero.");
|
|
1570
|
-
value = 1;
|
|
1571
|
-
}
|
|
1572
|
-
if (value === this._passes) {
|
|
1573
|
-
return;
|
|
1574
|
-
}
|
|
1575
|
-
this._passes = value;
|
|
1576
|
-
this.glRedraw();
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
/**
|
|
1580
|
-
* Gets the number of times this Scene renders per frame.
|
|
1581
|
-
*
|
|
1582
|
-
* Default value is ````1````.
|
|
1583
|
-
*
|
|
1584
|
-
* @type {Number}
|
|
1585
|
-
*/
|
|
1586
|
-
get passes() {
|
|
1587
|
-
return this._passes;
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
/**
|
|
1591
|
-
* When {@link Scene#passes} is greater than ````1````, indicates whether or not to clear the canvas before each pass (````true````) or just before the first pass (````false````).
|
|
1592
|
-
*
|
|
1593
|
-
* Default value is ````false````.
|
|
1594
|
-
*
|
|
1595
|
-
* @type {Boolean}
|
|
1596
|
-
*/
|
|
1597
|
-
set clearEachPass(value) {
|
|
1598
|
-
value = !!value;
|
|
1599
|
-
if (value === this._clearEachPass) {
|
|
1600
|
-
return;
|
|
1601
|
-
}
|
|
1602
|
-
this._clearEachPass = value;
|
|
1603
|
-
this.glRedraw();
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
/**
|
|
1607
|
-
* When {@link Scene#passes} is greater than ````1````, indicates whether or not to clear the canvas before each pass (````true````) or just before the first pass (````false````).
|
|
1608
|
-
*
|
|
1609
|
-
* Default value is ````false````.
|
|
1610
|
-
*
|
|
1611
|
-
* @type {Boolean}
|
|
1612
|
-
*/
|
|
1613
|
-
get clearEachPass() {
|
|
1614
|
-
return this._clearEachPass;
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
/**
|
|
1618
|
-
* Sets whether or not {@link Scene} should expect all {@link Texture}s and colors to have pre-multiplied gamma.
|
|
1619
|
-
*
|
|
1620
|
-
* Default value is ````false````.
|
|
1621
|
-
*
|
|
1622
|
-
* @type {Boolean}
|
|
1623
|
-
*/
|
|
1624
|
-
set gammaInput(value) {
|
|
1625
|
-
value = value !== false;
|
|
1626
|
-
if (value === this._renderer.gammaInput) {
|
|
1627
|
-
return;
|
|
1628
|
-
}
|
|
1629
|
-
this._renderer.gammaInput = value;
|
|
1630
|
-
this._needRecompile = true;
|
|
1631
|
-
this.glRedraw();
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
/**
|
|
1635
|
-
* Gets whether or not {@link Scene} should expect all {@link Texture}s and colors to have pre-multiplied gamma.
|
|
1636
|
-
*
|
|
1637
|
-
* Default value is ````false````.
|
|
1638
|
-
*
|
|
1639
|
-
* @type {Boolean}
|
|
1640
|
-
*/
|
|
1641
|
-
get gammaInput() {
|
|
1642
|
-
return this._renderer.gammaInput;
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
/**
|
|
1646
|
-
* Sets whether or not to render pixels with pre-multiplied gama.
|
|
1647
|
-
*
|
|
1648
|
-
* Default value is ````false````.
|
|
1649
|
-
*
|
|
1650
|
-
* @type {Boolean}
|
|
1651
|
-
*/
|
|
1652
|
-
set gammaOutput(value) {
|
|
1653
|
-
value = !!value;
|
|
1654
|
-
if (value === this._renderer.gammaOutput) {
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
this._renderer.gammaOutput = value;
|
|
1658
|
-
this._needRecompile = true;
|
|
1659
|
-
this.glRedraw();
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
/**
|
|
1663
|
-
* Gets whether or not to render pixels with pre-multiplied gama.
|
|
1664
|
-
*
|
|
1665
|
-
* Default value is ````true````.
|
|
1666
|
-
*
|
|
1667
|
-
* @type {Boolean}
|
|
1668
|
-
*/
|
|
1669
|
-
get gammaOutput() {
|
|
1670
|
-
return this._renderer.gammaOutput;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
/**
|
|
1674
|
-
* Sets the gamma factor to use when {@link Scene#gammaOutput} is set true.
|
|
1675
|
-
*
|
|
1676
|
-
* Default value is ````2.2````.
|
|
1677
|
-
*
|
|
1678
|
-
* @type {Number}
|
|
1679
|
-
*/
|
|
1680
|
-
set gammaFactor(value) {
|
|
1681
|
-
value = (value === undefined || value === null) ? 2.2 : value;
|
|
1682
|
-
if (value === this._renderer.gammaFactor) {
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
|
-
this._renderer.gammaFactor = value;
|
|
1686
|
-
this.glRedraw();
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
/**
|
|
1690
|
-
* Gets the gamma factor to use when {@link Scene#gammaOutput} is set true.
|
|
1691
|
-
*
|
|
1692
|
-
* Default value is ````2.2````.
|
|
1693
|
-
*
|
|
1694
|
-
* @type {Number}
|
|
1695
|
-
*/
|
|
1696
|
-
get gammaFactor() {
|
|
1697
|
-
return this._renderer.gammaFactor;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
/**
|
|
1701
|
-
* Gets the default {@link Geometry} for this Scene, which is a {@link ReadableGeometry} with a unit-sized box shape.
|
|
1702
|
-
*
|
|
1703
|
-
* Has {@link ReadableGeometry#id} set to "default.geometry".
|
|
1704
|
-
*
|
|
1705
|
-
* {@link Mesh}s in this Scene have {@link Mesh#geometry} set to this {@link ReadableGeometry} by default.
|
|
1706
|
-
*
|
|
1707
|
-
* @type {ReadableGeometry}
|
|
1708
|
-
*/
|
|
1709
|
-
get geometry() {
|
|
1710
|
-
return this.components["default.geometry"] || buildBoxGeometry(ReadableGeometry, this, {
|
|
1711
|
-
id: "default.geometry",
|
|
1712
|
-
dontClear: true
|
|
1713
|
-
});
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* Gets the default {@link Material} for this Scene, which is a {@link PhongMaterial}.
|
|
1718
|
-
*
|
|
1719
|
-
* Has {@link PhongMaterial#id} set to "default.material".
|
|
1720
|
-
*
|
|
1721
|
-
* {@link Mesh}s in this Scene have {@link Mesh#material} set to this {@link PhongMaterial} by default.
|
|
1722
|
-
*
|
|
1723
|
-
* @type {PhongMaterial}
|
|
1724
|
-
*/
|
|
1725
|
-
get material() {
|
|
1726
|
-
return this.components["default.material"] || new PhongMaterial(this, {
|
|
1727
|
-
id: "default.material",
|
|
1728
|
-
emissive: [0.4, 0.4, 0.4], // Visible by default on geometry without normals
|
|
1729
|
-
dontClear: true
|
|
1730
|
-
});
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
/**
|
|
1734
|
-
* Gets the default xraying {@link EmphasisMaterial} for this Scene.
|
|
1735
|
-
*
|
|
1736
|
-
* Has {@link EmphasisMaterial#id} set to "default.xrayMaterial".
|
|
1737
|
-
*
|
|
1738
|
-
* {@link Mesh}s in this Scene have {@link Mesh#xrayMaterial} set to this {@link EmphasisMaterial} by default.
|
|
1739
|
-
*
|
|
1740
|
-
* {@link Mesh}s are xrayed while {@link Mesh#xrayed} is ````true````.
|
|
1741
|
-
*
|
|
1742
|
-
* @type {EmphasisMaterial}
|
|
1743
|
-
*/
|
|
1744
|
-
get xrayMaterial() {
|
|
1745
|
-
return this.components["default.xrayMaterial"] || new EmphasisMaterial(this, {
|
|
1746
|
-
id: "default.xrayMaterial",
|
|
1747
|
-
preset: "sepia",
|
|
1748
|
-
dontClear: true
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
/**
|
|
1753
|
-
* Gets the default highlight {@link EmphasisMaterial} for this Scene.
|
|
1754
|
-
*
|
|
1755
|
-
* Has {@link EmphasisMaterial#id} set to "default.highlightMaterial".
|
|
1756
|
-
*
|
|
1757
|
-
* {@link Mesh}s in this Scene have {@link Mesh#highlightMaterial} set to this {@link EmphasisMaterial} by default.
|
|
1758
|
-
*
|
|
1759
|
-
* {@link Mesh}s are highlighted while {@link Mesh#highlighted} is ````true````.
|
|
1760
|
-
*
|
|
1761
|
-
* @type {EmphasisMaterial}
|
|
1762
|
-
*/
|
|
1763
|
-
get highlightMaterial() {
|
|
1764
|
-
return this.components["default.highlightMaterial"] || new EmphasisMaterial(this, {
|
|
1765
|
-
id: "default.highlightMaterial",
|
|
1766
|
-
preset: "yellowHighlight",
|
|
1767
|
-
dontClear: true
|
|
1768
|
-
});
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* Gets the default selection {@link EmphasisMaterial} for this Scene.
|
|
1773
|
-
*
|
|
1774
|
-
* Has {@link EmphasisMaterial#id} set to "default.selectedMaterial".
|
|
1775
|
-
*
|
|
1776
|
-
* {@link Mesh}s in this Scene have {@link Mesh#highlightMaterial} set to this {@link EmphasisMaterial} by default.
|
|
1777
|
-
*
|
|
1778
|
-
* {@link Mesh}s are highlighted while {@link Mesh#highlighted} is ````true````.
|
|
1779
|
-
*
|
|
1780
|
-
* @type {EmphasisMaterial}
|
|
1781
|
-
*/
|
|
1782
|
-
get selectedMaterial() {
|
|
1783
|
-
return this.components["default.selectedMaterial"] || new EmphasisMaterial(this, {
|
|
1784
|
-
id: "default.selectedMaterial",
|
|
1785
|
-
preset: "greenSelected",
|
|
1786
|
-
dontClear: true
|
|
1787
|
-
});
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* Gets the default {@link EdgeMaterial} for this Scene.
|
|
1792
|
-
*
|
|
1793
|
-
* Has {@link EdgeMaterial#id} set to "default.edgeMaterial".
|
|
1794
|
-
*
|
|
1795
|
-
* {@link Mesh}s in this Scene have {@link Mesh#edgeMaterial} set to this {@link EdgeMaterial} by default.
|
|
1796
|
-
*
|
|
1797
|
-
* {@link Mesh}s have their edges emphasized while {@link Mesh#edges} is ````true````.
|
|
1798
|
-
*
|
|
1799
|
-
* @type {EdgeMaterial}
|
|
1800
|
-
*/
|
|
1801
|
-
get edgeMaterial() {
|
|
1802
|
-
return this.components["default.edgeMaterial"] || new EdgeMaterial(this, {
|
|
1803
|
-
id: "default.edgeMaterial",
|
|
1804
|
-
preset: "default",
|
|
1805
|
-
edgeColor: [0.0, 0.0, 0.0],
|
|
1806
|
-
edgeAlpha: 1.0,
|
|
1807
|
-
edgeWidth: 1,
|
|
1808
|
-
dontClear: true
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
/**
|
|
1813
|
-
* Gets the {@link PointsMaterial} for this Scene.
|
|
1814
|
-
*
|
|
1815
|
-
* @type {PointsMaterial}
|
|
1816
|
-
*/
|
|
1817
|
-
get pointsMaterial() {
|
|
1818
|
-
return this.components["default.pointsMaterial"] || new PointsMaterial(this, {
|
|
1819
|
-
id: "default.pointsMaterial",
|
|
1820
|
-
preset: "default",
|
|
1821
|
-
dontClear: true
|
|
1822
|
-
});
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
/**
|
|
1826
|
-
* Gets the {@link LinesMaterial} for this Scene.
|
|
1827
|
-
*
|
|
1828
|
-
* @type {LinesMaterial}
|
|
1829
|
-
*/
|
|
1830
|
-
get linesMaterial() {
|
|
1831
|
-
return this.components["default.linesMaterial"] || new LinesMaterial(this, {
|
|
1832
|
-
id: "default.linesMaterial",
|
|
1833
|
-
preset: "default",
|
|
1834
|
-
dontClear: true
|
|
1835
|
-
});
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* Gets the {@link Viewport} for this Scene.
|
|
1840
|
-
*
|
|
1841
|
-
* @type Viewport
|
|
1842
|
-
*/
|
|
1843
|
-
get viewport() {
|
|
1844
|
-
return this._viewport;
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
/**
|
|
1848
|
-
* Gets the {@link Camera} for this Scene.
|
|
1849
|
-
*
|
|
1850
|
-
* @type {Camera}
|
|
1851
|
-
*/
|
|
1852
|
-
get camera() {
|
|
1853
|
-
return this._camera;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
/**
|
|
1857
|
-
* Gets the World-space 3D center of this Scene.
|
|
1858
|
-
*
|
|
1859
|
-
*@type {Number[]}
|
|
1860
|
-
*/
|
|
1861
|
-
get center() {
|
|
1862
|
-
if (this._aabbDirty || !this._center) {
|
|
1863
|
-
if (!this._center || !this._center) {
|
|
1864
|
-
this._center = math.vec3();
|
|
1865
|
-
}
|
|
1866
|
-
const aabb = this.aabb;
|
|
1867
|
-
this._center[0] = (aabb[0] + aabb[3]) / 2;
|
|
1868
|
-
this._center[1] = (aabb[1] + aabb[4]) / 2;
|
|
1869
|
-
this._center[2] = (aabb[2] + aabb[5]) / 2;
|
|
1870
|
-
}
|
|
1871
|
-
return this._center;
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
/**
|
|
1875
|
-
* Gets the World-space axis-aligned 3D boundary (AABB) of this Scene.
|
|
1876
|
-
*
|
|
1877
|
-
* The AABB is represented by a six-element Float64Array containing the min/max extents of the axis-aligned volume, ie. ````[xmin, ymin,zmin,xmax,ymax, zmax]````.
|
|
1878
|
-
*
|
|
1879
|
-
* When the Scene has no content, will be ````[-100,-100,-100,100,100,100]````.
|
|
1880
|
-
*
|
|
1881
|
-
* @type {Number[]}
|
|
1882
|
-
*/
|
|
1883
|
-
get aabb() {
|
|
1884
|
-
if (this._aabbDirty) {
|
|
1885
|
-
if (!this._aabb) {
|
|
1886
|
-
this._aabb = math.AABB3();
|
|
1887
|
-
}
|
|
1888
|
-
let xmin = math.MAX_DOUBLE;
|
|
1889
|
-
let ymin = math.MAX_DOUBLE;
|
|
1890
|
-
let zmin = math.MAX_DOUBLE;
|
|
1891
|
-
let xmax = math.MIN_DOUBLE;
|
|
1892
|
-
let ymax = math.MIN_DOUBLE;
|
|
1893
|
-
let zmax = math.MIN_DOUBLE;
|
|
1894
|
-
let aabb;
|
|
1895
|
-
const collidables = this._collidables;
|
|
1896
|
-
let collidable;
|
|
1897
|
-
let valid = false;
|
|
1898
|
-
for (const collidableId in collidables) {
|
|
1899
|
-
if (collidables.hasOwnProperty(collidableId)) {
|
|
1900
|
-
collidable = collidables[collidableId];
|
|
1901
|
-
if (collidable.collidable === false) {
|
|
1902
|
-
continue;
|
|
1903
|
-
}
|
|
1904
|
-
aabb = collidable.aabb;
|
|
1905
|
-
if (aabb[0] < xmin) {
|
|
1906
|
-
xmin = aabb[0];
|
|
1907
|
-
}
|
|
1908
|
-
if (aabb[1] < ymin) {
|
|
1909
|
-
ymin = aabb[1];
|
|
1910
|
-
}
|
|
1911
|
-
if (aabb[2] < zmin) {
|
|
1912
|
-
zmin = aabb[2];
|
|
1913
|
-
}
|
|
1914
|
-
if (aabb[3] > xmax) {
|
|
1915
|
-
xmax = aabb[3];
|
|
1916
|
-
}
|
|
1917
|
-
if (aabb[4] > ymax) {
|
|
1918
|
-
ymax = aabb[4];
|
|
1919
|
-
}
|
|
1920
|
-
if (aabb[5] > zmax) {
|
|
1921
|
-
zmax = aabb[5];
|
|
1922
|
-
}
|
|
1923
|
-
valid = true;
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
if (!valid) {
|
|
1927
|
-
xmin = -100;
|
|
1928
|
-
ymin = -100;
|
|
1929
|
-
zmin = -100;
|
|
1930
|
-
xmax = 100;
|
|
1931
|
-
ymax = 100;
|
|
1932
|
-
zmax = 100;
|
|
1933
|
-
}
|
|
1934
|
-
this._aabb[0] = xmin;
|
|
1935
|
-
this._aabb[1] = ymin;
|
|
1936
|
-
this._aabb[2] = zmin;
|
|
1937
|
-
this._aabb[3] = xmax;
|
|
1938
|
-
this._aabb[4] = ymax;
|
|
1939
|
-
this._aabb[5] = zmax;
|
|
1940
|
-
this._aabbDirty = false;
|
|
1941
|
-
}
|
|
1942
|
-
return this._aabb;
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
_setAABBDirty() {
|
|
1946
|
-
//if (!this._aabbDirty) {
|
|
1947
|
-
this._aabbDirty = true;
|
|
1948
|
-
this.fire("boundary");
|
|
1949
|
-
// }
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
/**
|
|
1953
|
-
* Attempts to pick an {@link Entity} in this Scene.
|
|
1954
|
-
*
|
|
1955
|
-
* Ignores {@link Entity}s with {@link Entity#pickable} set ````false````.
|
|
1956
|
-
*
|
|
1957
|
-
* When an {@link Entity} is picked, fires a "pick" event on the {@link Entity} with the pick result as parameters.
|
|
1958
|
-
*
|
|
1959
|
-
* Picking the {@link Entity} at the given canvas coordinates:
|
|
1960
|
-
|
|
1961
|
-
* ````javascript
|
|
1962
|
-
* var pickResult = scene.pick({
|
|
1963
|
-
* canvasPos: [23, 131]
|
|
1964
|
-
* });
|
|
1965
|
-
*
|
|
1966
|
-
* if (pickResult) { // Picked an Entity
|
|
1967
|
-
* var entity = pickResult.entity;
|
|
1968
|
-
* }
|
|
1969
|
-
* ````
|
|
1970
|
-
*
|
|
1971
|
-
* Picking, with a ray cast through the canvas, hits an {@link Entity}:
|
|
1972
|
-
*
|
|
1973
|
-
* ````javascript
|
|
1974
|
-
* var pickResult = scene.pick({
|
|
1975
|
-
* pickSurface: true,
|
|
1976
|
-
* canvasPos: [23, 131]
|
|
1977
|
-
* });
|
|
1978
|
-
*
|
|
1979
|
-
* if (pickResult) { // Picked an Entity
|
|
1980
|
-
*
|
|
1981
|
-
* var entity = pickResult.entity;
|
|
1982
|
-
*
|
|
1983
|
-
* if (pickResult.primitive === "triangle") {
|
|
1984
|
-
*
|
|
1985
|
-
* // Picked a triangle on the entity surface
|
|
1986
|
-
*
|
|
1987
|
-
* var primIndex = pickResult.primIndex; // Position of triangle's first index in the picked Entity's Geometry's indices array
|
|
1988
|
-
* var indices = pickResult.indices; // UInt32Array containing the triangle's vertex indices
|
|
1989
|
-
* var localPos = pickResult.localPos; // Float64Array containing the picked Local-space position on the triangle
|
|
1990
|
-
* var worldPos = pickResult.worldPos; // Float64Array containing the picked World-space position on the triangle
|
|
1991
|
-
* var viewPos = pickResult.viewPos; // Float64Array containing the picked View-space position on the triangle
|
|
1992
|
-
* var bary = pickResult.bary; // Float64Array containing the picked barycentric position within the triangle
|
|
1993
|
-
* var worldNormal = pickResult.worldNormal; // Float64Array containing the interpolated World-space normal vector at the picked position on the triangle
|
|
1994
|
-
* var uv = pickResult.uv; // Float64Array containing the interpolated UV coordinates at the picked position on the triangle
|
|
1995
|
-
*
|
|
1996
|
-
* } else if (pickResult.worldPos && pickResult.worldNormal) {
|
|
1997
|
-
*
|
|
1998
|
-
* // Picked a point and normal on the entity surface
|
|
1999
|
-
*
|
|
2000
|
-
* var worldPos = pickResult.worldPos; // Float64Array containing the picked World-space position on the Entity surface
|
|
2001
|
-
* var worldNormal = pickResult.worldNormal; // Float64Array containing the picked World-space normal vector on the Entity Surface
|
|
2002
|
-
* }
|
|
2003
|
-
* }
|
|
2004
|
-
* ````
|
|
2005
|
-
*
|
|
2006
|
-
* Picking the {@link Entity} that intersects an arbitrarily-aligned World-space ray:
|
|
2007
|
-
*
|
|
2008
|
-
* ````javascript
|
|
2009
|
-
* var pickResult = scene.pick({
|
|
2010
|
-
* pickSurface: true, // Picking with arbitrarily-positioned ray
|
|
2011
|
-
* origin: [0,0,-5], // Ray origin
|
|
2012
|
-
* direction: [0,0,1] // Ray direction
|
|
2013
|
-
* });
|
|
2014
|
-
*
|
|
2015
|
-
* if (pickResult) { // Picked an Entity with the ray
|
|
2016
|
-
*
|
|
2017
|
-
* var entity = pickResult.entity;
|
|
2018
|
-
*
|
|
2019
|
-
* if (pickResult.primitive == "triangle") {
|
|
2020
|
-
*
|
|
2021
|
-
* // Picked a triangle on the entity surface
|
|
2022
|
-
*
|
|
2023
|
-
* var primitive = pickResult.primitive; // Type of primitive that was picked, usually "triangles"
|
|
2024
|
-
* var primIndex = pickResult.primIndex; // Position of triangle's first index in the picked Entity's Geometry's indices array
|
|
2025
|
-
* var indices = pickResult.indices; // UInt32Array containing the triangle's vertex indices
|
|
2026
|
-
* var localPos = pickResult.localPos; // Float64Array containing the picked Local-space position on the triangle
|
|
2027
|
-
* var worldPos = pickResult.worldPos; // Float64Array containing the picked World-space position on the triangle
|
|
2028
|
-
* var viewPos = pickResult.viewPos; // Float64Array containing the picked View-space position on the triangle
|
|
2029
|
-
* var bary = pickResult.bary; // Float64Array containing the picked barycentric position within the triangle
|
|
2030
|
-
* var worldNormal = pickResult.worldNormal; // Float64Array containing the interpolated World-space normal vector at the picked position on the triangle
|
|
2031
|
-
* var uv = pickResult.uv; // Float64Array containing the interpolated UV coordinates at the picked position on the triangle
|
|
2032
|
-
* var origin = pickResult.origin; // Float64Array containing the World-space ray origin
|
|
2033
|
-
* var direction = pickResult.direction; // Float64Array containing the World-space ray direction
|
|
2034
|
-
*
|
|
2035
|
-
* } else if (pickResult.worldPos && pickResult.worldNormal) {
|
|
2036
|
-
*
|
|
2037
|
-
* // Picked a point and normal on the entity surface
|
|
2038
|
-
*
|
|
2039
|
-
* var worldPos = pickResult.worldPos; // Float64Array containing the picked World-space position on the Entity surface
|
|
2040
|
-
* var worldNormal = pickResult.worldNormal; // Float64Array containing the picked World-space normal vector on the Entity Surface
|
|
2041
|
-
* }
|
|
2042
|
-
* }
|
|
2043
|
-
* ````
|
|
2044
|
-
*
|
|
2045
|
-
* @param {*} params Picking parameters.
|
|
2046
|
-
* @param {Boolean} [params.pickSurface=false] Whether to find the picked position on the surface of the Entity.
|
|
2047
|
-
* @param {Boolean} [params.pickSurfaceNormal=false] Whether to find the picked normal on the surface of the Entity. Only works if ````pickSurface```` is given.
|
|
2048
|
-
* @param {Number[]} [params.canvasPos] Canvas-space coordinates. When ray-picking, this will override the **origin** and ** direction** parameters and will cause the ray to be fired through the canvas at this position, directly along the negative View-space Z-axis.
|
|
2049
|
-
* @param {Number[]} [params.origin] World-space ray origin when ray-picking. Ignored when canvasPos given.
|
|
2050
|
-
* @param {Number[]} [params.direction] World-space ray direction when ray-picking. Also indicates the length of the ray. Ignored when canvasPos given.
|
|
2051
|
-
* @param {Number[]} [params.matrix] 4x4 transformation matrix to define the World-space ray origin and direction, as an alternative to ````origin```` and ````direction````.
|
|
2052
|
-
* @param {String[]} [params.includeEntities] IDs of {@link Entity}s to restrict picking to. When given, ignores {@link Entity}s whose IDs are not in this list.
|
|
2053
|
-
* @param {String[]} [params.excludeEntities] IDs of {@link Entity}s to ignore. When given, will pick *through* these {@link Entity}s, as if they were not there.
|
|
2054
|
-
* @param {PickResult} [pickResult] Holds the results of the pick attempt. Will use the Scene's singleton PickResult if you don't supply your own.
|
|
2055
|
-
* @returns {PickResult} Holds results of the pick attempt, returned when an {@link Entity} is picked, else null. See method comments for description.
|
|
2056
|
-
*/
|
|
2057
|
-
pick(params, pickResult) {
|
|
2058
|
-
|
|
2059
|
-
if (this.canvas.boundary[2] === 0 || this.canvas.boundary[3] === 0) {
|
|
2060
|
-
this.error("Picking not allowed while canvas has zero width or height");
|
|
2061
|
-
return null;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
params = params || {};
|
|
2065
|
-
|
|
2066
|
-
params.pickSurface = params.pickSurface || params.rayPick; // Backwards compatibility
|
|
2067
|
-
|
|
2068
|
-
if (!params.canvasPos && !params.matrix && (!params.origin || !params.direction)) {
|
|
2069
|
-
this.warn("picking without canvasPos, matrix, or ray origin and direction");
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
const includeEntities = params.includeEntities || params.include; // Backwards compat
|
|
2073
|
-
if (includeEntities) {
|
|
2074
|
-
params.includeEntityIds = getEntityIDMap(this, includeEntities);
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2077
|
-
const excludeEntities = params.excludeEntities || params.exclude; // Backwards compat
|
|
2078
|
-
if (excludeEntities) {
|
|
2079
|
-
params.excludeEntityIds = getEntityIDMap(this, excludeEntities);
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
if (this._needRecompile) {
|
|
2083
|
-
this._recompile();
|
|
2084
|
-
this._renderer.imageDirty();
|
|
2085
|
-
this._needRecompile = false;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
pickResult = this._renderer.pick(params, pickResult);
|
|
2089
|
-
|
|
2090
|
-
if (pickResult) {
|
|
2091
|
-
if (pickResult.entity && pickResult.entity.fire) {
|
|
2092
|
-
pickResult.entity.fire("picked", pickResult); // TODO: PerformanceModelNode doesn't fire events
|
|
2093
|
-
}
|
|
2094
|
-
return pickResult;
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
/**
|
|
2099
|
-
* Destroys all non-default {@link Component}s in this Scene.
|
|
2100
|
-
*/
|
|
2101
|
-
clear() {
|
|
2102
|
-
var component;
|
|
2103
|
-
for (const id in this.components) {
|
|
2104
|
-
if (this.components.hasOwnProperty(id)) {
|
|
2105
|
-
component = this.components[id];
|
|
2106
|
-
if (!component._dontClear) { // Don't destroy components like Camera, Input, Viewport etc.
|
|
2107
|
-
component.destroy();
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
/**
|
|
2114
|
-
* Destroys all {@link Light}s in this Scene..
|
|
2115
|
-
*/
|
|
2116
|
-
clearLights() {
|
|
2117
|
-
const ids = Object.keys(this.lights);
|
|
2118
|
-
for (let i = 0, len = ids.length; i < len; i++) {
|
|
2119
|
-
this.lights[ids[i]].destroy();
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
/**
|
|
2124
|
-
* Destroys all {@link SectionPlane}s in this Scene.
|
|
2125
|
-
*/
|
|
2126
|
-
clearSectionPlanes() {
|
|
2127
|
-
const ids = Object.keys(this.sectionPlanes);
|
|
2128
|
-
for (let i = 0, len = ids.length; i < len; i++) {
|
|
2129
|
-
this.sectionPlanes[ids[i]].destroy();
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
/**
|
|
2134
|
-
* Gets the collective axis-aligned boundary (AABB) of a batch of {@link Entity}s that represent objects.
|
|
2135
|
-
*
|
|
2136
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2137
|
-
*
|
|
2138
|
-
* Each {@link Entity} on which {@link Entity#isObject} is registered by {@link Entity#id} in {@link Scene#visibleObjects}.
|
|
2139
|
-
*
|
|
2140
|
-
* Each {@link Entity} is only included in the AABB when {@link Entity#collidable} is ````true````.
|
|
2141
|
-
*
|
|
2142
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2143
|
-
* @returns {[Number, Number, Number, Number, Number, Number]} An axis-aligned World-space bounding box, given as elements ````[xmin, ymin, zmin, xmax, ymax, zmax]````.
|
|
2144
|
-
*/
|
|
2145
|
-
getAABB(ids) {
|
|
2146
|
-
if (ids === undefined) {
|
|
2147
|
-
return this.aabb;
|
|
2148
|
-
}
|
|
2149
|
-
if (utils.isString(ids)) {
|
|
2150
|
-
const entity = this.objects[ids];
|
|
2151
|
-
if (entity && entity.aabb) { // A Component subclass with an AABB
|
|
2152
|
-
return entity.aabb;
|
|
2153
|
-
}
|
|
2154
|
-
ids = [ids]; // Must be an entity type
|
|
2155
|
-
}
|
|
2156
|
-
if (ids.length === 0) {
|
|
2157
|
-
return this.aabb;
|
|
2158
|
-
}
|
|
2159
|
-
let xmin = math.MAX_DOUBLE;
|
|
2160
|
-
let ymin = math.MAX_DOUBLE;
|
|
2161
|
-
let zmin = math.MAX_DOUBLE;
|
|
2162
|
-
let xmax = math.MIN_DOUBLE;
|
|
2163
|
-
let ymax = math.MIN_DOUBLE;
|
|
2164
|
-
let zmax = math.MIN_DOUBLE;
|
|
2165
|
-
let valid;
|
|
2166
|
-
this.withObjects(ids, entity => {
|
|
2167
|
-
if (entity.collidable) {
|
|
2168
|
-
const aabb = entity.aabb;
|
|
2169
|
-
if (aabb[0] < xmin) {
|
|
2170
|
-
xmin = aabb[0];
|
|
2171
|
-
}
|
|
2172
|
-
if (aabb[1] < ymin) {
|
|
2173
|
-
ymin = aabb[1];
|
|
2174
|
-
}
|
|
2175
|
-
if (aabb[2] < zmin) {
|
|
2176
|
-
zmin = aabb[2];
|
|
2177
|
-
}
|
|
2178
|
-
if (aabb[3] > xmax) {
|
|
2179
|
-
xmax = aabb[3];
|
|
2180
|
-
}
|
|
2181
|
-
if (aabb[4] > ymax) {
|
|
2182
|
-
ymax = aabb[4];
|
|
2183
|
-
}
|
|
2184
|
-
if (aabb[5] > zmax) {
|
|
2185
|
-
zmax = aabb[5];
|
|
2186
|
-
}
|
|
2187
|
-
valid = true;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
);
|
|
2191
|
-
if (valid) {
|
|
2192
|
-
const aabb2 = math.AABB3();
|
|
2193
|
-
aabb2[0] = xmin;
|
|
2194
|
-
aabb2[1] = ymin;
|
|
2195
|
-
aabb2[2] = zmin;
|
|
2196
|
-
aabb2[3] = xmax;
|
|
2197
|
-
aabb2[4] = ymax;
|
|
2198
|
-
aabb2[5] = zmax;
|
|
2199
|
-
return aabb2;
|
|
2200
|
-
} else {
|
|
2201
|
-
return this.aabb; // Scene AABB
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
/**
|
|
2206
|
-
* Batch-updates {@link Entity#visible} on {@link Entity}s that represent objects.
|
|
2207
|
-
*
|
|
2208
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2209
|
-
*
|
|
2210
|
-
* Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#visible} are ````true```` is
|
|
2211
|
-
* registered by {@link Entity#id} in {@link Scene#visibleObjects}.
|
|
2212
|
-
*
|
|
2213
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2214
|
-
* @param {Boolean} visible Whether or not to cull.
|
|
2215
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2216
|
-
*/
|
|
2217
|
-
setObjectsVisible(ids, visible) {
|
|
2218
|
-
return this.withObjects(ids, entity => {
|
|
2219
|
-
const changed = (entity.visible !== visible);
|
|
2220
|
-
entity.visible = visible;
|
|
2221
|
-
return changed;
|
|
2222
|
-
});
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
/**
|
|
2226
|
-
* Batch-updates {@link Entity#collidable} on {@link Entity}s that represent objects.
|
|
2227
|
-
*
|
|
2228
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2229
|
-
*
|
|
2230
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2231
|
-
* @param {Boolean} collidable Whether or not to cull.
|
|
2232
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2233
|
-
*/
|
|
2234
|
-
setObjectsCollidable(ids, collidable) {
|
|
2235
|
-
return this.withObjects(ids, entity => {
|
|
2236
|
-
const changed = (entity.collidable !== collidable);
|
|
2237
|
-
entity.collidable = collidable;
|
|
2238
|
-
return changed;
|
|
2239
|
-
});
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
/**
|
|
2243
|
-
* Batch-updates {@link Entity#culled} on {@link Entity}s that represent objects.
|
|
2244
|
-
*
|
|
2245
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2246
|
-
*
|
|
2247
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2248
|
-
* @param {Boolean} culled Whether or not to cull.
|
|
2249
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2250
|
-
*/
|
|
2251
|
-
setObjectsCulled(ids, culled) {
|
|
2252
|
-
return this.withObjects(ids, this.objects, entity => {
|
|
2253
|
-
const changed = (entity.culled !== culled);
|
|
2254
|
-
entity.culled = culled;
|
|
2255
|
-
return changed;
|
|
2256
|
-
});
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
/**
|
|
2260
|
-
* Batch-updates {@link Entity#selected} on {@link Entity}s that represent objects.
|
|
2261
|
-
*
|
|
2262
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2263
|
-
*
|
|
2264
|
-
* Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#selected} are ````true```` is
|
|
2265
|
-
* registered by {@link Entity#id} in {@link Scene#selectedObjects}.
|
|
2266
|
-
*
|
|
2267
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2268
|
-
* @param {Boolean} selected Whether or not to highlight.
|
|
2269
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2270
|
-
*/
|
|
2271
|
-
setObjectsSelected(ids, selected) {
|
|
2272
|
-
return this.withObjects(ids, entity => {
|
|
2273
|
-
const changed = (entity.selected !== selected);
|
|
2274
|
-
entity.selected = selected;
|
|
2275
|
-
return changed;
|
|
2276
|
-
});
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
/**
|
|
2280
|
-
* Batch-updates {@link Entity#highlighted} on {@link Entity}s that represent objects.
|
|
2281
|
-
*
|
|
2282
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2283
|
-
*
|
|
2284
|
-
* Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#highlighted} are ````true```` is
|
|
2285
|
-
* registered by {@link Entity#id} in {@link Scene#highlightedObjects}.
|
|
2286
|
-
*
|
|
2287
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2288
|
-
* @param {Boolean} highlighted Whether or not to highlight.
|
|
2289
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2290
|
-
*/
|
|
2291
|
-
setObjectsHighlighted(ids, highlighted) {
|
|
2292
|
-
return this.withObjects(ids, entity => {
|
|
2293
|
-
const changed = (entity.highlighted !== highlighted);
|
|
2294
|
-
entity.highlighted = highlighted;
|
|
2295
|
-
return changed;
|
|
2296
|
-
});
|
|
2297
|
-
}
|
|
2298
|
-
|
|
2299
|
-
/**
|
|
2300
|
-
* Batch-updates {@link Entity#xrayed} on {@link Entity}s that represent objects.
|
|
2301
|
-
*
|
|
2302
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2303
|
-
*
|
|
2304
|
-
* Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#xrayed} are ````true```` is
|
|
2305
|
-
* registered by {@link Entity#id} in {@link Scene#xrayedObjects}.
|
|
2306
|
-
*
|
|
2307
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2308
|
-
* @param {Boolean} xrayed Whether or not to xray.
|
|
2309
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2310
|
-
*/
|
|
2311
|
-
setObjectsXRayed(ids, xrayed) {
|
|
2312
|
-
return this.withObjects(ids, entity => {
|
|
2313
|
-
const changed = (entity.xrayed !== xrayed);
|
|
2314
|
-
entity.xrayed = xrayed;
|
|
2315
|
-
return changed;
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
/**
|
|
2320
|
-
* Batch-updates {@link Entity#edges} on {@link Entity}s that represent objects.
|
|
2321
|
-
*
|
|
2322
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2323
|
-
*
|
|
2324
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2325
|
-
* @param {Boolean} edges Whether or not to show edges.
|
|
2326
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2327
|
-
*/
|
|
2328
|
-
setObjectsEdges(ids, edges) {
|
|
2329
|
-
return this.withObjects(ids, entity => {
|
|
2330
|
-
const changed = (entity.edges !== edges);
|
|
2331
|
-
entity.edges = edges;
|
|
2332
|
-
return changed;
|
|
2333
|
-
});
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
/**
|
|
2337
|
-
* Batch-updates {@link Entity#colorize} on {@link Entity}s that represent objects.
|
|
2338
|
-
*
|
|
2339
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2340
|
-
*
|
|
2341
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2342
|
-
* @param {Number[]} [colorize=(1,1,1)] RGB colorize factors, multiplied by the rendered pixel colors.
|
|
2343
|
-
* @returns {Boolean} True if any {@link Entity}s changed opacity, else false if all updates were redundant and not applied.
|
|
2344
|
-
*/
|
|
2345
|
-
setObjectsColorized(ids, colorize) {
|
|
2346
|
-
return this.withObjects(ids, entity => {
|
|
2347
|
-
entity.colorize = colorize;
|
|
2348
|
-
});
|
|
2349
|
-
}
|
|
2350
|
-
|
|
2351
|
-
/**
|
|
2352
|
-
* Batch-updates {@link Entity#opacity} on {@link Entity}s that represent objects.
|
|
2353
|
-
*
|
|
2354
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2355
|
-
*
|
|
2356
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2357
|
-
* @param {Number} [opacity=1.0] Opacity factor, multiplied by the rendered pixel alphas.
|
|
2358
|
-
* @returns {Boolean} True if any {@link Entity}s changed opacity, else false if all updates were redundant and not applied.
|
|
2359
|
-
*/
|
|
2360
|
-
setObjectsOpacity(ids, opacity) {
|
|
2361
|
-
return this.withObjects(ids, entity => {
|
|
2362
|
-
const changed = (entity.opacity !== opacity);
|
|
2363
|
-
entity.opacity = opacity;
|
|
2364
|
-
return changed;
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
/**
|
|
2369
|
-
* Batch-updates {@link Entity#pickable} on {@link Entity}s that represent objects.
|
|
2370
|
-
*
|
|
2371
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2372
|
-
*
|
|
2373
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2374
|
-
* @param {Boolean} pickable Whether or not to enable picking.
|
|
2375
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2376
|
-
*/
|
|
2377
|
-
setObjectsPickable(ids, pickable) {
|
|
2378
|
-
return this.withObjects(ids, entity => {
|
|
2379
|
-
const changed = (entity.pickable !== pickable);
|
|
2380
|
-
entity.pickable = pickable;
|
|
2381
|
-
return changed;
|
|
2382
|
-
});
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
/**
|
|
2386
|
-
* Batch-updates {@link Entity#offset} on {@link Entity}s that represent objects.
|
|
2387
|
-
*
|
|
2388
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2389
|
-
*
|
|
2390
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2391
|
-
* @param {Number[]} [offset] 3D offset vector.
|
|
2392
|
-
*/
|
|
2393
|
-
setObjectsOffset(ids, offset) {
|
|
2394
|
-
this.withObjects(ids, entity => {
|
|
2395
|
-
entity.offset = offset;
|
|
2396
|
-
});
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
/**
|
|
2400
|
-
* Iterates with a callback over {@link Entity#visible} on {@link Entity}s that represent objects.
|
|
2401
|
-
*
|
|
2402
|
-
* An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
|
|
2403
|
-
*
|
|
2404
|
-
* Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#visible} are ````true```` is
|
|
2405
|
-
* registered by {@link Entity#id} in {@link Scene#visibleObjects}.
|
|
2406
|
-
*
|
|
2407
|
-
* @param {String[]} ids Array of {@link Entity#id} values.
|
|
2408
|
-
* @param {Function} callback Callback to execute on eacn {@link Entity}.
|
|
2409
|
-
* @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
|
|
2410
|
-
*/
|
|
2411
|
-
withObjects(ids, callback) {
|
|
2412
|
-
if (utils.isString(ids)) {
|
|
2413
|
-
ids = [ids];
|
|
2414
|
-
}
|
|
2415
|
-
let changed = false;
|
|
2416
|
-
for (let i = 0, len = ids.length; i < len; i++) {
|
|
2417
|
-
const id = ids[i];
|
|
2418
|
-
let entity = this.objects[id];
|
|
2419
|
-
if (entity) {
|
|
2420
|
-
changed = callback(entity) || changed;
|
|
2421
|
-
} else {
|
|
2422
|
-
const modelIds = this.modelIds;
|
|
2423
|
-
for (let i = 0, len = modelIds.length; i < len; i++) {
|
|
2424
|
-
const modelId = modelIds[i];
|
|
2425
|
-
const globalObjectId = math.globalizeObjectId(modelId, id);
|
|
2426
|
-
entity = this.objects[globalObjectId];
|
|
2427
|
-
if (entity) {
|
|
2428
|
-
changed = callback(entity) || changed;
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
return changed;
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
/**
|
|
2437
|
-
* Destroys this Scene.
|
|
2438
|
-
*/
|
|
2439
|
-
destroy() {
|
|
2440
|
-
|
|
2441
|
-
super.destroy();
|
|
2442
|
-
|
|
2443
|
-
for (const id in this.components) {
|
|
2444
|
-
if (this.components.hasOwnProperty(id)) {
|
|
2445
|
-
this.components[id].destroy();
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
this.canvas.gl = null;
|
|
2450
|
-
|
|
2451
|
-
// Memory leak prevention
|
|
2452
|
-
this.components = null;
|
|
2453
|
-
this.models = null;
|
|
2454
|
-
this.objects = null;
|
|
2455
|
-
this.visibleObjects = null;
|
|
2456
|
-
this.xrayedObjects = null;
|
|
2457
|
-
this.highlightedObjects = null;
|
|
2458
|
-
this.selectedObjects = null;
|
|
2459
|
-
this.colorizedObjects = null;
|
|
2460
|
-
this.opacityObjects = null;
|
|
2461
|
-
this.sectionPlanes = null;
|
|
2462
|
-
this.lights = null;
|
|
2463
|
-
this.lightMaps = null;
|
|
2464
|
-
this.reflectionMaps = null;
|
|
2465
|
-
this._objectIds = null;
|
|
2466
|
-
this._visibleObjectIds = null;
|
|
2467
|
-
this._xrayedObjectIds = null;
|
|
2468
|
-
this._highlightedObjectIds = null;
|
|
2469
|
-
this._selectedObjectIds = null;
|
|
2470
|
-
this._colorizedObjectIds = null;
|
|
2471
|
-
this.types = null;
|
|
2472
|
-
this.components = null;
|
|
2473
|
-
this.canvas = null;
|
|
2474
|
-
this._renderer = null;
|
|
2475
|
-
this.input = null;
|
|
2476
|
-
this._viewport = null;
|
|
2477
|
-
this._camera = null;
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2481
|
-
export {Scene};
|