pidsmaker 5.0.0__py3-none-any.whl
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.
- pidsmaker/__init__.py +1 -0
- pidsmaker/cli.py +81 -0
- pidsmaker/config/__init__.py +2 -0
- pidsmaker/config/config.py +2100 -0
- pidsmaker/config/pipeline.py +1824 -0
- pidsmaker/config/schemas.py +1032 -0
- pidsmaker/datasets.py +323 -0
- pidsmaker/debug_tests.py +30 -0
- pidsmaker/decoders/__init__.py +5 -0
- pidsmaker/decoders/custom_edge_mlp_decoder.py +17 -0
- pidsmaker/decoders/custom_mlp_decoder.py +10 -0
- pidsmaker/decoders/edge_linear_decoder.py +16 -0
- pidsmaker/decoders/inner_product_decoder.py +18 -0
- pidsmaker/decoders/nodlink_decoder.py +56 -0
- pidsmaker/detection/__init__.py +0 -0
- pidsmaker/detection/evaluation_methods/__init__.py +9 -0
- pidsmaker/detection/evaluation_methods/edge_evaluation.py +255 -0
- pidsmaker/detection/evaluation_methods/evaluation_utils.py +1788 -0
- pidsmaker/detection/evaluation_methods/host_two_stage_evaluation.py +115 -0
- pidsmaker/detection/evaluation_methods/node_evaluation.py +459 -0
- pidsmaker/detection/evaluation_methods/node_tw_evaluation.py +196 -0
- pidsmaker/detection/evaluation_methods/plot.py +192 -0
- pidsmaker/detection/evaluation_methods/queue_evaluation.py +456 -0
- pidsmaker/detection/evaluation_methods/tw_evaluation.py +93 -0
- pidsmaker/detection/flash_detection.py +162 -0
- pidsmaker/detection/magic_knn.py +190 -0
- pidsmaker/detection/node_scoring.py +52 -0
- pidsmaker/detection/threatrace_detection.py +65 -0
- pidsmaker/detection/training_methods/__init__.py +1 -0
- pidsmaker/detection/training_methods/inference_loop.py +287 -0
- pidsmaker/detection/training_methods/ocrapt_early_stop.py +165 -0
- pidsmaker/detection/training_methods/threatrace_training.py +168 -0
- pidsmaker/detection/training_methods/training_loop.py +383 -0
- pidsmaker/encoders/__init__.py +22 -0
- pidsmaker/encoders/argus_encoder.py +69 -0
- pidsmaker/encoders/custom_mlp.py +75 -0
- pidsmaker/encoders/custom_mlp_encoder.py +10 -0
- pidsmaker/encoders/egraphsage_encoder.py +56 -0
- pidsmaker/encoders/gat.py +67 -0
- pidsmaker/encoders/gcn.py +27 -0
- pidsmaker/encoders/gin.py +48 -0
- pidsmaker/encoders/glstm.py +298 -0
- pidsmaker/encoders/graph_attention.py +63 -0
- pidsmaker/encoders/gru.py +29 -0
- pidsmaker/encoders/hetero/__init__.py +4 -0
- pidsmaker/encoders/hetero/ancestor_encoder.py +98 -0
- pidsmaker/encoders/hetero/entity_encoder.py +33 -0
- pidsmaker/encoders/hetero/event_encoder.py +81 -0
- pidsmaker/encoders/hetero/hetero_graph_transformer.py +40 -0
- pidsmaker/encoders/lares_encoder.py +68 -0
- pidsmaker/encoders/linear_encoder.py +16 -0
- pidsmaker/encoders/magic_encoder.py +161 -0
- pidsmaker/encoders/rcaid_encoder.py +81 -0
- pidsmaker/encoders/rgcn.py +75 -0
- pidsmaker/encoders/sage.py +51 -0
- pidsmaker/encoders/shadewatcher_encoder.py +149 -0
- pidsmaker/encoders/sum_aggregation.py +20 -0
- pidsmaker/encoders/temporal_wrappers.py +80 -0
- pidsmaker/encoders/textrcnn.py +82 -0
- pidsmaker/encoders/tgn_encoder.py +193 -0
- pidsmaker/experiments/tuning.py +102 -0
- pidsmaker/experiments/uncertainty.py +261 -0
- pidsmaker/factory.py +1456 -0
- pidsmaker/featurization/__init__.py +0 -0
- pidsmaker/featurization/feat_inference_methods/__init__.py +7 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_HFH.py +30 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_TRW.py +65 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_alacarte.py +14 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_doc2vec.py +53 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_fasttext.py +37 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_flash.py +69 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_graph2vec.py +84 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_ocrapt_features.py +95 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_pretrained.py +1728 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_word2vec.py +55 -0
- pidsmaker/featurization/featurization_methods/__init__.py +0 -0
- pidsmaker/featurization/featurization_methods/build_trw.py +66 -0
- pidsmaker/featurization/featurization_methods/featurization_alacarte.py +747 -0
- pidsmaker/featurization/featurization_methods/featurization_doc2vec.py +98 -0
- pidsmaker/featurization/featurization_methods/featurization_fasttext.py +74 -0
- pidsmaker/featurization/featurization_methods/featurization_flash.py +201 -0
- pidsmaker/featurization/featurization_methods/featurization_graph2vec.py +242 -0
- pidsmaker/featurization/featurization_methods/featurization_trw.py +114 -0
- pidsmaker/featurization/featurization_methods/featurization_word2vec.py +89 -0
- pidsmaker/featurization/featurization_utils.py +275 -0
- pidsmaker/featurization/utils/build_random_walks.py +66 -0
- pidsmaker/featurization/utils/trw.py +203 -0
- pidsmaker/hetero.py +81 -0
- pidsmaker/losses.py +170 -0
- pidsmaker/main.py +478 -0
- pidsmaker/mimicry.py +284 -0
- pidsmaker/model.py +382 -0
- pidsmaker/objectives/__init__.py +16 -0
- pidsmaker/objectives/autoencode_edge_emb.py +43 -0
- pidsmaker/objectives/deep_graph_infomax.py +94 -0
- pidsmaker/objectives/detect_few_shot.py +21 -0
- pidsmaker/objectives/one_class.py +75 -0
- pidsmaker/objectives/predict_edge_contrastive.py +165 -0
- pidsmaker/objectives/predict_edge_supervised.py +77 -0
- pidsmaker/objectives/predict_edge_type.py +28 -0
- pidsmaker/objectives/predict_masked_struct.py +49 -0
- pidsmaker/objectives/predict_node_type.py +36 -0
- pidsmaker/objectives/predict_process_tag.py +169 -0
- pidsmaker/objectives/predict_snapshot_embedding.py +97 -0
- pidsmaker/objectives/reconstruct_edge_emb.py +16 -0
- pidsmaker/objectives/reconstruct_masked_feat.py +51 -0
- pidsmaker/objectives/reconstruct_node_emb.py +13 -0
- pidsmaker/objectives/reconstruct_node_feat.py +13 -0
- pidsmaker/objectives/validation_wrapper.py +55 -0
- pidsmaker/preprocessing/__init__.py +0 -0
- pidsmaker/preprocessing/build_graph_methods/__init__.py +1 -0
- pidsmaker/preprocessing/build_graph_methods/build_default_graphs.py +825 -0
- pidsmaker/preprocessing/build_graph_methods/build_magic_graphs.py +216 -0
- pidsmaker/preprocessing/cleaning.py +258 -0
- pidsmaker/preprocessing/transformation_methods/__init__.py +2 -0
- pidsmaker/preprocessing/transformation_methods/attack_generation/synthetic_attack_naive.py +194 -0
- pidsmaker/preprocessing/transformation_methods/transformation_dag.py +28 -0
- pidsmaker/preprocessing/transformation_methods/transformation_merge_edges.py +136 -0
- pidsmaker/preprocessing/transformation_methods/transformation_rcaid_pseudo_graph.py +510 -0
- pidsmaker/preprocessing/transformation_methods/transformation_undirected.py +24 -0
- pidsmaker/preprocessing/transformation_methods/transformation_utils.py +36 -0
- pidsmaker/pretrained/__init__.py +5 -0
- pidsmaker/pretrained/data/__init__.py +4 -0
- pidsmaker/pretrained/data/behavior_signatures.py +548 -0
- pidsmaker/pretrained/data/canonical_tokens.py +1035 -0
- pidsmaker/pretrained/data/edge_filter.py +381 -0
- pidsmaker/pretrained/data/entity_classes.py +476 -0
- pidsmaker/pretrained/data/sampler.py +926 -0
- pidsmaker/pretrained/data/tokenizer_bpe.py +1659 -0
- pidsmaker/pretrained/detect.py +1427 -0
- pidsmaker/pretrained/embedding_generator.py +252 -0
- pidsmaker/pretrained/finetune.py +1434 -0
- pidsmaker/pretrained/models/__init__.py +20 -0
- pidsmaker/pretrained/models/behavior.py +348 -0
- pidsmaker/pretrained/models/bert.py +286 -0
- pidsmaker/pretrained/models/deepwalk.py +128 -0
- pidsmaker/pretrained/models/dgi.py +120 -0
- pidsmaker/pretrained/models/gae.py +114 -0
- pidsmaker/pretrained/models/gnn_distill.py +475 -0
- pidsmaker/pretrained/models/graphmae.py +373 -0
- pidsmaker/pretrained/models/hf_pretrained.py +213 -0
- pidsmaker/pretrained/models/llama.py +110 -0
- pidsmaker/pretrained/models/modernbert.py +567 -0
- pidsmaker/pretrained/models/roberta.py +147 -0
- pidsmaker/pretrained/models/rope_utils.py +99 -0
- pidsmaker/pretrained/models/ropebert.py +322 -0
- pidsmaker/pretrained/models/spider.py +204 -0
- pidsmaker/pretrained/models/tgn.py +770 -0
- pidsmaker/pretrained/pretrain/__init__.py +3 -0
- pidsmaker/pretrained/pretrain/pretrain_behavior_cluster.py +513 -0
- pidsmaker/pretrained/pretrain/pretrain_common.py +585 -0
- pidsmaker/pretrained/pretrain/pretrain_deepwalk.py +31 -0
- pidsmaker/pretrained/pretrain/pretrain_dgi.py +143 -0
- pidsmaker/pretrained/pretrain/pretrain_gae.py +143 -0
- pidsmaker/pretrained/pretrain/pretrain_gnn_distill.py +438 -0
- pidsmaker/pretrained/pretrain/pretrain_graphmae.py +151 -0
- pidsmaker/pretrained/pretrain/pretrain_hf.py +169 -0
- pidsmaker/pretrained/pretrain/pretrain_main.py +275 -0
- pidsmaker/pretrained/pretrain/pretrain_mlm.py +491 -0
- pidsmaker/pretrained/pretrain/pretrain_spider.py +502 -0
- pidsmaker/pretrained/training_utils.py +157 -0
- pidsmaker/process_reapr_gt.py +101 -0
- pidsmaker/resources/config/anomal_e.yml +25 -0
- pidsmaker/resources/config/argus.yml +56 -0
- pidsmaker/resources/config/attack_edges/cadets_e3.yml +435 -0
- pidsmaker/resources/config/attack_edges/cadets_e5.yml +407 -0
- pidsmaker/resources/config/attack_edges/theia_e3.yml +382 -0
- pidsmaker/resources/config/attack_edges/theia_e5.yml +387 -0
- pidsmaker/resources/config/attack_edges/trace_e3.yml +415 -0
- pidsmaker/resources/config/attack_edges/trace_e5.yml +417 -0
- pidsmaker/resources/config/default.yml +315 -0
- pidsmaker/resources/config/egraphsage.yml +95 -0
- pidsmaker/resources/config/euler.yml +104 -0
- pidsmaker/resources/config/eval/eval_set_clustering.json +3170 -0
- pidsmaker/resources/config/experiments/tuning/components/tuning_featurization_methods.yml +29 -0
- pidsmaker/resources/config/experiments/tuning/systems/clearscope_e5/tuning_orthrus.yml +14 -0
- pidsmaker/resources/config/experiments/tuning/systems/default/tuning_default_baselines.yml +13 -0
- pidsmaker/resources/config/experiments/tuning/systems/default/tuning_orthrus_fixed.yml +16 -0
- pidsmaker/resources/config/experiments/uncertainty/none.yml +5 -0
- pidsmaker/resources/config/experiments/uncertainty/run_n_times.yml +12 -0
- pidsmaker/resources/config/experiments/uncertainty/run_n_times_hyperparameters.yml +12 -0
- pidsmaker/resources/config/experiments/uncertainty/uncertainty.yml +22 -0
- pidsmaker/resources/config/flash.yml +79 -0
- pidsmaker/resources/config/jbeil.yml +65 -0
- pidsmaker/resources/config/kairos.yml +121 -0
- pidsmaker/resources/config/lares.yml +115 -0
- pidsmaker/resources/config/magic.yml +86 -0
- pidsmaker/resources/config/nodlink.yml +79 -0
- pidsmaker/resources/config/ocrapt.yml +91 -0
- pidsmaker/resources/config/orthrus.yml +126 -0
- pidsmaker/resources/config/orthrus_fixed.yml +17 -0
- pidsmaker/resources/config/pretrained/README.md +101 -0
- pidsmaker/resources/config/pretrained/cybergfm/cybergfm.yml +49 -0
- pidsmaker/resources/config/pretrained/pretrained.yml +190 -0
- pidsmaker/resources/config/pretrained/pretrained_flash.yml +9 -0
- pidsmaker/resources/config/pretrained/pretrained_kairos.yml +12 -0
- pidsmaker/resources/config/pretrained/pretrained_magic.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_nodlink.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_orthrus.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_supervised.yml +13 -0
- pidsmaker/resources/config/pretrained/pretrained_threatrace.yml +8 -0
- pidsmaker/resources/config/pretrained/pretrained_velox.yml +14 -0
- pidsmaker/resources/config/prographer.yml +136 -0
- pidsmaker/resources/config/rcaid.yml +88 -0
- pidsmaker/resources/config/shadewatcher.yml +146 -0
- pidsmaker/resources/config/tests.yml +10 -0
- pidsmaker/resources/config/threatrace.yml +73 -0
- pidsmaker/resources/config/tuned_baselines/optc_net/tuned_argus.yml +4 -0
- pidsmaker/resources/config/tuned_baselines/optc_net/tuned_lares.yml +13 -0
- pidsmaker/resources/config/velox.yml +10 -0
- pidsmaker/resources/config/viz_config.yml +10 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_06.csv +8 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_11.csv +4 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_12.csv +43 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_13.csv +24 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0411.csv +41 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0412.csv +0 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_browser_0412.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +63 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +56 -0
- pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +61 -0
- pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +58 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_firefox_0410.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_pine_0413.csv +14 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT.csv +19 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT_17.csv +107 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_appstarter_0515.csv +26 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_firefox_0517.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_lockwatch_0517.csv +17 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_tester_0517.csv +8 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_bits_0515.csv +54 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_copykatz_0509.csv +87 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_dns_0517.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_drakon_0517.csv +6 -0
- pidsmaker/resources/ground_truth/orthrus/E5-THEIA/node_THEIA_1_Firefox_Drakon_APT_BinFmt_Elevate_Inject.csv +70 -0
- pidsmaker/resources/ground_truth/orthrus/E5-TRACE/node_Trace_Firefox_Drakon.csv +71 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m1.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m2.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m3.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m4.csv +5 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m5.csv +23 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m6.csv +18 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s1.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s2.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s3.csv +16 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s4.csv +22 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m1.csv +126 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m2.csv +105 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m3.csv +94 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m4.csv +139 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m5.csv +228 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m6.csv +131 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s1.csv +118 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s2.csv +89 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s3.csv +133 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s4.csv +135 -0
- pidsmaker/resources/ground_truth/orthrus/carbanakv2_edr/carbanakv2_edr.csv +2453 -0
- pidsmaker/resources/ground_truth/orthrus/h051/node_h051_0925.csv +114 -0
- pidsmaker/resources/ground_truth/orthrus/h201/node_h201_0923.csv +2905 -0
- pidsmaker/resources/ground_truth/orthrus/h501/node_h501_0924.csv +749 -0
- pidsmaker/resources/ground_truth/orthrus/readme.md +98 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_06.csv +3 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_12.csv +655 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_13.csv +770 -0
- pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +0 -0
- pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +18 -0
- pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +42 -0
- pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +81 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_firefox_0410.csv +37 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +9 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_pine_0413.csv +40 -0
- pidsmaker/resources/ground_truth/threatrace/E3-CADETS/ground_truth.txt +12858 -0
- pidsmaker/resources/ground_truth/threatrace/E3-FIVEDIRECTIONS/ground_truth.txt +18420 -0
- pidsmaker/resources/ground_truth/threatrace/E3-THEIA/ground_truth.txt +25363 -0
- pidsmaker/resources/ground_truth/threatrace/E3-TRACE/ground_truth.txt +68265 -0
- pidsmaker/resources/ground_truth/threatrace/README.md +123 -0
- pidsmaker/tasks/__init__.py +10 -0
- pidsmaker/tasks/batching.py +47 -0
- pidsmaker/tasks/construction.py +31 -0
- pidsmaker/tasks/evaluation.py +241 -0
- pidsmaker/tasks/feat_inference.py +413 -0
- pidsmaker/tasks/featurization.py +43 -0
- pidsmaker/tasks/training.py +17 -0
- pidsmaker/tasks/transformation.py +306 -0
- pidsmaker/tasks/triage.py +143 -0
- pidsmaker/tgn.py +635 -0
- pidsmaker/tokenization/__init__.py +112 -0
- pidsmaker/tokenization/base.py +58 -0
- pidsmaker/tokenization/bpe_tokenizer.py +83 -0
- pidsmaker/tokenization/hf_tokenizer.py +61 -0
- pidsmaker/tokenization/hierarchical_tokenizer.py +44 -0
- pidsmaker/tokenization/label_tokenizer.py +24 -0
- pidsmaker/tokenization/nltk_tokenizer.py +84 -0
- pidsmaker/tokenization/substitution.py +295 -0
- pidsmaker/triage/__init__.py +0 -0
- pidsmaker/triage/tracing_methods/__init__.py +1 -0
- pidsmaker/triage/tracing_methods/depimpact.py +213 -0
- pidsmaker/triage/tracing_methods/depimpact_utils.py +537 -0
- pidsmaker/triage/tracing_methods/ocrapt_subgraph.py +267 -0
- pidsmaker/utils/__init__.py +0 -0
- pidsmaker/utils/cache_utils.py +256 -0
- pidsmaker/utils/console.py +282 -0
- pidsmaker/utils/data_utils.py +1742 -0
- pidsmaker/utils/database.py +150 -0
- pidsmaker/utils/dataset_utils.py +413 -0
- pidsmaker/utils/dataset_writer.py +570 -0
- pidsmaker/utils/graph_store.py +634 -0
- pidsmaker/utils/labelling.py +445 -0
- pidsmaker/utils/loss_files.py +193 -0
- pidsmaker/utils/process_tags.py +44 -0
- pidsmaker/utils/utils.py +712 -0
- pidsmaker/vizgen/__init__.py +1 -0
- pidsmaker/vizgen/backfill_manifests.py +100 -0
- pidsmaker/vizgen/dimensionality_reduction.py +249 -0
- pidsmaker/vizgen/embed_exporter.py +467 -0
- pidsmaker/vizgen/exporter.py +493 -0
- pidsmaker/vizgen/html_builder.py +936 -0
- pidsmaker/vizgen/web/__init__.py +1 -0
- pidsmaker/vizgen/web/export.py +62 -0
- pidsmaker/vizgen/web/static/css/app.css +250 -0
- pidsmaker/vizgen/web/static/index.html +182 -0
- pidsmaker/vizgen/web/static/js/app.js +627 -0
- pidsmaker/vizgen/web/static/js/campaign.js +123 -0
- pidsmaker/vizgen/web/static/js/data.js +119 -0
- pidsmaker/vizgen/web/static/js/dialogs.js +240 -0
- pidsmaker/vizgen/web/static/js/jobs.js +75 -0
- pidsmaker/vizgen/web/static/js/scene.js +651 -0
- pidsmaker/vizgen/web/static/js/ui.js +370 -0
- pidsmaker/vizgen/web/static/vendor/OrbitControls.js +1045 -0
- pidsmaker/vizgen/web/static/vendor/d3.v4.min.js +2 -0
- pidsmaker/vizgen/web/static/vendor/three.min.js +6 -0
- pidsmaker/vizgen/web/viz_server.py +2176 -0
- pidsmaker-5.0.0.dist-info/METADATA +597 -0
- pidsmaker-5.0.0.dist-info/RECORD +339 -0
- pidsmaker-5.0.0.dist-info/WHEEL +5 -0
- pidsmaker-5.0.0.dist-info/entry_points.txt +2 -0
- pidsmaker-5.0.0.dist-info/licenses/LICENSE +201 -0
- pidsmaker-5.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1045 @@
|
|
|
1
|
+
( function () {
|
|
2
|
+
|
|
3
|
+
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
4
|
+
//
|
|
5
|
+
// Orbit - left mouse / touch: one-finger move
|
|
6
|
+
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
7
|
+
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
8
|
+
|
|
9
|
+
const _changeEvent = {
|
|
10
|
+
type: 'change'
|
|
11
|
+
};
|
|
12
|
+
const _startEvent = {
|
|
13
|
+
type: 'start'
|
|
14
|
+
};
|
|
15
|
+
const _endEvent = {
|
|
16
|
+
type: 'end'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
class OrbitControls extends THREE.EventDispatcher {
|
|
20
|
+
|
|
21
|
+
constructor( object, domElement ) {
|
|
22
|
+
|
|
23
|
+
super();
|
|
24
|
+
if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' );
|
|
25
|
+
if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' );
|
|
26
|
+
this.object = object;
|
|
27
|
+
this.domElement = domElement; // Set to false to disable this control
|
|
28
|
+
|
|
29
|
+
this.enabled = true; // "target" sets the location of focus, where the object orbits around
|
|
30
|
+
|
|
31
|
+
this.target = new THREE.Vector3(); // How far you can dolly in and out ( PerspectiveCamera only )
|
|
32
|
+
|
|
33
|
+
this.minDistance = 0;
|
|
34
|
+
this.maxDistance = Infinity; // How far you can zoom in and out ( OrthographicCamera only )
|
|
35
|
+
|
|
36
|
+
this.minZoom = 0;
|
|
37
|
+
this.maxZoom = Infinity; // How far you can orbit vertically, upper and lower limits.
|
|
38
|
+
// Range is 0 to Math.PI radians.
|
|
39
|
+
|
|
40
|
+
this.minPolarAngle = 0; // radians
|
|
41
|
+
|
|
42
|
+
this.maxPolarAngle = Math.PI; // radians
|
|
43
|
+
// How far you can orbit horizontally, upper and lower limits.
|
|
44
|
+
// If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
|
|
45
|
+
|
|
46
|
+
this.minAzimuthAngle = - Infinity; // radians
|
|
47
|
+
|
|
48
|
+
this.maxAzimuthAngle = Infinity; // radians
|
|
49
|
+
// Set to true to enable damping (inertia)
|
|
50
|
+
// If damping is enabled, you must call controls.update() in your animation loop
|
|
51
|
+
|
|
52
|
+
this.enableDamping = false;
|
|
53
|
+
this.dampingFactor = 0.05; // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
|
|
54
|
+
// Set to false to disable zooming
|
|
55
|
+
|
|
56
|
+
this.enableZoom = true;
|
|
57
|
+
this.zoomSpeed = 1.0; // Set to false to disable rotating
|
|
58
|
+
|
|
59
|
+
this.enableRotate = true;
|
|
60
|
+
this.rotateSpeed = 1.0; // Set to false to disable panning
|
|
61
|
+
|
|
62
|
+
this.enablePan = true;
|
|
63
|
+
this.panSpeed = 1.0;
|
|
64
|
+
this.screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up
|
|
65
|
+
|
|
66
|
+
this.keyPanSpeed = 7.0; // pixels moved per arrow key push
|
|
67
|
+
// Set to true to automatically rotate around the target
|
|
68
|
+
// If auto-rotate is enabled, you must call controls.update() in your animation loop
|
|
69
|
+
|
|
70
|
+
this.autoRotate = false;
|
|
71
|
+
this.autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60
|
|
72
|
+
// The four arrow keys
|
|
73
|
+
|
|
74
|
+
this.keys = {
|
|
75
|
+
LEFT: 'ArrowLeft',
|
|
76
|
+
UP: 'ArrowUp',
|
|
77
|
+
RIGHT: 'ArrowRight',
|
|
78
|
+
BOTTOM: 'ArrowDown'
|
|
79
|
+
}; // Mouse buttons
|
|
80
|
+
|
|
81
|
+
this.mouseButtons = {
|
|
82
|
+
LEFT: THREE.MOUSE.ROTATE,
|
|
83
|
+
MIDDLE: THREE.MOUSE.DOLLY,
|
|
84
|
+
RIGHT: THREE.MOUSE.PAN
|
|
85
|
+
}; // Touch fingers
|
|
86
|
+
|
|
87
|
+
this.touches = {
|
|
88
|
+
ONE: THREE.TOUCH.ROTATE,
|
|
89
|
+
TWO: THREE.TOUCH.DOLLY_PAN
|
|
90
|
+
}; // for reset
|
|
91
|
+
|
|
92
|
+
this.target0 = this.target.clone();
|
|
93
|
+
this.position0 = this.object.position.clone();
|
|
94
|
+
this.zoom0 = this.object.zoom; // the target DOM element for key events
|
|
95
|
+
|
|
96
|
+
this._domElementKeyEvents = null; //
|
|
97
|
+
// public methods
|
|
98
|
+
//
|
|
99
|
+
|
|
100
|
+
this.getPolarAngle = function () {
|
|
101
|
+
|
|
102
|
+
return spherical.phi;
|
|
103
|
+
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
this.getAzimuthalAngle = function () {
|
|
107
|
+
|
|
108
|
+
return spherical.theta;
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
this.listenToKeyEvents = function ( domElement ) {
|
|
113
|
+
|
|
114
|
+
domElement.addEventListener( 'keydown', onKeyDown );
|
|
115
|
+
this._domElementKeyEvents = domElement;
|
|
116
|
+
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
this.saveState = function () {
|
|
120
|
+
|
|
121
|
+
scope.target0.copy( scope.target );
|
|
122
|
+
scope.position0.copy( scope.object.position );
|
|
123
|
+
scope.zoom0 = scope.object.zoom;
|
|
124
|
+
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
this.reset = function () {
|
|
128
|
+
|
|
129
|
+
scope.target.copy( scope.target0 );
|
|
130
|
+
scope.object.position.copy( scope.position0 );
|
|
131
|
+
scope.object.zoom = scope.zoom0;
|
|
132
|
+
scope.object.updateProjectionMatrix();
|
|
133
|
+
scope.dispatchEvent( _changeEvent );
|
|
134
|
+
scope.update();
|
|
135
|
+
state = STATE.NONE;
|
|
136
|
+
|
|
137
|
+
}; // this method is exposed, but perhaps it would be better if we can make it private...
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
this.update = function () {
|
|
141
|
+
|
|
142
|
+
const offset = new THREE.Vector3(); // so camera.up is the orbit axis
|
|
143
|
+
|
|
144
|
+
const quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
|
|
145
|
+
const quatInverse = quat.clone().invert();
|
|
146
|
+
const lastPosition = new THREE.Vector3();
|
|
147
|
+
const lastQuaternion = new THREE.Quaternion();
|
|
148
|
+
const twoPI = 2 * Math.PI;
|
|
149
|
+
return function update() {
|
|
150
|
+
|
|
151
|
+
const position = scope.object.position;
|
|
152
|
+
offset.copy( position ).sub( scope.target ); // rotate offset to "y-axis-is-up" space
|
|
153
|
+
|
|
154
|
+
offset.applyQuaternion( quat ); // angle from z-axis around y-axis
|
|
155
|
+
|
|
156
|
+
spherical.setFromVector3( offset );
|
|
157
|
+
|
|
158
|
+
if ( scope.autoRotate && state === STATE.NONE ) {
|
|
159
|
+
|
|
160
|
+
rotateLeft( getAutoRotationAngle() );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if ( scope.enableDamping ) {
|
|
165
|
+
|
|
166
|
+
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
167
|
+
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
168
|
+
|
|
169
|
+
} else {
|
|
170
|
+
|
|
171
|
+
spherical.theta += sphericalDelta.theta;
|
|
172
|
+
spherical.phi += sphericalDelta.phi;
|
|
173
|
+
|
|
174
|
+
} // restrict theta to be between desired limits
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
let min = scope.minAzimuthAngle;
|
|
178
|
+
let max = scope.maxAzimuthAngle;
|
|
179
|
+
|
|
180
|
+
if ( isFinite( min ) && isFinite( max ) ) {
|
|
181
|
+
|
|
182
|
+
if ( min < - Math.PI ) min += twoPI; else if ( min > Math.PI ) min -= twoPI;
|
|
183
|
+
if ( max < - Math.PI ) max += twoPI; else if ( max > Math.PI ) max -= twoPI;
|
|
184
|
+
|
|
185
|
+
if ( min <= max ) {
|
|
186
|
+
|
|
187
|
+
spherical.theta = Math.max( min, Math.min( max, spherical.theta ) );
|
|
188
|
+
|
|
189
|
+
} else {
|
|
190
|
+
|
|
191
|
+
spherical.theta = spherical.theta > ( min + max ) / 2 ? Math.max( min, spherical.theta ) : Math.min( max, spherical.theta );
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
} // restrict phi to be between desired limits
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
|
|
199
|
+
spherical.makeSafe();
|
|
200
|
+
spherical.radius *= scale; // restrict radius to be between desired limits
|
|
201
|
+
|
|
202
|
+
spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); // move target to panned location
|
|
203
|
+
|
|
204
|
+
if ( scope.enableDamping === true ) {
|
|
205
|
+
|
|
206
|
+
scope.target.addScaledVector( panOffset, scope.dampingFactor );
|
|
207
|
+
|
|
208
|
+
} else {
|
|
209
|
+
|
|
210
|
+
scope.target.add( panOffset );
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
offset.setFromSpherical( spherical ); // rotate offset back to "camera-up-vector-is-up" space
|
|
215
|
+
|
|
216
|
+
offset.applyQuaternion( quatInverse );
|
|
217
|
+
position.copy( scope.target ).add( offset );
|
|
218
|
+
scope.object.lookAt( scope.target );
|
|
219
|
+
|
|
220
|
+
if ( scope.enableDamping === true ) {
|
|
221
|
+
|
|
222
|
+
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
223
|
+
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
224
|
+
panOffset.multiplyScalar( 1 - scope.dampingFactor );
|
|
225
|
+
|
|
226
|
+
} else {
|
|
227
|
+
|
|
228
|
+
sphericalDelta.set( 0, 0, 0 );
|
|
229
|
+
panOffset.set( 0, 0, 0 );
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
scale = 1; // update condition is:
|
|
234
|
+
// min(camera displacement, camera rotation in radians)^2 > EPS
|
|
235
|
+
// using small-angle approximation cos(x/2) = 1 - x^2 / 8
|
|
236
|
+
|
|
237
|
+
if ( zoomChanged || lastPosition.distanceToSquared( scope.object.position ) > EPS || 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
|
|
238
|
+
|
|
239
|
+
scope.dispatchEvent( _changeEvent );
|
|
240
|
+
lastPosition.copy( scope.object.position );
|
|
241
|
+
lastQuaternion.copy( scope.object.quaternion );
|
|
242
|
+
zoomChanged = false;
|
|
243
|
+
return true;
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return false;
|
|
248
|
+
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
}();
|
|
252
|
+
|
|
253
|
+
this.dispose = function () {
|
|
254
|
+
|
|
255
|
+
scope.domElement.removeEventListener( 'contextmenu', onContextMenu );
|
|
256
|
+
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
257
|
+
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
258
|
+
scope.domElement.removeEventListener( 'touchstart', onTouchStart );
|
|
259
|
+
scope.domElement.removeEventListener( 'touchend', onTouchEnd );
|
|
260
|
+
scope.domElement.removeEventListener( 'touchmove', onTouchMove );
|
|
261
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
262
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
263
|
+
|
|
264
|
+
if ( scope._domElementKeyEvents !== null ) {
|
|
265
|
+
|
|
266
|
+
scope._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown );
|
|
267
|
+
|
|
268
|
+
} //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
|
|
269
|
+
|
|
270
|
+
}; //
|
|
271
|
+
// internals
|
|
272
|
+
//
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
const scope = this;
|
|
276
|
+
const STATE = {
|
|
277
|
+
NONE: - 1,
|
|
278
|
+
ROTATE: 0,
|
|
279
|
+
DOLLY: 1,
|
|
280
|
+
PAN: 2,
|
|
281
|
+
TOUCH_ROTATE: 3,
|
|
282
|
+
TOUCH_PAN: 4,
|
|
283
|
+
TOUCH_DOLLY_PAN: 5,
|
|
284
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
285
|
+
};
|
|
286
|
+
let state = STATE.NONE;
|
|
287
|
+
const EPS = 0.000001; // current position in spherical coordinates
|
|
288
|
+
|
|
289
|
+
const spherical = new THREE.Spherical();
|
|
290
|
+
const sphericalDelta = new THREE.Spherical();
|
|
291
|
+
let scale = 1;
|
|
292
|
+
const panOffset = new THREE.Vector3();
|
|
293
|
+
let zoomChanged = false;
|
|
294
|
+
const rotateStart = new THREE.Vector2();
|
|
295
|
+
const rotateEnd = new THREE.Vector2();
|
|
296
|
+
const rotateDelta = new THREE.Vector2();
|
|
297
|
+
const panStart = new THREE.Vector2();
|
|
298
|
+
const panEnd = new THREE.Vector2();
|
|
299
|
+
const panDelta = new THREE.Vector2();
|
|
300
|
+
const dollyStart = new THREE.Vector2();
|
|
301
|
+
const dollyEnd = new THREE.Vector2();
|
|
302
|
+
const dollyDelta = new THREE.Vector2();
|
|
303
|
+
|
|
304
|
+
function getAutoRotationAngle() {
|
|
305
|
+
|
|
306
|
+
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function getZoomScale() {
|
|
311
|
+
|
|
312
|
+
return Math.pow( 0.95, scope.zoomSpeed );
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function rotateLeft( angle ) {
|
|
317
|
+
|
|
318
|
+
sphericalDelta.theta -= angle;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function rotateUp( angle ) {
|
|
323
|
+
|
|
324
|
+
sphericalDelta.phi -= angle;
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const panLeft = function () {
|
|
329
|
+
|
|
330
|
+
const v = new THREE.Vector3();
|
|
331
|
+
return function panLeft( distance, objectMatrix ) {
|
|
332
|
+
|
|
333
|
+
v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
|
|
334
|
+
|
|
335
|
+
v.multiplyScalar( - distance );
|
|
336
|
+
panOffset.add( v );
|
|
337
|
+
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
}();
|
|
341
|
+
|
|
342
|
+
const panUp = function () {
|
|
343
|
+
|
|
344
|
+
const v = new THREE.Vector3();
|
|
345
|
+
return function panUp( distance, objectMatrix ) {
|
|
346
|
+
|
|
347
|
+
if ( scope.screenSpacePanning === true ) {
|
|
348
|
+
|
|
349
|
+
v.setFromMatrixColumn( objectMatrix, 1 );
|
|
350
|
+
|
|
351
|
+
} else {
|
|
352
|
+
|
|
353
|
+
v.setFromMatrixColumn( objectMatrix, 0 );
|
|
354
|
+
v.crossVectors( scope.object.up, v );
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
v.multiplyScalar( distance );
|
|
359
|
+
panOffset.add( v );
|
|
360
|
+
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
}(); // deltaX and deltaY are in pixels; right and down are positive
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
const pan = function () {
|
|
367
|
+
|
|
368
|
+
const offset = new THREE.Vector3();
|
|
369
|
+
return function pan( deltaX, deltaY ) {
|
|
370
|
+
|
|
371
|
+
const element = scope.domElement;
|
|
372
|
+
|
|
373
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
374
|
+
|
|
375
|
+
// perspective
|
|
376
|
+
const position = scope.object.position;
|
|
377
|
+
offset.copy( position ).sub( scope.target );
|
|
378
|
+
let targetDistance = offset.length(); // half of the fov is center to top of screen
|
|
379
|
+
|
|
380
|
+
targetDistance *= Math.tan( scope.object.fov / 2 * Math.PI / 180.0 ); // we use only clientHeight here so aspect ratio does not distort speed
|
|
381
|
+
|
|
382
|
+
panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
|
|
383
|
+
panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
|
|
384
|
+
|
|
385
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
386
|
+
|
|
387
|
+
// orthographic
|
|
388
|
+
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
|
|
389
|
+
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
|
|
390
|
+
|
|
391
|
+
} else {
|
|
392
|
+
|
|
393
|
+
// camera neither orthographic nor perspective
|
|
394
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
|
|
395
|
+
scope.enablePan = false;
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
}();
|
|
402
|
+
|
|
403
|
+
function dollyOut( dollyScale ) {
|
|
404
|
+
|
|
405
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
406
|
+
|
|
407
|
+
scale /= dollyScale;
|
|
408
|
+
|
|
409
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
410
|
+
|
|
411
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
|
|
412
|
+
scope.object.updateProjectionMatrix();
|
|
413
|
+
zoomChanged = true;
|
|
414
|
+
|
|
415
|
+
} else {
|
|
416
|
+
|
|
417
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
418
|
+
scope.enableZoom = false;
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function dollyIn( dollyScale ) {
|
|
425
|
+
|
|
426
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
427
|
+
|
|
428
|
+
scale *= dollyScale;
|
|
429
|
+
|
|
430
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
431
|
+
|
|
432
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
|
|
433
|
+
scope.object.updateProjectionMatrix();
|
|
434
|
+
zoomChanged = true;
|
|
435
|
+
|
|
436
|
+
} else {
|
|
437
|
+
|
|
438
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
439
|
+
scope.enableZoom = false;
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
} //
|
|
444
|
+
// event callbacks - update the object state
|
|
445
|
+
//
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
function handleMouseDownRotate( event ) {
|
|
449
|
+
|
|
450
|
+
rotateStart.set( event.clientX, event.clientY );
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function handleMouseDownDolly( event ) {
|
|
455
|
+
|
|
456
|
+
dollyStart.set( event.clientX, event.clientY );
|
|
457
|
+
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function handleMouseDownPan( event ) {
|
|
461
|
+
|
|
462
|
+
panStart.set( event.clientX, event.clientY );
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function handleMouseMoveRotate( event ) {
|
|
467
|
+
|
|
468
|
+
rotateEnd.set( event.clientX, event.clientY );
|
|
469
|
+
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
470
|
+
const element = scope.domElement;
|
|
471
|
+
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
472
|
+
|
|
473
|
+
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
474
|
+
rotateStart.copy( rotateEnd );
|
|
475
|
+
scope.update();
|
|
476
|
+
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function handleMouseMoveDolly( event ) {
|
|
480
|
+
|
|
481
|
+
dollyEnd.set( event.clientX, event.clientY );
|
|
482
|
+
dollyDelta.subVectors( dollyEnd, dollyStart );
|
|
483
|
+
|
|
484
|
+
if ( dollyDelta.y > 0 ) {
|
|
485
|
+
|
|
486
|
+
dollyOut( getZoomScale() );
|
|
487
|
+
|
|
488
|
+
} else if ( dollyDelta.y < 0 ) {
|
|
489
|
+
|
|
490
|
+
dollyIn( getZoomScale() );
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
dollyStart.copy( dollyEnd );
|
|
495
|
+
scope.update();
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function handleMouseMovePan( event ) {
|
|
500
|
+
|
|
501
|
+
panEnd.set( event.clientX, event.clientY );
|
|
502
|
+
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
503
|
+
pan( panDelta.x, panDelta.y );
|
|
504
|
+
panStart.copy( panEnd );
|
|
505
|
+
scope.update();
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function handleMouseUp( ) { // no-op
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function handleMouseWheel( event ) {
|
|
513
|
+
|
|
514
|
+
if ( event.deltaY < 0 ) {
|
|
515
|
+
|
|
516
|
+
dollyIn( getZoomScale() );
|
|
517
|
+
|
|
518
|
+
} else if ( event.deltaY > 0 ) {
|
|
519
|
+
|
|
520
|
+
dollyOut( getZoomScale() );
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
scope.update();
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function handleKeyDown( event ) {
|
|
529
|
+
|
|
530
|
+
let needsUpdate = false;
|
|
531
|
+
|
|
532
|
+
switch ( event.code ) {
|
|
533
|
+
|
|
534
|
+
case scope.keys.UP:
|
|
535
|
+
pan( 0, scope.keyPanSpeed );
|
|
536
|
+
needsUpdate = true;
|
|
537
|
+
break;
|
|
538
|
+
|
|
539
|
+
case scope.keys.BOTTOM:
|
|
540
|
+
pan( 0, - scope.keyPanSpeed );
|
|
541
|
+
needsUpdate = true;
|
|
542
|
+
break;
|
|
543
|
+
|
|
544
|
+
case scope.keys.LEFT:
|
|
545
|
+
pan( scope.keyPanSpeed, 0 );
|
|
546
|
+
needsUpdate = true;
|
|
547
|
+
break;
|
|
548
|
+
|
|
549
|
+
case scope.keys.RIGHT:
|
|
550
|
+
pan( - scope.keyPanSpeed, 0 );
|
|
551
|
+
needsUpdate = true;
|
|
552
|
+
break;
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if ( needsUpdate ) {
|
|
557
|
+
|
|
558
|
+
// prevent the browser from scrolling on cursor keys
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
scope.update();
|
|
561
|
+
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function handleTouchStartRotate( event ) {
|
|
567
|
+
|
|
568
|
+
if ( event.touches.length == 1 ) {
|
|
569
|
+
|
|
570
|
+
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
571
|
+
|
|
572
|
+
} else {
|
|
573
|
+
|
|
574
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
575
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
576
|
+
rotateStart.set( x, y );
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function handleTouchStartPan( event ) {
|
|
583
|
+
|
|
584
|
+
if ( event.touches.length == 1 ) {
|
|
585
|
+
|
|
586
|
+
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
587
|
+
|
|
588
|
+
} else {
|
|
589
|
+
|
|
590
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
591
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
592
|
+
panStart.set( x, y );
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function handleTouchStartDolly( event ) {
|
|
599
|
+
|
|
600
|
+
const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
601
|
+
const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
602
|
+
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
603
|
+
dollyStart.set( 0, distance );
|
|
604
|
+
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function handleTouchStartDollyPan( event ) {
|
|
608
|
+
|
|
609
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
610
|
+
if ( scope.enablePan ) handleTouchStartPan( event );
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function handleTouchStartDollyRotate( event ) {
|
|
615
|
+
|
|
616
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
617
|
+
if ( scope.enableRotate ) handleTouchStartRotate( event );
|
|
618
|
+
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function handleTouchMoveRotate( event ) {
|
|
622
|
+
|
|
623
|
+
if ( event.touches.length == 1 ) {
|
|
624
|
+
|
|
625
|
+
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
626
|
+
|
|
627
|
+
} else {
|
|
628
|
+
|
|
629
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
630
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
631
|
+
rotateEnd.set( x, y );
|
|
632
|
+
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
636
|
+
const element = scope.domElement;
|
|
637
|
+
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
638
|
+
|
|
639
|
+
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
640
|
+
rotateStart.copy( rotateEnd );
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function handleTouchMovePan( event ) {
|
|
645
|
+
|
|
646
|
+
if ( event.touches.length == 1 ) {
|
|
647
|
+
|
|
648
|
+
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
649
|
+
|
|
650
|
+
} else {
|
|
651
|
+
|
|
652
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
653
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
654
|
+
panEnd.set( x, y );
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
659
|
+
pan( panDelta.x, panDelta.y );
|
|
660
|
+
panStart.copy( panEnd );
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function handleTouchMoveDolly( event ) {
|
|
665
|
+
|
|
666
|
+
const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
667
|
+
const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
668
|
+
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
669
|
+
dollyEnd.set( 0, distance );
|
|
670
|
+
dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) );
|
|
671
|
+
dollyOut( dollyDelta.y );
|
|
672
|
+
dollyStart.copy( dollyEnd );
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function handleTouchMoveDollyPan( event ) {
|
|
677
|
+
|
|
678
|
+
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
679
|
+
if ( scope.enablePan ) handleTouchMovePan( event );
|
|
680
|
+
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
function handleTouchMoveDollyRotate( event ) {
|
|
684
|
+
|
|
685
|
+
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
686
|
+
if ( scope.enableRotate ) handleTouchMoveRotate( event );
|
|
687
|
+
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function handleTouchEnd( ) { // no-op
|
|
691
|
+
} //
|
|
692
|
+
// event handlers - FSM: listen for events and reset state
|
|
693
|
+
//
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
function onPointerDown( event ) {
|
|
697
|
+
|
|
698
|
+
if ( scope.enabled === false ) return;
|
|
699
|
+
|
|
700
|
+
switch ( event.pointerType ) {
|
|
701
|
+
|
|
702
|
+
case 'mouse':
|
|
703
|
+
case 'pen':
|
|
704
|
+
onMouseDown( event );
|
|
705
|
+
break;
|
|
706
|
+
// TODO touch
|
|
707
|
+
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function onPointerMove( event ) {
|
|
713
|
+
|
|
714
|
+
if ( scope.enabled === false ) return;
|
|
715
|
+
|
|
716
|
+
switch ( event.pointerType ) {
|
|
717
|
+
|
|
718
|
+
case 'mouse':
|
|
719
|
+
case 'pen':
|
|
720
|
+
onMouseMove( event );
|
|
721
|
+
break;
|
|
722
|
+
// TODO touch
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function onPointerUp( event ) {
|
|
729
|
+
|
|
730
|
+
switch ( event.pointerType ) {
|
|
731
|
+
|
|
732
|
+
case 'mouse':
|
|
733
|
+
case 'pen':
|
|
734
|
+
onMouseUp( event );
|
|
735
|
+
break;
|
|
736
|
+
// TODO touch
|
|
737
|
+
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function onMouseDown( event ) {
|
|
743
|
+
|
|
744
|
+
// Prevent the browser from scrolling.
|
|
745
|
+
event.preventDefault(); // Manually set the focus since calling preventDefault above
|
|
746
|
+
// prevents the browser from setting it automatically.
|
|
747
|
+
|
|
748
|
+
scope.domElement.focus ? scope.domElement.focus() : window.focus();
|
|
749
|
+
let mouseAction;
|
|
750
|
+
|
|
751
|
+
switch ( event.button ) {
|
|
752
|
+
|
|
753
|
+
case 0:
|
|
754
|
+
mouseAction = scope.mouseButtons.LEFT;
|
|
755
|
+
break;
|
|
756
|
+
|
|
757
|
+
case 1:
|
|
758
|
+
mouseAction = scope.mouseButtons.MIDDLE;
|
|
759
|
+
break;
|
|
760
|
+
|
|
761
|
+
case 2:
|
|
762
|
+
mouseAction = scope.mouseButtons.RIGHT;
|
|
763
|
+
break;
|
|
764
|
+
|
|
765
|
+
default:
|
|
766
|
+
mouseAction = - 1;
|
|
767
|
+
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
switch ( mouseAction ) {
|
|
771
|
+
|
|
772
|
+
case THREE.MOUSE.DOLLY:
|
|
773
|
+
if ( scope.enableZoom === false ) return;
|
|
774
|
+
handleMouseDownDolly( event );
|
|
775
|
+
state = STATE.DOLLY;
|
|
776
|
+
break;
|
|
777
|
+
|
|
778
|
+
case THREE.MOUSE.ROTATE:
|
|
779
|
+
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
780
|
+
|
|
781
|
+
if ( scope.enablePan === false ) return;
|
|
782
|
+
handleMouseDownPan( event );
|
|
783
|
+
state = STATE.PAN;
|
|
784
|
+
|
|
785
|
+
} else {
|
|
786
|
+
|
|
787
|
+
if ( scope.enableRotate === false ) return;
|
|
788
|
+
handleMouseDownRotate( event );
|
|
789
|
+
state = STATE.ROTATE;
|
|
790
|
+
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
break;
|
|
794
|
+
|
|
795
|
+
case THREE.MOUSE.PAN:
|
|
796
|
+
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
797
|
+
|
|
798
|
+
if ( scope.enableRotate === false ) return;
|
|
799
|
+
handleMouseDownRotate( event );
|
|
800
|
+
state = STATE.ROTATE;
|
|
801
|
+
|
|
802
|
+
} else {
|
|
803
|
+
|
|
804
|
+
if ( scope.enablePan === false ) return;
|
|
805
|
+
handleMouseDownPan( event );
|
|
806
|
+
state = STATE.PAN;
|
|
807
|
+
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
break;
|
|
811
|
+
|
|
812
|
+
default:
|
|
813
|
+
state = STATE.NONE;
|
|
814
|
+
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if ( state !== STATE.NONE ) {
|
|
818
|
+
|
|
819
|
+
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove );
|
|
820
|
+
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp );
|
|
821
|
+
scope.dispatchEvent( _startEvent );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function onMouseMove( event ) {
|
|
828
|
+
|
|
829
|
+
if ( scope.enabled === false ) return;
|
|
830
|
+
event.preventDefault();
|
|
831
|
+
|
|
832
|
+
switch ( state ) {
|
|
833
|
+
|
|
834
|
+
case STATE.ROTATE:
|
|
835
|
+
if ( scope.enableRotate === false ) return;
|
|
836
|
+
handleMouseMoveRotate( event );
|
|
837
|
+
break;
|
|
838
|
+
|
|
839
|
+
case STATE.DOLLY:
|
|
840
|
+
if ( scope.enableZoom === false ) return;
|
|
841
|
+
handleMouseMoveDolly( event );
|
|
842
|
+
break;
|
|
843
|
+
|
|
844
|
+
case STATE.PAN:
|
|
845
|
+
if ( scope.enablePan === false ) return;
|
|
846
|
+
handleMouseMovePan( event );
|
|
847
|
+
break;
|
|
848
|
+
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function onMouseUp( event ) {
|
|
854
|
+
|
|
855
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
856
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
857
|
+
if ( scope.enabled === false ) return;
|
|
858
|
+
handleMouseUp( event );
|
|
859
|
+
scope.dispatchEvent( _endEvent );
|
|
860
|
+
state = STATE.NONE;
|
|
861
|
+
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function onMouseWheel( event ) {
|
|
865
|
+
|
|
866
|
+
if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE && state !== STATE.ROTATE ) return;
|
|
867
|
+
event.preventDefault();
|
|
868
|
+
scope.dispatchEvent( _startEvent );
|
|
869
|
+
handleMouseWheel( event );
|
|
870
|
+
scope.dispatchEvent( _endEvent );
|
|
871
|
+
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function onKeyDown( event ) {
|
|
875
|
+
|
|
876
|
+
if ( scope.enabled === false || scope.enablePan === false ) return;
|
|
877
|
+
handleKeyDown( event );
|
|
878
|
+
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function onTouchStart( event ) {
|
|
882
|
+
|
|
883
|
+
if ( scope.enabled === false ) return;
|
|
884
|
+
event.preventDefault(); // prevent scrolling
|
|
885
|
+
|
|
886
|
+
switch ( event.touches.length ) {
|
|
887
|
+
|
|
888
|
+
case 1:
|
|
889
|
+
switch ( scope.touches.ONE ) {
|
|
890
|
+
|
|
891
|
+
case THREE.TOUCH.ROTATE:
|
|
892
|
+
if ( scope.enableRotate === false ) return;
|
|
893
|
+
handleTouchStartRotate( event );
|
|
894
|
+
state = STATE.TOUCH_ROTATE;
|
|
895
|
+
break;
|
|
896
|
+
|
|
897
|
+
case THREE.TOUCH.PAN:
|
|
898
|
+
if ( scope.enablePan === false ) return;
|
|
899
|
+
handleTouchStartPan( event );
|
|
900
|
+
state = STATE.TOUCH_PAN;
|
|
901
|
+
break;
|
|
902
|
+
|
|
903
|
+
default:
|
|
904
|
+
state = STATE.NONE;
|
|
905
|
+
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
break;
|
|
909
|
+
|
|
910
|
+
case 2:
|
|
911
|
+
switch ( scope.touches.TWO ) {
|
|
912
|
+
|
|
913
|
+
case THREE.TOUCH.DOLLY_PAN:
|
|
914
|
+
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
915
|
+
handleTouchStartDollyPan( event );
|
|
916
|
+
state = STATE.TOUCH_DOLLY_PAN;
|
|
917
|
+
break;
|
|
918
|
+
|
|
919
|
+
case THREE.TOUCH.DOLLY_ROTATE:
|
|
920
|
+
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
921
|
+
handleTouchStartDollyRotate( event );
|
|
922
|
+
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
923
|
+
break;
|
|
924
|
+
|
|
925
|
+
default:
|
|
926
|
+
state = STATE.NONE;
|
|
927
|
+
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
break;
|
|
931
|
+
|
|
932
|
+
default:
|
|
933
|
+
state = STATE.NONE;
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if ( state !== STATE.NONE ) {
|
|
938
|
+
|
|
939
|
+
scope.dispatchEvent( _startEvent );
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
function onTouchMove( event ) {
|
|
946
|
+
|
|
947
|
+
if ( scope.enabled === false ) return;
|
|
948
|
+
event.preventDefault(); // prevent scrolling
|
|
949
|
+
|
|
950
|
+
switch ( state ) {
|
|
951
|
+
|
|
952
|
+
case STATE.TOUCH_ROTATE:
|
|
953
|
+
if ( scope.enableRotate === false ) return;
|
|
954
|
+
handleTouchMoveRotate( event );
|
|
955
|
+
scope.update();
|
|
956
|
+
break;
|
|
957
|
+
|
|
958
|
+
case STATE.TOUCH_PAN:
|
|
959
|
+
if ( scope.enablePan === false ) return;
|
|
960
|
+
handleTouchMovePan( event );
|
|
961
|
+
scope.update();
|
|
962
|
+
break;
|
|
963
|
+
|
|
964
|
+
case STATE.TOUCH_DOLLY_PAN:
|
|
965
|
+
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
966
|
+
handleTouchMoveDollyPan( event );
|
|
967
|
+
scope.update();
|
|
968
|
+
break;
|
|
969
|
+
|
|
970
|
+
case STATE.TOUCH_DOLLY_ROTATE:
|
|
971
|
+
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
972
|
+
handleTouchMoveDollyRotate( event );
|
|
973
|
+
scope.update();
|
|
974
|
+
break;
|
|
975
|
+
|
|
976
|
+
default:
|
|
977
|
+
state = STATE.NONE;
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
function onTouchEnd( event ) {
|
|
984
|
+
|
|
985
|
+
if ( scope.enabled === false ) return;
|
|
986
|
+
handleTouchEnd( event );
|
|
987
|
+
scope.dispatchEvent( _endEvent );
|
|
988
|
+
state = STATE.NONE;
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function onContextMenu( event ) {
|
|
993
|
+
|
|
994
|
+
if ( scope.enabled === false ) return;
|
|
995
|
+
event.preventDefault();
|
|
996
|
+
|
|
997
|
+
} //
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
scope.domElement.addEventListener( 'contextmenu', onContextMenu );
|
|
1001
|
+
scope.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
1002
|
+
scope.domElement.addEventListener( 'wheel', onMouseWheel, {
|
|
1003
|
+
passive: false
|
|
1004
|
+
} );
|
|
1005
|
+
scope.domElement.addEventListener( 'touchstart', onTouchStart, {
|
|
1006
|
+
passive: false
|
|
1007
|
+
} );
|
|
1008
|
+
scope.domElement.addEventListener( 'touchend', onTouchEnd );
|
|
1009
|
+
scope.domElement.addEventListener( 'touchmove', onTouchMove, {
|
|
1010
|
+
passive: false
|
|
1011
|
+
} ); // force an update at start
|
|
1012
|
+
|
|
1013
|
+
this.update();
|
|
1014
|
+
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
} // This set of controls performs orbiting, dollying (zooming), and panning.
|
|
1018
|
+
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
1019
|
+
// This is very similar to OrbitControls, another set of touch behavior
|
|
1020
|
+
//
|
|
1021
|
+
// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate
|
|
1022
|
+
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
1023
|
+
// Pan - left mouse, or arrow keys / touch: one-finger move
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
class MapControls extends OrbitControls {
|
|
1027
|
+
|
|
1028
|
+
constructor( object, domElement ) {
|
|
1029
|
+
|
|
1030
|
+
super( object, domElement );
|
|
1031
|
+
this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up
|
|
1032
|
+
|
|
1033
|
+
this.mouseButtons.LEFT = THREE.MOUSE.PAN;
|
|
1034
|
+
this.mouseButtons.RIGHT = THREE.MOUSE.ROTATE;
|
|
1035
|
+
this.touches.ONE = THREE.TOUCH.PAN;
|
|
1036
|
+
this.touches.TWO = THREE.TOUCH.DOLLY_ROTATE;
|
|
1037
|
+
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
THREE.MapControls = MapControls;
|
|
1043
|
+
THREE.OrbitControls = OrbitControls;
|
|
1044
|
+
|
|
1045
|
+
} )();
|