{"id":6997,"date":"2020-10-15T17:56:12","date_gmt":"2020-10-15T08:56:12","guid":{"rendered":"https:\/\/gunmagisgeek.com\/blog\/?p=6997"},"modified":"2020-10-16T01:15:55","modified_gmt":"2020-10-15T16:15:55","slug":"deck-gl-%e3%81%a7%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%82%b7%e3%82%a7%e3%83%bc%e3%83%80%e3%83%bc%e3%82%92%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/deck-gl\/6997","title":{"rendered":"deck.gl \u3067\u30ab\u30b9\u30bf\u30e0\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u4f7f\u3046"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u6982\u8981<\/h2>\n\n\n\n<p>Deck.gl\u3067\u306f\u958b\u767a\u8005\u304c\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u65b9\u6cd5\u304c\u3044\u304f\u3064\u304b\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u306f<a href=\"https:\/\/deck.gl\/docs\/developer-guide\/custom-layers\/layer-extensions\" data-type=\"URL\" data-id=\"https:\/\/deck.gl\/docs\/developer-guide\/custom-layers\/layer-extensions\">LayerExtension<\/a>\u3092\u4f7f\u3063\u3066\u72ec\u81ea\u306e\u30b7\u30a7\u30fc\u30c0\u30fc\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb<\/h2>\n\n\n\n<p>LayerExtension\u3092\u7528\u3044\u3066ScatterplotLayer\u306b\u3001\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u633f\u5165\u3057\u3001\u51fa\u529b\u7d50\u679c\u3092\u30af\u30ed\u30b9\uff08\u5341\u5b57\uff09\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<iframe src=\"https:\/\/codesandbox.io\/embed\/use-layerextension-kb26g?fontsize=14&amp;hidenavigation=1&amp;theme=dark&amp;;view=split\" style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\" title=\"Use LayerExtension\" allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\" sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u8aac<\/h2>\n\n\n\n<p>Deck.gl\u306e\u30ec\u30a4\u30e4\u30fc\u30af\u30e9\u30b9\u306b\u306f\u3001\u3042\u3089\u304b\u3058\u3081\u30ec\u30a4\u30e4\u30fc\u3092\u62e1\u5f35\u3059\u308b\u305f\u3081\u306e<a href=\"https:\/\/deck.gl\/docs\/api-reference\/core\/layer#extensions\" data-type=\"URL\" data-id=\"https:\/\/deck.gl\/docs\/api-reference\/core\/layer#extensions\">extensions<\/a>\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>extensions\u306e\u6a5f\u80fd\u306e\u4e00\u3064\u3068\u3057\u3066\u3001deck.gl\u304c\u751f\u6210\u3059\u308b\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u30d5\u30c3\u30af\u3057\u3066\u30aa\u30ea\u30b8\u30ca\u30eb\u306a\u30b7\u30a7\u30fc\u30c0\u30fc\u30b3\u30fc\u30c9\u3092\u6ce8\u5165(inject)\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><\/div>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:js decode:true \" title=\"Layers.js\">import { ScatterplotLayer, LayerExtension } from \"deck.gl\";\n\n\/\/LayerExtension\u3092\u7d99\u627f\u3057\u3001\u30aa\u30ea\u30b8\u30ca\u30eb\u306a\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\nclass injectionShader extends LayerExtension {\n  \/\/\n  getShaders() {\n    return {\n      inject: {\n        \"fs:#decl\": ` \/\/\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u30b7\u30a7\u30fc\u30c0\u30fc\u306e\u5192\u982d\u306b\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3059\u308b\n          uniform bool changeCloss;\n          `,\n        \"fs:#main-end\": ` \/\/\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u30b7\u30a7\u30fc\u30c0\u30fc\u306emain\u95a2\u6570\u306e\u6700\u5f8c\u306b\u30b3\u30fc\u30c9\u3092\u6ce8\u5165\u3059\u308b\n          if(changeCloss){\n            if (abs(unitPosition.x) &lt; 0.2 || abs(unitPosition.y) &lt; 0.2) {\n              gl_FragColor = vFillColor;\n            } else {\n              discard;\n            }\n          }\n        `\n      }\n    };\n  }\n\n  \/\/\u89aa\u30ec\u30a4\u30e4\u30fc\u304b\u3089\u547c\u3073\u51fa\u3055\u308c\u308b\u95a2\u6570\n  updateState(params) {\n    \/\/\u89aa\u30ec\u30a4\u30e4\u30fc\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u304b\u3089chageCloss\u306e\u5024\u3092\u53d6\u5f97\n    const { changeCloss = true } = params.props;\n    for (const model of this.getModels()) {\n      \/\/changeCloss\u306e\u5024\u3092uniforms\u3068\u3057\u3066\u6e21\u3059\n      model.setUniforms({ changeCloss });\n    }\n  }\n}\n\nexport function renderLayers(props) {\n  const { data, checkBtn } = props;\n  \/\/\u30ab\u30b9\u30bf\u30e0\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\n  const extension = new injectionShader();\n\n  const layes = [\n    new ScatterplotLayer({\n      id: \"hexagon-layer\",\n      data,\n      pickable: true,\n      opacity: 0.8,\n      stroked: true,\n      filled: true,\n      radiusScale: 6,\n      radiusMinPixels: 1,\n      radiusMaxPixels: 300,\n      lineWidthMinPixels: 1,\n      getPosition: (d) =&gt; d.position,\n      getRadius: 300,\n      getFillColor: (d) =&gt; [255, 0, 0],\n      getLineColor: (d) =&gt; [255, 255, 255],\n      changeCloss: checkBtn,\n      extensions: [extension] \/\/\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\n    })\n  ];\n\n  return layes;\n}\n<\/pre><\/div>\n\n\n\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306b\u30c1\u30a7\u30c3\u30af\u304c\u5165\u308b\u3068true\u306e\u5024\u304c\u89aa\u30ec\u30a4\u30e4\u30fc\u306echangeCloss\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u7d4c\u7531\u3057\u3066\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u30b7\u30a7\u30fc\u30c0\u30fc\u306buniform\u5909\u6570\u3068\u3057\u3066\u6e21\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u306e\u5f8c\u3001\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u30d5\u30c3\u30af\u3059\u308b\u30ab\u30b9\u30bf\u30e0\u30b3\u30fc\u30c9\u300cfs:#main-end\u300d\u306b\u5165\u529b\u3055\u308c\u305f\u30b3\u30fc\u30c9\u304c\u30b7\u30a7\u30fc\u30c0\u30fc\u306emain\u95a2\u6570\u306e\u6700\u5f8c\u306b\u6ce8\u5165\u3055\u308c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30b3\u30fc\u30c9\u3092\u6ce8\u5165\u3059\u308b\u5834\u6240\u306f\u3042\u3089\u304b\u3058\u3081\u3044\u304f\u3064\u304b\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u30ea\u30f3\u30af\u5148\u30da\u30fc\u30b8\u306e\u300c<a href=\"https:\/\/deck.gl\/docs\/developer-guide\/custom-layers\/writing-shaders#standard-shader-hooks\" data-type=\"URL\" data-id=\"https:\/\/deck.gl\/docs\/developer-guide\/custom-layers\/writing-shaders#standard-shader-hooks\">Standard Shader Hooks<\/a>\u300d\u306e\u7ae0\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Deck.gl\u3067\u306f\u958b\u767a\u8005\u304c\u30b7\u30a7\u30fc\u30c0\u30fc\u3092\u30ab\u30b9\u30bf&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6998,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"class_list":["post-6997","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-deck-gl","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=6997"}],"version-history":[{"count":8,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6997\/revisions"}],"predecessor-version":[{"id":7007,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6997\/revisions\/7007"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/6998"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=6997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=6997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=6997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}