diff --git a/package-lock.json b/package-lock.json index daf5797..7c5df3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,12 +89,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.0.tgz", - "integrity": "sha512-C6u00HbmsrNPug6A+CiNl8rEys7TsdcXwg12BHi2ca5rUfAs3+UwZsuDQSXnc+wCElCXMB8gMaJ3YXDdh8fAlg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.1.tgz", + "integrity": "sha512-TMGhsXMXCP/O1WtQmZjpEYDhCYC9vFhayWZPJSZCGkPJgUqX0rF0wwtrYvnzVxIjcF80tkUertXVk5cwqi5cAQ==", "dev": true, "dependencies": { - "@babel/types": "^7.14.0", + "@babel/types": "^7.14.1", "jsesc": "^2.5.1", "source-map": "^0.5.0" } @@ -134,9 +134,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.14.0.tgz", - "integrity": "sha512-6pXDPguA5zC40Y8oI5mqr+jEUpjMJonKvknvA+vD8CYDz5uuXEwWBK8sRAsE/t3gfb1k15AQb9RhwpscC4nUJQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.14.1.tgz", + "integrity": "sha512-r8rsUahG4ywm0QpGcCrLaUSOuNAISR3IZCg4Fx05Ozq31aCUrQsTLH6KPxy0N5ULoQ4Sn9qjNdGNtbPWAC6hYg==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.12.13", @@ -367,9 +367,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.0.tgz", - "integrity": "sha512-AHbfoxesfBALg33idaTBVUkLnfXtsgvJREf93p4p0Lwsz4ppfE7g1tpEXVm4vrxUcH4DVhAa9Z1m1zqf9WUC7Q==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.1.tgz", + "integrity": "sha512-muUGEKu8E/ftMTPlNp+mc6zL3E9zKWmF5sDHZ5MSsoTP9Wyz64AhEf9kD08xYJ7w6Hdcu8H550ircnPyWSIF0Q==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -842,9 +842,9 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.13.16", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.13.16.tgz", - "integrity": "sha512-ad3PHUxGnfWF4Efd3qFuznEtZKoBp0spS+DgqzVzRPV7urEBvPLue3y2j80w4Jf2YLzZHj8TOv/Lmvdmh3b2xg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.14.1.tgz", + "integrity": "sha512-2mQXd0zBrwfp0O1moWIhPpEeTKDvxyHcnma3JATVP1l+CctWBuot6OJG8LQ4DnBj4ZZPSmlb/fm4mu47EOAnVA==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.13.0" @@ -1243,9 +1243,9 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.0.tgz", - "integrity": "sha512-GWRCdBv2whxqqaSi7bo/BEXf070G/fWFMEdCnmoRg2CZJy4GK06ovFuEjJrZhDRXYgBsYtxVbG8GUHvw+UWBkQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.1.tgz", + "integrity": "sha512-0M4yL1l7V4l+j/UHvxcdvNfLB9pPtIooHTbEhgD/6UGyh8Hy3Bm1Mj0buzjDXATCSz3JFibVdnoJZCrlUCanrQ==", "dev": true, "dependencies": { "@babel/compat-data": "^7.14.0", @@ -1285,7 +1285,7 @@ "@babel/plugin-transform-arrow-functions": "^7.13.0", "@babel/plugin-transform-async-to-generator": "^7.13.0", "@babel/plugin-transform-block-scoped-functions": "^7.12.13", - "@babel/plugin-transform-block-scoping": "^7.13.16", + "@babel/plugin-transform-block-scoping": "^7.14.1", "@babel/plugin-transform-classes": "^7.13.0", "@babel/plugin-transform-computed-properties": "^7.13.0", "@babel/plugin-transform-destructuring": "^7.13.17", @@ -1315,7 +1315,7 @@ "@babel/plugin-transform-unicode-escapes": "^7.12.13", "@babel/plugin-transform-unicode-regex": "^7.12.13", "@babel/preset-modules": "^0.1.4", - "@babel/types": "^7.14.0", + "@babel/types": "^7.14.1", "babel-plugin-polyfill-corejs2": "^0.2.0", "babel-plugin-polyfill-corejs3": "^0.2.0", "babel-plugin-polyfill-regenerator": "^0.2.0", @@ -1393,9 +1393,9 @@ } }, "node_modules/@babel/types": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.0.tgz", - "integrity": "sha512-O2LVLdcnWplaGxiPBz12d0HcdN8QdxdsWYhz5LSeuukV/5mn2xUUc3gBeU4QBYPJ18g/UToe8F532XJ608prmg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.1.tgz", + "integrity": "sha512-S13Qe85fzLs3gYRUnrpyeIrBJIMYv33qSTg1qoBwiG6nPKwUWAD9odSzWhEedpwOIzSEI6gbdQIWEMiCI42iBA==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.14.0", @@ -2125,9 +2125,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001220", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001220.tgz", - "integrity": "sha512-pjC2T4DIDyGAKTL4dMvGUQaMUHRmhvPpAgNNTa14jaBWHu+bLQgvpFqElxh9L4829Fdx0PlKiMp3wnYldRtECA==", + "version": "1.0.30001221", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001221.tgz", + "integrity": "sha512-b9TOZfND3uGSLjMOrLh8XxSQ41x8mX+9MLJYDM4AAHLfaZHttrLNPrScWjVnBITRZbY5sPpCt7X85n7VSLZ+/g==", "dev": true }, "node_modules/caseless": { @@ -2430,12 +2430,12 @@ } }, "node_modules/core-js-compat": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.1.tgz", - "integrity": "sha512-aZ0e4tmlG/aOBHj92/TuOuZwp6jFvn1WNabU5VOVixzhu5t5Ao+JZkQOPlgNXu6ynwLrwJxklT4Gw1G1VGEh+g==", + "version": "3.11.2", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.2.tgz", + "integrity": "sha512-gYhNwu7AJjecNtRrIfyoBabQ3ZG+llfPmg9BifIX8yxIpDyfNLRM73zIjINSm6z3dMdI1nwNC9C7uiy4pIC6cw==", "dev": true, "dependencies": { - "browserslist": "^4.16.5", + "browserslist": "^4.16.6", "semver": "7.0.0" }, "funding": { @@ -6760,12 +6760,12 @@ } }, "@babel/generator": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.0.tgz", - "integrity": "sha512-C6u00HbmsrNPug6A+CiNl8rEys7TsdcXwg12BHi2ca5rUfAs3+UwZsuDQSXnc+wCElCXMB8gMaJ3YXDdh8fAlg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.1.tgz", + "integrity": "sha512-TMGhsXMXCP/O1WtQmZjpEYDhCYC9vFhayWZPJSZCGkPJgUqX0rF0wwtrYvnzVxIjcF80tkUertXVk5cwqi5cAQ==", "dev": true, "requires": { - "@babel/types": "^7.14.0", + "@babel/types": "^7.14.1", "jsesc": "^2.5.1", "source-map": "^0.5.0" } @@ -6802,9 +6802,9 @@ } }, "@babel/helper-create-class-features-plugin": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.14.0.tgz", - "integrity": "sha512-6pXDPguA5zC40Y8oI5mqr+jEUpjMJonKvknvA+vD8CYDz5uuXEwWBK8sRAsE/t3gfb1k15AQb9RhwpscC4nUJQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.14.1.tgz", + "integrity": "sha512-r8rsUahG4ywm0QpGcCrLaUSOuNAISR3IZCg4Fx05Ozq31aCUrQsTLH6KPxy0N5ULoQ4Sn9qjNdGNtbPWAC6hYg==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.12.13", @@ -7026,9 +7026,9 @@ } }, "@babel/parser": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.0.tgz", - "integrity": "sha512-AHbfoxesfBALg33idaTBVUkLnfXtsgvJREf93p4p0Lwsz4ppfE7g1tpEXVm4vrxUcH4DVhAa9Z1m1zqf9WUC7Q==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.1.tgz", + "integrity": "sha512-muUGEKu8E/ftMTPlNp+mc6zL3E9zKWmF5sDHZ5MSsoTP9Wyz64AhEf9kD08xYJ7w6Hdcu8H550ircnPyWSIF0Q==", "dev": true }, "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { @@ -7384,9 +7384,9 @@ } }, "@babel/plugin-transform-block-scoping": { - "version": "7.13.16", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.13.16.tgz", - "integrity": "sha512-ad3PHUxGnfWF4Efd3qFuznEtZKoBp0spS+DgqzVzRPV7urEBvPLue3y2j80w4Jf2YLzZHj8TOv/Lmvdmh3b2xg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.14.1.tgz", + "integrity": "sha512-2mQXd0zBrwfp0O1moWIhPpEeTKDvxyHcnma3JATVP1l+CctWBuot6OJG8LQ4DnBj4ZZPSmlb/fm4mu47EOAnVA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.13.0" @@ -7692,9 +7692,9 @@ } }, "@babel/preset-env": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.0.tgz", - "integrity": "sha512-GWRCdBv2whxqqaSi7bo/BEXf070G/fWFMEdCnmoRg2CZJy4GK06ovFuEjJrZhDRXYgBsYtxVbG8GUHvw+UWBkQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.1.tgz", + "integrity": "sha512-0M4yL1l7V4l+j/UHvxcdvNfLB9pPtIooHTbEhgD/6UGyh8Hy3Bm1Mj0buzjDXATCSz3JFibVdnoJZCrlUCanrQ==", "dev": true, "requires": { "@babel/compat-data": "^7.14.0", @@ -7734,7 +7734,7 @@ "@babel/plugin-transform-arrow-functions": "^7.13.0", "@babel/plugin-transform-async-to-generator": "^7.13.0", "@babel/plugin-transform-block-scoped-functions": "^7.12.13", - "@babel/plugin-transform-block-scoping": "^7.13.16", + "@babel/plugin-transform-block-scoping": "^7.14.1", "@babel/plugin-transform-classes": "^7.13.0", "@babel/plugin-transform-computed-properties": "^7.13.0", "@babel/plugin-transform-destructuring": "^7.13.17", @@ -7764,7 +7764,7 @@ "@babel/plugin-transform-unicode-escapes": "^7.12.13", "@babel/plugin-transform-unicode-regex": "^7.12.13", "@babel/preset-modules": "^0.1.4", - "@babel/types": "^7.14.0", + "@babel/types": "^7.14.1", "babel-plugin-polyfill-corejs2": "^0.2.0", "babel-plugin-polyfill-corejs3": "^0.2.0", "babel-plugin-polyfill-regenerator": "^0.2.0", @@ -7833,9 +7833,9 @@ } }, "@babel/types": { - "version": "7.14.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.0.tgz", - "integrity": "sha512-O2LVLdcnWplaGxiPBz12d0HcdN8QdxdsWYhz5LSeuukV/5mn2xUUc3gBeU4QBYPJ18g/UToe8F532XJ608prmg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.1.tgz", + "integrity": "sha512-S13Qe85fzLs3gYRUnrpyeIrBJIMYv33qSTg1qoBwiG6nPKwUWAD9odSzWhEedpwOIzSEI6gbdQIWEMiCI42iBA==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.14.0", @@ -8442,9 +8442,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001220", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001220.tgz", - "integrity": "sha512-pjC2T4DIDyGAKTL4dMvGUQaMUHRmhvPpAgNNTa14jaBWHu+bLQgvpFqElxh9L4829Fdx0PlKiMp3wnYldRtECA==", + "version": "1.0.30001221", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001221.tgz", + "integrity": "sha512-b9TOZfND3uGSLjMOrLh8XxSQ41x8mX+9MLJYDM4AAHLfaZHttrLNPrScWjVnBITRZbY5sPpCt7X85n7VSLZ+/g==", "dev": true }, "caseless": { @@ -8690,12 +8690,12 @@ } }, "core-js-compat": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.1.tgz", - "integrity": "sha512-aZ0e4tmlG/aOBHj92/TuOuZwp6jFvn1WNabU5VOVixzhu5t5Ao+JZkQOPlgNXu6ynwLrwJxklT4Gw1G1VGEh+g==", + "version": "3.11.2", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.2.tgz", + "integrity": "sha512-gYhNwu7AJjecNtRrIfyoBabQ3ZG+llfPmg9BifIX8yxIpDyfNLRM73zIjINSm6z3dMdI1nwNC9C7uiy4pIC6cw==", "dev": true, "requires": { - "browserslist": "^4.16.5", + "browserslist": "^4.16.6", "semver": "7.0.0" }, "dependencies": { diff --git a/src/js/clip/Selection.js b/src/js/clip/Selection.js index adabc0e..249f0c7 100644 --- a/src/js/clip/Selection.js +++ b/src/js/clip/Selection.js @@ -102,7 +102,6 @@ export class Selection extends Layer { map.scene.remove(this.touchMeshes); } - build(app_scene) { // app_scene.add(this.boxMesh); app_scene.add(this.displayMeshes); @@ -131,7 +130,7 @@ export class Selection extends Layer { scaleZ(z) { this.scale = z; - this.boxMesh.scale.z = z; + // this.boxMesh.scale.z = z; this.displayMeshes.scale.z = z; this.touchMeshes.scale.z = z; this.setUniforms(); diff --git a/src/js/layer/TinLayer.ts b/src/js/layer/TinLayer.ts index 7845e0a..e539e86 100644 --- a/src/js/layer/TinLayer.ts +++ b/src/js/layer/TinLayer.ts @@ -106,12 +106,13 @@ class TinLayer extends Layer { setVisible(visible) { this.visible = visible; this.objectGroup.visible = visible; - this.emit('visibility-change'); + this.emit('visibility-change', visible); } scaleZ(z) { this.scale = z; this.objectGroup.scale.z = z; + this.emit('scale-change', z); } async onAdd(map) { diff --git a/src/js/main.js b/src/js/main.js index 2290494..87bb3ad 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -176,9 +176,18 @@ class Application { let layer = map.layers[i]; if (layer instanceof TinLayer && layer.name != "Topography") { let mesh = new Mesh(layer.geometry.clone(), material.frontStencilMaterial); + mesh.userData.layerId = layer.index; frontGroup.add(mesh); + layer.on('visibility-change', (args) => { + let visible = args[0]; + mesh.visible = visible; + }); + layer.on('scale-change', (args) => { + let z = args[0]; + mesh.scale.z = z; + }); } - } + } frontGroup.updateMatrix(); // let frontMesh = new Mesh(frontGroup, material.frontStencilMaterial); this.frontStencil.add(frontGroup); @@ -188,9 +197,19 @@ class Application { let layer = map.layers[i]; if (layer instanceof TinLayer && layer.name != "Topography") { let mesh = new Mesh(layer.geometry.clone(), material.backStencilMaterial); + mesh.userData.layerId = layer.index; backGroup.add(mesh); + layer.on('visibility-change', (args) => { + let visible = args[0]; + mesh.visible = visible; + }); + layer.on('scale-change', (args) => { + let z = args[0]; + mesh.scale.z = z; + }); + } - } + } backGroup.updateMatrix(); // let frontMesh = new Mesh(frontGroup, material.frontStencilMaterial); this.backStencil.add(backGroup); @@ -332,13 +351,13 @@ class Application { if (this.showCaps && gl != undefined) { // enable stencil test - gl.enable(gl.STENCIL_TEST); + gl.enable(gl.STENCIL_TEST); // this.renderer.state.setStencilFunc( true ); // gl.stencilFunc( gl.ALWAYS, 1, 0xff ); // gl.stencilOp( gl.REPLACE, gl.REPLACE, gl.REPLACE ); - + gl.stencilFunc(gl.ALWAYS, 1, 0xff); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); this.renderer.render(this.backStencil, this.map.camera); gl.stencilFunc(gl.ALWAYS, 1, 0xff);