{"id":7679,"date":"2021-12-20T09:00:49","date_gmt":"2021-12-20T00:00:49","guid":{"rendered":"https:\/\/gunmagisgeek.com\/blog\/?p=7679"},"modified":"2021-12-20T09:01:22","modified_gmt":"2021-12-20T00:01:22","slug":"deck-gl%e3%81%a7%e5%9c%b0%e5%9b%b3%e4%b8%8a%e3%81%ab%e5%8b%95%e7%94%bb%e3%82%92%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/deck-gl\/7679","title":{"rendered":"deck.gl\u3067\u5730\u56f3\u4e0a\u306b\u52d5\u753b\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"\n<p>\u3053\u306e\u8a18\u4e8b\u306f<a href=\"https:\/\/qiita.com\/advent-calendar\/2021\/deckgl\">deck.gl Advent Calendar 2021&nbsp;<\/a>\u53c2\u52a0\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6982\u8981<\/h2>\n\n\n\n<p>deck.gl\u306b\u306f\u5730\u56f3\u4e0a\u306b\u753b\u50cf\u3092\u3072\u3087\u3046\u3058\u3059\u308b<a href=\"https:\/\/deck.gl\/docs\/api-reference\/layers\/bitmap-layer\" data-type=\"URL\" data-id=\"https:\/\/deck.gl\/docs\/api-reference\/layers\/bitmap-layer\">BitmapLayer<\/a>\u304c\u5b58\u5728\u3057\u307e\u3059\u304c\u3001\u3068\u304d\u306b\u306fLeaflet\u306e<a href=\"https:\/\/leafletjs.com\/examples\/video-overlay\/\" data-type=\"URL\" data-id=\"https:\/\/leafletjs.com\/examples\/video-overlay\/\">\u30b5\u30f3\u30d7\u30eb<\/a>\u306b\u3042\u308b\u3088\u3046\u306b\u52d5\u753b\u3092\u5730\u56f3\u4e0a\u306b\u63cf\u753b\u3057\u305f\u3044\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u3061\u3087\u3063\u3068\u3057\u305f\u5de5\u592b\u3067\u52d5\u753b\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u305d\u306e\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001\u52d5\u753b\u3092\u8868\u793a\u3059\u308b\u306b\u306fexperimental(\u5b9f\u9a13\u7684)\u3068\u306a\u3063\u3066\u3044\u308b\u30ec\u30a4\u30e4\u30fc\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u6a5f\u80fd\u3092\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u306e\u3053\u3068\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3(\u7279\u306biOS)\u306b\u306f\u975e\u5bfe\u5fdc\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/p>\n\n\n\n<iframe src=\"https:\/\/codesandbox.io\/embed\/deck-gl-di-tu-shang-nibideowobiao-shi-suru-lrnf1?fontsize=14&amp;hidenavigation=1&amp;theme=dark&amp;view=split\" style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\" title=\"deck.gl - \u5730\u56f3\u4e0a\u306b\u30d3\u30c7\u30aa\u3092\u8868\u793a\u3059\u308b\" 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>\u52d5\u753b\u30d5\u30a1\u30a4\u30eb\u3092video\u8981\u7d20\u306b\u8aad\u307f\u8fbc\u307f\u3001SimpleMeshLayer\u3092\u7528\u3044\u3066\u751f\u6210\u3057\u305f\u5e73\u9762\u30b8\u30aa\u30e1\u30c8\u30ea\u306b\u30c6\u30af\u30b9\u30c1\u30e3\u30fc\u3068\u3057\u3066\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:js decode:true \" title=\"RenderLayers.js\">import { TileLayer } from \"deck.gl\";\nimport { PlaneGeometry } from \"@luma.gl\/engine\";\n\n\/\/\u5e73\u9762\u306e\u30b8\u30aa\u30e1\u30c8\u30ea\u3092\u751f\u6210\nconst plane = new PlaneGeometry({\n  type: \"x,z\",\n  xlen: 426,\n  zlen: 260,\n  nx: 5,\n  nz: 5,\n  offset: 0\n});\n\n\/\/plane\u3092\u63cf\u753b\u3059\u308b\u4f4d\u7f6e\uff08\u7def\u5ea6\u7d4c\u5ea6\uff09\u3092\u6307\u5b9a\nconst data = [\n  {\n    position: [-115, 22.5]\n  }\n];\n\nexport function renderLayers(props) {\n  const { video } = props; \/\/\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089video\u8981\u7d20\u3092\u53d7\u3051\u53d6\u308b\n\n  \/\/geometry\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\n  const meshlayer = new SimpleMeshLayer({\n    id: \"mesh-layer\",\n    data: data, \/\/\u4f4d\u7f6e\u60c5\u5831\u3092\u6e21\u3059\n    mesh: plane, \/\/\u5e73\u9762\u30b8\u30aa\u30e1\u30c8\u30ea\u3092\u6307\u5b9a\u3059\u308b\n    texture: video, \/\/\u52d5\u753b\u3092\u518d\u751f\u3057\u3066\u3044\u308bvideo\u8981\u7d20\u3092\u30c6\u30af\u30b9\u30c1\u30e3\u30fc\u3068\u3057\u3066\u6307\u5b9a\u3059\u308b\n    sizeScale: 9000,\n    getPosition: (d) =&gt; d.position,\n    getColor: (d) =&gt; [255, 0, 0],\n    getOrientation: (d) =&gt; [0, 0, 90],\n    material: false\n  });\n\n  return [meshlayer];\n}\n<\/pre><\/div>\n\n\n\n<p>\u518d\u751f\u3057\u3066\u3044\u308b\u52d5\u753b\u3092\u9023\u7d9a\u7684\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3059\u308b\u305f\u3081\u306b\u3001Deck\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e_animate\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6709\u52b9\u5316\u3057\u3066\u307e\u3059\u3002 <\/p>\n\n\n\n<p>_animate\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6709\u52b9\u306b\u3059\u308b\u3068\u3001deck.gl\u306f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u3054\u3068\u306b\u30ec\u30a4\u30e4\u30fc\u306e\u518d\u63cf\u753b\u3092\u884c\u3046\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:js decode:true \" title=\"App.js\">const VIDEO_URL = \".\/video\/patricia_nasa.mp4\";\n\nconst App = () =&gt; {\n  const [video, setVideo] = useState(null);\n\n  useEffect(() =&gt; {\n    let videoEl;\n    if (typeof document !== \"undefined\") {\n      \/\/\u30d3\u30c7\u30aa\u8981\u7d20\u3092\u751f\u6210\u3059\u308b\n      videoEl = document.createElement(\"video\");\n      videoEl.crossOrigin = \"anonymous\"; \/\/\u30e6\u30fc\u30b6\u30fc\u8cc7\u683c\u60c5\u5831\u3092\u9001\u4fe1\n      videoEl.preload = \"auto\"; \/\/ \u81ea\u52d5\u3067\u52d5\u753b\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u3092\u884c\u3046\n      videoEl.muted = true; \/\/\u97f3\u58f0\u3092\u30df\u30e5\u30fc\u30c8\u306b\n      videoEl.loop = true; \/\/\u30eb\u30fc\u30d7\u518d\u751f\u3092\u6709\u52b9\u5316\n      videoEl.autoplay = true; \/\/\u81ea\u52d5\u518d\u751f\u3092\u6709\u52b9\u5316\n\n      \/\/\u52d5\u753b\u30bd\u30fc\u30b9\u8981\u7d20\u3092\u751f\u6210\n      const source = document.createElement(\"source\");\n      source.src = VIDEO_URL; \/\/\u30d3\u30c7\u30aa\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u6307\u5b9a\n      videoEl.append(source); \/\/\u30d3\u30c7\u30aa\u8981\u7d20\u306b\u52d5\u753b\u30bd\u30fc\u30b9\u8981\u7d20\u3092\u52a0\u3048\u308b\n\n      videoEl.onloadeddata = (event) =&gt; {\n        \/\/\u30c7\u30fc\u30bf\u304c\u8aad\u307f\u8fbc\u307e\u308c\u52d5\u753b\u306e\u518d\u751f\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3089\u3001\u518d\u751f\u3059\u308b\n        videoEl.play();\n      };\n\n      \/\/\u30d3\u30c7\u30aa\u8981\u7d20\u3092\u4fdd\u5b58\n      setVideo(videoEl);\n    }\n  }, []);\n\n  \/\/\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\n  return (\n      &lt;DeckGL\n        views={\n          new MapView({\n            repeat: true\n          })\n        }\n        layers={renderLayers({ video })} \/\/\u30ec\u30a4\u30e4\u30fc\u306b\u30d3\u30c7\u30aa\u8981\u7d20\u3092\u6e21\u3059\n        controller={{ type: MapController }}\n        initialViewState={viewState}\n        _animate={true} \/\/\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u3054\u3068\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u5316\u3059\u308b\n      \/&gt;\n  );\n};\n\nexport default App;\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u306fdeck.gl Advent Calen&hellip;<\/p>\n","protected":false},"author":1,"featured_media":7682,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"class_list":["post-7679","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\/7679","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=7679"}],"version-history":[{"count":5,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/7679\/revisions"}],"predecessor-version":[{"id":7862,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/7679\/revisions\/7862"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/7682"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=7679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=7679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=7679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}