[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\n    [\n      \"@babel/env\",\n      {\n        \"targets\": {\n          \"browsers\": \"ie>=11, > 0.25%, not dead\"\n        },\n        \"corejs\": \"3.6\",\n        \"useBuiltIns\": \"usage\"\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": ".eslintignore",
    "content": "bazel-*\ncoverage/\ndist/\ndocs/\nlib/\nnode_modules/\npublic/"
  },
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"extends\": [\"eslint:recommended\", \"plugin:prettier/recommended\"],\n  \"parserOptions\": {\n    \"ecmaVersion\": 12,\n    \"sourceType\": \"module\",\n    \"ecmaFeatures\": {\n      \"jsx\": true\n    }\n  },\n  \"plugins\": [\"jest\"],\n  \"rules\": {\n    \"no-var\": 2,\n    \"prefer-arrow-callback\": 2\n  },\n  \"overrides\": [\n    {\n      \"files\": [\"*.ts\", \"*.tsx\"],\n      \"parser\": \"@typescript-eslint/parser\",\n      \"plugins\": [\"@typescript-eslint\"],\n      \"extends\": [\"plugin:@typescript-eslint/recommended\"],\n      \"rules\": {\n        \"@typescript-eslint/ban-ts-comment\": 0,\n        \"@typescript-eslint/ban-types\": 1,\n        \"@typescript-eslint/no-empty-function\": 1,\n        \"@typescript-eslint/member-ordering\": 1,\n        \"@typescript-eslint/explicit-member-accessibility\": [\n          1,\n          {\n            \"accessibility\": \"explicit\",\n            \"overrides\": {\n              \"accessors\": \"explicit\",\n              \"constructors\": \"no-public\",\n              \"methods\": \"explicit\",\n              \"properties\": \"explicit\",\n              \"parameterProperties\": \"explicit\"\n            }\n          }\n        ]\n      }\n    }\n  ],\n  \"env\": {\n    \"browser\": true,\n    \"node\": true,\n    \"es6\": true,\n    \"jest/globals\": true\n  },\n  \"globals\": { \"google\": \"readonly\" }\n}\n"
  },
  {
    "path": ".github/CODEOWNERS",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners\n\n.github/ @googlemaps/admin\n"
  },
  {
    "path": ".github/bundlewatch.config.json",
    "content": "{\n  \"files\": [\n    {\n      \"path\": \"dist/index.*.js\"\n    }\n  ],\n  \"ci\": {\n    \"trackBranches\": [\"main\"],\n    \"repoBranchBase\": \"main\"\n  }\n}\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nversion: 2\nupdates:\n  - package-ecosystem: \"npm\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n"
  },
  {
    "path": ".github/sync-repo-settings.yaml",
    "content": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings\n\nrebaseMergeAllowed: true\nsquashMergeAllowed: true\nmergeCommitAllowed: false\ndeleteBranchOnMerge: true\nbranchProtectionRules:\n- pattern: main\n  isAdminEnforced: false\n  requiresStrictStatusChecks: false\n  requiredStatusCheckContexts:\n    - 'cla/google'\n    - 'test'\n    - 'snippet-bot check'\n    - 'header-check'\n  requiredApprovingReviewCount: 1\n  requiresCodeOwnerReviews: true\n- pattern: master\n  isAdminEnforced: false\n  requiresStrictStatusChecks: false\n  requiredStatusCheckContexts:\n    - 'cla/google'\n    - 'test'\n    - 'snippet-bot check'\n    - 'header-check'\n  requiredApprovingReviewCount: 1\n  requiresCodeOwnerReviews: true\npermissionRules:\n  - team: admin\n    permission: admin\n"
  },
  {
    "path": ".github/workflows/bundlewatch.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Bundlewatch\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    types: [synchronize, opened]\n\njobs:\n  bundlewatch:\n    runs-on: ubuntu-latest\n    env:\n      CI_BRANCH_BASE: main\n    steps:\n      - uses: actions/checkout@v2\n      - uses: jackyef/bundlewatch-gh-action@b9753bc9b3ea458ff21069eaf6206e01e046f0b5\n        with:\n          build-script: npm i\n          bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}\n          bundlewatch-config: .github/bundlewatch.config.json\n"
  },
  {
    "path": ".github/workflows/codeql.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [main]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [main]\n  schedule:\n    - cron: \"0 13 * * *\"\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [\"javascript\"]\n        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]\n        # Learn more:\n        # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v2\n\n      # Initializes the CodeQL tools for scanning.\n      - name: Initialize CodeQL\n        uses: github/codeql-action/init@v1\n        with:\n          languages: ${{ matrix.language }}\n          # If you wish to specify custom queries, you can do so here or in a config file.\n          # By default, queries listed here will override any specified in a config file.\n          # Prefix the list here with \"+\" to use these queries and those in the config file.\n          # queries: ./path/to/local/query, your-org/your-repo/queries@main\n\n      # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n      # If this step fails, then you should remove it and run the build manually (see below)\n      - name: Autobuild\n        uses: github/codeql-action/autobuild@v1\n\n      # ℹ️ Command-line programs to run using the OS shell.\n      # 📚 https://git.io/JvXDl\n\n      # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines\n      #    and modify them (or add more) to build your code if your project\n      #    uses a compiled language\n\n      #- run: |\n      #   make bootstrap\n      #   make release\n\n      - name: Perform CodeQL Analysis\n        uses: github/codeql-action/analyze@v1\n"
  },
  {
    "path": ".github/workflows/dependabot.yml",
    "content": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Dependabot\non: pull_request\n\npermissions:\n  contents: write\n\njobs:\n  dependabot:\n    runs-on: ubuntu-latest\n    if: ${{ github.actor == 'dependabot[bot]' }}\n    env:\n      PR_URL: ${{github.event.pull_request.html_url}}\n      GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}}\n    steps:\n      - name: approve\n        run: gh pr review --approve \"$PR_URL\"\n      - name: merge\n        run: gh pr merge --auto --squash --delete-branch \"$PR_URL\"\n"
  },
  {
    "path": ".github/workflows/docs.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Docs\non: [push, pull_request]\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - uses: actions/cache@v2\n        with:\n          path: ~/.npm\n          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-node-\n      - run: |\n          npm i\n          npm run docs\n      - uses: peaceiris/actions-gh-pages@v3\n        if: github.ref == 'refs/heads/main'\n        with:\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n          publish_dir: ./docs\n          user_name: 'googlemaps-bot'\n          user_email: 'googlemaps-bot@users.noreply.github.com'\n          commit_message: ${{ github.event.head_commit.message }}\n"
  },
  {
    "path": ".github/workflows/e2e.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: e2e\non:\n  push:\n  schedule:\n    - cron: \"0 12 * * *\"\njobs:\n  chrome:\n    runs-on: ubuntu-latest\n    services:\n       hub:\n        image: selenium/standalone-chrome\n        volumes:\n          - ${{ github.workspace }}:${{ github.workspace }}\n        ports:\n          - 4444:4444\n    steps:\n      - uses: actions/checkout@v2\n      - run: npm i\n      - run: npm run test:e2e\n  firefox:\n    runs-on: ubuntu-latest\n    services:\n      hub:\n        image: selenium/standalone-firefox\n        volumes:\n          - ${{ github.workspace }}:${{ github.workspace }}\n        ports:\n          - 4444:4444\n    steps:\n      - uses: actions/checkout@v2\n      - run: npm i\n      - run: npm run test:e2e\n        env:\n          BROWSER: firefox\n"
  },
  {
    "path": ".github/workflows/package.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Package\non:\n  - push\n  - pull_request\njobs:\n  package:\n    runs-on: ubuntu-latest   \n    steps:\n      - uses: actions/checkout@v2\n      - run: npm i\n      - uses: jpoehnelt/verify-npm-files-action@main\n        with:\n          keys: |\n            types\n            main\n            module\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Release\non:\n  push:\n    branches:\n      - main\nconcurrency: release\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/setup-node@v3\n        with:\n          node-version: '16'\n      - name: Checkout\n        uses: actions/checkout@v3\n        with:\n          token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}\n      - uses: actions/cache@v2\n        with:\n          path: ~/.npm\n          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-node-\n      - name: Test\n        run: |\n          npm i\n          npm run lint\n          npm test\n      - name: Release\n        uses: cycjimmy/semantic-release-action@v3\n        with:\n          semantic_version: 19\n          extra_plugins: |\n            @semantic-release/commit-analyzer@^9\n            semantic-release-interval\n            @semantic-release/release-notes-generator@^10\n            @semantic-release/git\n            @semantic-release/github@^8\n            @semantic-release/npm@^9\n            @googlemaps/semantic-release-config\n            semantic-release-npm-deprecate\n        env:\n          GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}\n          NPM_TOKEN: ${{ secrets.NPM_WOMBAT_TOKEN }}\n          RUNNER_DEBUG: 1\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nname: Test\non: [push, pull_request]\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:      \n      - uses: actions/checkout@v2\n      - uses: actions/cache@v2\n        with:\n          path: ~/.npm\n          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-node-\n      - run: npm i\n      - run: npm run lint\n      - run: npm test\n      - uses: codecov/codecov-action@v1\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\ndist/\n.npmrc\n**/docs\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# TypeScript v1 declaration files\ntypings/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n.env.test\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n\n# next.js build output\n.next\n\n# nuxt.js build output\n.nuxt\n\n# gatsby files\n.cache/\npublic\n\n# vuepress build output\n.vuepress/dist\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm\n# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839\n\n# User-specific stuff\n.idea/**/workspace.xml\n.idea/**/tasks.xml\n.idea/**/usage.statistics.xml\n.idea/**/dictionaries\n.idea/**/shelf\n\n# Generated files\n.idea/**/contentModel.xml\n\n# Sensitive or high-churn files\n.idea/**/dataSources/\n.idea/**/dataSources.ids\n.idea/**/dataSources.local.xml\n.idea/**/sqlDataSources.xml\n.idea/**/dynamic.xml\n.idea/**/uiDesigner.xml\n.idea/**/dbnavigator.xml\n\n# Gradle\n.idea/**/gradle.xml\n.idea/**/libraries\n\n# Gradle and Maven with auto-import\n# When using Gradle or Maven with auto-import, you should exclude module files,\n# since they will be recreated, and may cause churn.  Uncomment if using\n# auto-import.\n# .idea/modules.xml\n# .idea/*.iml\n# .idea/modules\n# *.iml\n# *.ipr\n\n# CMake\ncmake-build-*/\n\n# Mongo Explorer plugin\n.idea/**/mongoSettings.xml\n\n# File-based project format\n*.iws\n\n# IntelliJ\nout/\n\n# mpeltonen/sbt-idea plugin\n.idea_modules/\n\n# JIRA plugin\natlassian-ide-plugin.xml\n\n# Cursive Clojure plugin\n.idea/replstate.xml\n\n# Crashlytics plugin (for Android Studio and IntelliJ)\ncom_crashlytics_export_strings.xml\ncrashlytics.properties\ncrashlytics-build.properties\nfabric.properties\n\n# Editor-based Rest Client\n.idea/httpRequests\n\n# Android studio 3.1+ serialized cache file\n.idea/caches/build_file_checksums.ser\n\n# General\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n\n# Thumbnails\n._*\n\n# Files that might appear in the root of a volume\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n.com.apple.timemachine.donotpresent\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n# Windows thumbnail cache files\nThumbs.db\nThumbs.db:encryptable\nehthumbs.db\nehthumbs_vista.db\n\n# Dump file\n*.stackdump\n\n# Folder config file\n[Dd]esktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msix\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n.vscode\n"
  },
  {
    "path": ".prettierrc",
    "content": "{ \"trailingComma\": \"es5\" }\n"
  },
  {
    "path": ".releaserc",
    "content": "extends: \"@googlemaps/semantic-release-config\"\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# How to become a contributor and submit your own code\n\n1.  Submit an issue describing your proposed change to the repo in question.\n1.  The repo owner will respond to your issue promptly.\n1.  Fork the desired repo, develop and test your code changes.\n1.  Ensure that your code adheres to the existing style in the code to which\n    you are contributing.\n1.  Ensure that your code has an appropriate set of tests which all pass.\n1.  Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling.\n1.  Submit a pull request.\n\n## Running the tests\n\n1.  Install dependencies:\n\n        npm i\n1.  Run lint\n\n        npm run lint\n        npm run format  # will fix some issues\n\n1.  Run the tests:\n\n        # Run unit tests.\n        npm test\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Google Maps ThreeJS Overlay View and Utilities\n\n[![npm](https://img.shields.io/npm/v/@googlemaps/three)](https://www.npmjs.com/package/@googlemaps/three)\n![Build](https://github.com/googlemaps/js-three/workflows/Test/badge.svg)\n![Release](https://github.com/googlemaps/js-three/workflows/Release/badge.svg)\n[![codecov](https://codecov.io/gh/googlemaps/js-three/branch/main/graph/badge.svg)](https://codecov.io/gh/googlemaps/js-three)\n![GitHub contributors](https://img.shields.io/github/contributors/googlemaps/js-three?color=green)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![](https://github.com/jpoehnelt/in-solidarity-bot/raw/main/static//badge-flat.png)](https://github.com/apps/in-solidarity)\n[![Discord](https://img.shields.io/discord/676948200904589322?color=6A7EC2&logo=discord&logoColor=ffffff)](https://discord.gg/jRteCzP)\n\n## Description\n\nAdd [three.js](https://threejs.org) objects to Google Maps Platform JS. The\nlibrary provides a `ThreeJSOverlayView` class extending `google.maps.WebGLOverlayView`\nand utility functions for converting geo-coordinates (latitude/longitude) to\nvectors in the coordinate system used by three.js.\n\n## Install\n\nAvailable via npm as the package [@googlemaps/three](https://www.npmjs.com/package/@googlemaps/three).\n\n```\nnpm i @googlemaps/three\n```\n\nAlternatively you can load the package directly to the html document using\nunpkg or other CDNs. In this case, make sure to load three.js before loading\nthis library:\n\n```\n<script src=\"https://unpkg.com/three/build/three.min.js\"></script>\n<script src=\"https://unpkg.com/@googlemaps/three/dist/index.min.js\"></script>\n```\n\nWhen adding via unpkg, the package can be accessed as\n`google.maps.plugins.three`. A version can be specified by using\n`https://unpkg.com/@googlemaps/three@VERSION/dist/...`.\n\nThe third option to use it is via ES-Module imports, similar to how the\nthree.js examples work. For this, you first need to specify an\n[importmap](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap)\n(example using unpkg.com, but it works the same way with any other CDN\nor self-hosted files):\n\n```html\n<script type=\"importmap\">\n  {\n    \"imports\": {\n      \"three\": \"https://unpkg.com/three/build/three.module.js\",\n      \"@googlemaps/three\": \"https://unpkg.com/@googlemaps/three/dist/index.esm.js\"\n    }\n  }\n</script>\n```\n\nIn order to support browsers that don't yet implement importmap, you can\nuse the [es-module-shims package](https://github.com/guybedford/es-module-shims).\n\nAfter that, you can use three.js and the ThreeJSOverlayView like you would when\nusing a bundler.\n\n```html\n<script type=\"module\">\n  import * as THREE from \"three\";\n  import { ThreeJSOverlayView } from \"@googlemaps/three\";\n\n  // ...\n</script>\n```\n\n## Documentation\n\nCheckout the reference [documentation](https://googlemaps.github.io/js-three/index.html).\n\n### Coordinates, Projection and Anchor-Points\n\nThe coordinate system within the three.js scene (so-called 'world\ncoordinates') is a right-handed coordinate system in z-up orientation.\nThe y-axis is pointing true north, and the x-axis is pointing east. The\nunits are meters. So the point `new Vector3(0, 50, 10)` is 10 meters\nabove ground and 50 meters east of the specified anchor point.\n\nThis anchor-point and orientation can be set in the constructor, or by using the\n`setAnchor()` and `setUpAxis()`-methods (be aware that all object-positions in\nyour scene depend on the anchor-point and orientation, so they have to be\nrecomputed when either of them is changed):\n\n```typescript\nimport { ThreeJSOverlayView } from \"@googlemaps/three\";\n\nconst overlay = new ThreeJSOverlayView({\n  anchor: { lat: 37.7793, lng: -122.4192, altitude: 0 },\n  upAxis: \"Y\",\n});\n\noverlay.setAnchor({ lat: 35.680432, lng: 139.769013, altitude: 0 });\noverlay.setUpAxis(\"Z\");\n// can also be specified as Vector3:\noverlay.setUpAxis(new Vector3(0, 0, 1));\n```\n\n> The default up-axis used in this library is the z-axis (+x is east\n> and +y is north), which is different from the y-up orientation normally\n> used in three.\n\nAll computations on the GPU related to the position use float32 numbers,\nwhich limits the possible precision to about 7 decimal digits. Because\nof this, we cannot use a global reference system and still have the\nprecision to show details in the meters to centimeters range.\n\nThis is where the anchor point is important. The anchor specifies the\ngeo-coordinates (lat/lng/altitude) where the origin of the world-space\ncoordinate system is, and you should always define it close to where the\nobjects are placed in the scene - unless of course you are only working with\nlarge-scale (city-sized) objects distributed globally.\n\nAnother reason why setting the anchor close to the objects in the scene\nis generally a good idea: In the mercator map-projection used in Google Maps,\nthe scaling of meters is only accurate in regions close to the equator. This\ncan be compensated for by applying a scale factor that depends on the\nlatitude of the anchor. This scale factor is factored into the coordinate\ncalculations in WebGlOverlayView based on the latitude of the anchor.\n\n#### Converting coordinates\n\nWhen you need more than just a single georeferenced object in your scene,\nyou need to compute the world-space position for those coordinates. The\nThreeJSOverlayView class provides a helper function for this conversion that\ntakes the current `anchor` and `upAxis` into account:\n\n```typescript\nconst coordinates = { lat: 12.34, lng: 56.78 };\nconst position: Vector3 = overlay.latLngAltitudeToVector3(coordinates);\n\n// alternative: pass the Vector3 to write the position\n// to as the second parameter, so to set the position of a mesh:\noverlay.latLngAltitudeToVector3(coordinates, mesh.position);\n```\n\n### Raycasting and Interactions\n\nIf you want to add interactivity to any three.js content, you typically\nhave to implement raycasting. We took care of that for you, and the\nThreeJSOverlayView provides a method `overlay.raycast()` for this. To make\nuse of it, you first have to keep track of mouse movements on the map:\n\n```js\nimport { Vector2 } from \"three\";\n\n// ...\n\nconst mapDiv = map.getDiv();\nconst mousePosition = new Vector2();\n\nmap.addListener(\"mousemove\", (ev) => {\n  const { domEvent } = ev;\n  const { left, top, width, height } = mapDiv.getBoundingClientRect();\n\n  const x = domEvent.clientX - left;\n  const y = domEvent.clientY - top;\n\n  mousePosition.x = 2 * (x / width) - 1;\n  mousePosition.y = 1 - 2 * (y / height);\n\n  // since the actual raycasting is performed when the next frame is\n  // rendered, we have to make sure that it will be called for the next frame.\n  overlay.requestRedraw();\n});\n```\n\nWith the mouse position being always up to date, you can then use the\n`raycast()` function in the `onBeforeDraw` callback.\nIn this example, we change the color of the object under the cursor:\n\n```js\nconst DEFAULT_COLOR = 0xffffff;\nconst HIGHLIGHT_COLOR = 0xff0000;\n\nlet highlightedObject = null;\n\noverlay.onBeforeDraw = () => {\n  const intersections = overlay.raycast(mousePosition);\n  if (highlightedObject) {\n    highlightedObject.material.color.setHex(DEFAULT_COLOR);\n  }\n\n  if (intersections.length === 0) return;\n\n  highlightedObject = intersections[0].object;\n  highlightedObject.material.color.setHex(HIGHLIGHT_COLOR);\n};\n```\n\nThe full examples can be found in [`./examples/raycasting.ts`](./examples/raycasting.ts).\n\n## Example\n\nThe following example provides a skeleton for adding objects to the map with this library.\n\n```js\nimport * as THREE from \"three\";\nimport { ThreeJSOverlayView, latLngToVector3 } from \"@googlemaps/three\";\n\n// when loading via UMD, remove the imports and use this instead:\n// const { ThreeJSOverlayView, latLngToVector3 } = google.maps.plugins.three;\n\nconst map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\nconst overlay = new ThreeJSOverlayView({\n  map,\n  upAxis: \"Y\",\n  anchor: mapOptions.center,\n});\n\n// create a box mesh\nconst box = new THREE.Mesh(\n  new THREE.BoxGeometry(10, 50, 10),\n  new THREE.MeshMatcapMaterial()\n);\n// move the box up so the origin of the box is at the bottom\nbox.geometry.translateY(25);\n\n// set position at center of map\nbox.position.copy(overlay.latLngAltitudeToVector3(mapOptions.center));\n\n// add box mesh to the scene\noverlay.scene.add(box);\n\n// rotate the box using requestAnimationFrame\nconst animate = () => {\n  box.rotateY(THREE.MathUtils.degToRad(0.1));\n\n  requestAnimationFrame(animate);\n};\n\n// start animation loop\nrequestAnimationFrame(animate);\n```\n\nThis adds a box to the map.\n\n<img src=\"https://storage.googleapis.com/geo-devrel-public-buckets/box.png\" alt=\"threejs box on map\" width=\"400\"/>\n\n## Demos\n\nView the package in action:\n\n- [Basic Example](https://googlemaps.github.io/js-three/public/basic/)\n- [Anchor Example](https://googlemaps.github.io/js-three/public/anchor/)\n- [Orientation Example](https://googlemaps.github.io/js-three/public/orientation/)\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Report a security issue\n\nTo report a security issue, please use https://g.co/vulnz. We use\nhttps://g.co/vulnz for our intake, and do coordination and disclosure here on\nGitHub (including using GitHub Security Advisory). The Google Security Team will\nrespond within 5 working days of your report on g.co/vulnz.\n\nTo contact us about other bugs, please open an issue on GitHub.\n\n> **Note**: This file is synchronized from the https://github.com/googlemaps/.github repository.\n"
  },
  {
    "path": "e2e/README.md",
    "content": ""
  },
  {
    "path": "examples/anchor.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LOADER_OPTIONS, MAP_ID } from \"./config\";\nimport { ThreeJSOverlayView, WORLD_SIZE } from \"../src\";\n\nimport { Loader } from \"@googlemaps/js-api-loader\";\nimport { AxesHelper } from \"three\";\n\nconst mapOptions = {\n  center: {\n    lat: 45,\n    lng: 0,\n  },\n  mapId: MAP_ID,\n  zoom: 5,\n  heading: -45,\n  tilt: 45,\n};\n\nnew Loader(LOADER_OPTIONS).load().then(() => {\n  const map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n  const overlay = new ThreeJSOverlayView({\n    anchor: { ...mapOptions.center, altitude: 0 },\n    map,\n  });\n\n  overlay.scene.add(new AxesHelper(WORLD_SIZE));\n});\n"
  },
  {
    "path": "examples/basic.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LOADER_OPTIONS, MAP_ID } from \"./config\";\nimport { ThreeJSOverlayView } from \"../src\";\n\nimport { Loader } from \"@googlemaps/js-api-loader\";\nimport { BoxGeometry, MathUtils, Mesh, MeshMatcapMaterial } from \"three\";\n\nconst mapOptions = {\n  center: {\n    lng: -122.343787,\n    lat: 47.607465,\n  },\n  mapId: MAP_ID,\n  zoom: 15,\n  heading: 45,\n  tilt: 67,\n};\n\nnew Loader(LOADER_OPTIONS).load().then(() => {\n  // create the map and ThreeJS Overlay\n  const map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n  const overlay = new ThreeJSOverlayView({ map });\n\n  // Create a box mesh\n  const box = new Mesh(\n    new BoxGeometry(100, 200, 500),\n    new MeshMatcapMaterial()\n  );\n\n  // set position at center of map\n  const pos = overlay.latLngAltitudeToVector3(mapOptions.center);\n  box.position.copy(pos);\n\n  // set position vertically\n  box.position.z = 25;\n\n  // add box mesh to the scene\n  overlay.scene.add(box);\n\n  // rotate the box using requestAnimationFrame\n  const animate = () => {\n    box.rotateZ(MathUtils.degToRad(0.1));\n\n    requestAnimationFrame(animate);\n  };\n\n  requestAnimationFrame(animate);\n});\n"
  },
  {
    "path": "examples/config.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LoaderOptions } from \"@googlemaps/js-api-loader\";\n\nexport const MAP_ID = \"7b9a897acd0a63a4\";\n\nexport const LOADER_OPTIONS: LoaderOptions = {\n  apiKey: \"AIzaSyD8xiaVPWB02OeQkJOenLiJzdeUHzlhu00\",\n  version: \"beta\",\n  libraries: [],\n};\n"
  },
  {
    "path": "examples/hemispheres.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LOADER_OPTIONS, MAP_ID } from \"./config\";\nimport { ThreeJSOverlayView } from \"../src\";\n\nimport { Loader } from \"@googlemaps/js-api-loader\";\nimport { BoxGeometry, Mesh, MeshMatcapMaterial } from \"three\";\n\nconst mapOptions = {\n  center: {\n    lng: 0,\n    lat: 0,\n  },\n  mapId: MAP_ID,\n  zoom: 4,\n  tilt: 67,\n};\n\nnew Loader(LOADER_OPTIONS).load().then(() => {\n  // create the map and overlay\n  const map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n  const overlay = new ThreeJSOverlayView({ map });\n\n  [\n    { lat: 45, lng: -90 },\n    { lat: 45, lng: 90 },\n    { lat: -45, lng: -90 },\n    { lat: -45, lng: 90 },\n  ].forEach((latLng: google.maps.LatLngLiteral) => {\n    // create a box mesh with origin on the ground, in z-up orientation\n    const geometry = new BoxGeometry(10, 50, 10)\n      .translate(0, 25, 0)\n      .rotateX(Math.PI / 2);\n\n    const box = new Mesh(geometry, new MeshMatcapMaterial());\n\n    // make it huge\n    box.scale.multiplyScalar(10000);\n\n    // set position at center of map\n    overlay.latLngAltitudeToVector3(latLng, box.position);\n\n    // add box mesh to the scene\n    overlay.scene.add(box);\n  });\n});\n"
  },
  {
    "path": "examples/orientation.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LOADER_OPTIONS, MAP_ID } from \"./config\";\nimport { ThreeJSOverlayView, WORLD_SIZE } from \"../src\";\n\nimport { Loader } from \"@googlemaps/js-api-loader\";\nimport { AxesHelper, Scene } from \"three\";\n\nconst mapOptions = {\n  center: {\n    lat: 0,\n    lng: 0,\n  },\n  mapId: MAP_ID,\n  zoom: 5,\n  heading: -45,\n  tilt: 45,\n};\n\nnew Loader(LOADER_OPTIONS).load().then(() => {\n  const map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n  const scene = new Scene();\n\n  scene.add(new AxesHelper(WORLD_SIZE));\n\n  new ThreeJSOverlayView({ scene, map });\n});\n"
  },
  {
    "path": "examples/raycasting.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LOADER_OPTIONS } from \"./config\";\nimport { ThreeJSOverlayView } from \"../src\";\n\nimport { Loader } from \"@googlemaps/js-api-loader\";\nimport {\n  AxesHelper,\n  CylinderGeometry,\n  GridHelper,\n  MathUtils,\n  Mesh,\n  MeshMatcapMaterial,\n  Vector2,\n} from \"three\";\n\n// the corners of the field in the Levi’s Stadium in Santa Clara\nconst coordinates = [\n  { lng: -121.9702904, lat: 37.4034362 },\n  { lng: -121.9698018, lat: 37.4027095 },\n  { lng: -121.9693109, lat: 37.402918 },\n  { lng: -121.969804, lat: 37.4036465 },\n];\nconst center = { lng: -121.9698032, lat: 37.4031777, altitude: 0 };\n\nconst DEFAULT_COLOR = 0xffffff;\nconst HIGHLIGHT_COLOR = 0xff0000;\n\nconst mapOptions = {\n  center,\n  mapId: \"7057886e21226ff7\",\n  zoom: 18,\n  tilt: 67.5,\n  disableDefaultUI: true,\n  backgroundColor: \"transparent\",\n  gestureHandling: \"greedy\",\n};\n\nnew Loader(LOADER_OPTIONS).load().then(() => {\n  // create the map and overlay\n  const map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n  const overlay = new ThreeJSOverlayView({ map, anchor: center, upAxis: \"Y\" });\n\n  const mapDiv = map.getDiv();\n  const mousePosition = new Vector2();\n\n  map.addListener(\"mousemove\", (ev: google.maps.MapMouseEvent) => {\n    const domEvent = ev.domEvent as MouseEvent;\n    const { left, top, width, height } = mapDiv.getBoundingClientRect();\n\n    const x = domEvent.clientX - left;\n    const y = domEvent.clientY - top;\n\n    mousePosition.x = 2 * (x / width) - 1;\n    mousePosition.y = 1 - 2 * (y / height);\n\n    // since the actual raycasting is performed when the next frame is\n    // rendered, we have to make sure that it will be called for the next frame.\n    overlay.requestRedraw();\n  });\n\n  // grid- and axes helpers to help with the orientation\n  const grid = new GridHelper(1);\n\n  grid.rotation.y = MathUtils.degToRad(28.1);\n  grid.scale.set(48.8, 0, 91.44);\n  overlay.scene.add(grid);\n  overlay.scene.add(new AxesHelper(20));\n\n  const meshes = coordinates.map((p) => {\n    const mesh = new Mesh(\n      new CylinderGeometry(2, 1, 20, 24, 1),\n      new MeshMatcapMaterial()\n    );\n    mesh.geometry.translate(0, mesh.geometry.parameters.height / 2, 0);\n    overlay.latLngAltitudeToVector3(p, mesh.position);\n\n    overlay.scene.add(mesh);\n\n    return mesh;\n  });\n\n  let highlightedObject: (typeof meshes)[number] | null = null;\n\n  overlay.onBeforeDraw = () => {\n    const intersections = overlay.raycast(mousePosition, meshes, {\n      recursive: false,\n    });\n\n    if (highlightedObject) {\n      // when there's a previously highlighted object, reset the highlighting\n      highlightedObject.material.color.setHex(DEFAULT_COLOR);\n    }\n\n    if (intersections.length === 0) {\n      // reset default cursor when no object is under the cursor\n      map.setOptions({ draggableCursor: null });\n      highlightedObject = null;\n      return;\n    }\n\n    // change the color of the object and update the map-cursor to indicate\n    // the object is clickable.\n    highlightedObject = intersections[0].object;\n    highlightedObject.material.color.setHex(HIGHLIGHT_COLOR);\n    map.setOptions({ draggableCursor: \"pointer\" });\n  };\n});\n"
  },
  {
    "path": "jest.config.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport default {\n  roots: [\"<rootDir>/src\"],\n  preset: \"ts-jest\",\n  testPathIgnorePatterns: [\"/dist/\", \"/__utils__/\"],\n  testEnvironment: \"jsdom\",\n  setupFilesAfterEnv: [\"jest-extended/all\"],\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@googlemaps/three\",\n  \"version\": \"4.0.18\",\n  \"type\": \"module\",\n  \"keywords\": [\n    \"google\",\n    \"maps\",\n    \"webgl\",\n    \"threejs\"\n  ],\n  \"homepage\": \"https://github.com/googlemaps/js-three\",\n  \"bugs\": {\n    \"url\": \"https://github.com/googlemaps/js-three/issues\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/googlemaps/js-three.git\"\n  },\n  \"license\": \"Apache-2.0\",\n  \"author\": \"Justin Poehnelt\",\n  \"source\": \"src/index.ts\",\n  \"main\": \"dist/index.umd.js\",\n  \"exports\": {\n    \".\": {\n      \"import\": {\n        \"types\": \"./dist/index.d.ts\",\n        \"default\": \"./dist/index.esm.js\"\n      },\n      \"require\": \"./dist/index.umd.js\",\n      \"umd\": \"./dist/index.umd.js\",\n      \"browser\": \"./dist/index.esm.js\"\n    }\n  },\n  \"unpkg\": \"dist/index.min.js\",\n  \"module\": \"dist/index.esm.js\",\n  \"types\": \"dist/index.d.ts\",\n  \"files\": [\n    \"/src\",\n    \"/dist\"\n  ],\n  \"scripts\": {\n    \"build:examples\": \"rm -rf public && rollup -c rollup.config.examples.js\",\n    \"docs\": \"typedoc src/index.ts && npm run build:examples && cp -r dist docs/dist && cp -r public docs/public\",\n    \"format\": \"eslint . --fix\",\n    \"lint\": \"eslint .\",\n    \"prepare\": \"rm -rf dist && rollup -c\",\n    \"start\": \"run-p start:*\",\n    \"start:rollup\": \"rollup -c rollup.config.examples.js -w --no-watch.clearScreen\",\n    \"start:server\": \"http-server ./public\",\n    \"test\": \"jest --coverage=true src/*\",\n    \"test:e2e\": \"jest --passWithNoTests e2e/*\"\n  },\n  \"peerDependencies\": {\n    \"three\": \"*\"\n  },\n  \"devDependencies\": {\n    \"@babel/preset-env\": \"^7.25.7\",\n    \"@babel/preset-modules\": \"^0.1.6\",\n    \"@babel/runtime-corejs3\": \"^7.25.7\",\n    \"@googlemaps/jest-mocks\": \"^2.21.4\",\n    \"@googlemaps/js-api-loader\": \"^1.16.8\",\n    \"@rollup/plugin-babel\": \"^6.0.4\",\n    \"@rollup/plugin-commonjs\": \"^26.0.1\",\n    \"@rollup/plugin-html\": \"^1.0.3\",\n    \"@rollup/plugin-json\": \"^6.1.0\",\n    \"@rollup/plugin-node-resolve\": \"^15.2.4\",\n    \"@rollup/plugin-terser\": \"^0.4.4\",\n    \"@rollup/plugin-typescript\": \"^11.1.6\",\n    \"@types/d3-random\": \"^3.0.3\",\n    \"@types/google.maps\": \"^3.58.1\",\n    \"@types/jest\": \"^29.5.14\",\n    \"@types/proj4\": \"^2.5.5\",\n    \"@types/selenium-webdriver\": \"^4.1.25\",\n    \"@types/stats.js\": \"^0.17.3\",\n    \"@types/three\": \"^0.156.0\",\n    \"@typescript-eslint/eslint-plugin\": \"^7.0.0\",\n    \"@typescript-eslint/parser\": \"^6.19.1\",\n    \"core-js\": \"^3.37.1\",\n    \"d3-random\": \"^3.0.1\",\n    \"eslint\": \"^8.57.0\",\n    \"eslint-config-prettier\": \"^9.1.0\",\n    \"eslint-plugin-jest\": \"^28.9.0\",\n    \"eslint-plugin-prettier\": \"^5.1.3\",\n    \"geckodriver\": \"^5.0.0\",\n    \"http-server\": \"^14.1.1\",\n    \"jest\": \"^29.7.0\",\n    \"jest-environment-jsdom\": \"^29.7.0\",\n    \"jest-extended\": \"^4.0.2\",\n    \"jest-webgl-canvas-mock\": \"^2.5.3\",\n    \"npm-run-all\": \"^4.1.5\",\n    \"prettier\": \"^3.3.3\",\n    \"rollup\": \"^4.22.4\",\n    \"selenium-webdriver\": \"^4.23.0\",\n    \"three\": \"^0.161.0\",\n    \"ts-jest\": \"^29.2.5\",\n    \"typedoc\": \"^0.25.13\",\n    \"typescript\": \"^5.4.5\"\n  },\n  \"publishConfig\": {\n    \"access\": \"public\",\n    \"registry\": \"https://wombat-dressing-room.appspot.com\"\n  }\n}"
  },
  {
    "path": "rollup.config.examples.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport * as url from \"node:url\";\n\nimport html, { makeHtmlAttributes } from \"@rollup/plugin-html\";\n\nimport commonjs from \"@rollup/plugin-commonjs\";\n\nimport jsonNodeResolve from \"@rollup/plugin-json\";\nimport { nodeResolve } from \"@rollup/plugin-node-resolve\";\n\nimport typescript from \"@rollup/plugin-typescript\";\n\nconst template = ({ attributes, files, meta, publicPath, title }) => {\n  const scripts = (files.js || [])\n    .map(({ fileName }) => {\n      const attrs = makeHtmlAttributes(attributes.script);\n      return `<script src=\"${publicPath}${fileName}\"${attrs}></script>`;\n    })\n    .join(\"\\n\");\n\n  const links = (files.css || [])\n    .map(({ fileName }) => {\n      const attrs = makeHtmlAttributes(attributes.link);\n      return `<link href=\"${publicPath}${fileName}\" rel=\"stylesheet\"${attrs}>`;\n    })\n    .join(\"\\n\");\n\n  const metas = meta\n    .map((input) => {\n      const attrs = makeHtmlAttributes(input);\n      return `<meta${attrs}>`;\n    })\n    .join(\"\\n\");\n\n  return `\n<!doctype html>\n<html${makeHtmlAttributes(attributes.html)}>\n  <head>\n    ${metas}\n    <title>${title}</title>\n    <style>\n      #map, html, body {\n        height: 100%;\n        width: 100%;\n        margin: 0;\n      }\n    </style>\n    ${links}\n  </head>\n  <body>\n    <div id=\"map\"></div>\n    ${scripts}\n  </body>\n</html>`;\n};\n\nconst typescriptOptions = {\n  tsconfig: \"tsconfig.examples.json\",\n  compilerOptions: {\n    sourceMap: true,\n    inlineSources: true,\n  },\n};\n\nconst dirname = url.fileURLToPath(new URL(\".\", import.meta.url));\nconst examples = fs\n  .readdirSync(path.join(dirname, \"examples\"))\n  .filter((f) => f !== \"config.ts\")\n  .map((f) => f.slice(0, f.length - 3));\n\nexport default examples.map((name) => ({\n  input: `examples/${name}.ts`,\n\n  plugins: [\n    typescript(typescriptOptions),\n    commonjs(),\n    nodeResolve(),\n    jsonNodeResolve(),\n  ],\n  output: {\n    dir: `public/${name}`,\n    sourcemap: \"inline\",\n    plugins: [\n      html({\n        fileName: `index.html`,\n        title: `@googlemaps/three: ${name}`,\n        template,\n      }),\n    ],\n    manualChunks: (id) => {\n      if (id.includes(\"node_modules\")) {\n        return \"vendor\";\n      }\n    },\n  },\n}));\n"
  },
  {
    "path": "rollup.config.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { babel } from \"@rollup/plugin-babel\";\nimport commonjs from \"@rollup/plugin-commonjs\";\nimport terser from \"@rollup/plugin-terser\";\nimport typescript from \"@rollup/plugin-typescript\";\nimport { nodeResolve } from \"@rollup/plugin-node-resolve\";\n\nconst babelOptions = {\n  extensions: [\".js\", \".ts\"],\n  babelHelpers: \"bundled\",\n};\n\nconst terserOptions = { output: { comments: \"some\" } };\n\nexport default [\n  {\n    input: \"src/index.ts\",\n    plugins: [\n      typescript({ tsconfig: \"./tsconfig.json\", declarationDir: \"./\" }),\n\n      commonjs(),\n      babel(babelOptions),\n      nodeResolve(),\n      terser(terserOptions),\n    ],\n    external: [\"three\"],\n    output: [\n      {\n        file: \"dist/index.umd.js\",\n        format: \"umd\",\n        sourcemap: true,\n        name: \"google.maps.plugins.three\",\n        globals: {\n          three: \"THREE\",\n        },\n      },\n      {\n        file: \"dist/index.min.js\",\n        format: \"iife\",\n        sourcemap: true,\n        name: \"google.maps.plugins.three\",\n        globals: {\n          three: \"THREE\",\n        },\n      },\n    ],\n  },\n  {\n    input: \"src/index.ts\",\n    plugins: [\n      typescript({ tsconfig: \"./tsconfig.json\", declarationDir: \"./\" }),\n\n      commonjs(),\n      babel(babelOptions),\n      nodeResolve(),\n      terser(terserOptions),\n    ],\n    external: [\"three\"],\n    output: {\n      file: \"dist/index.dev.js\",\n      format: \"iife\",\n      sourcemap: true,\n      name: \"google.maps.plugins.three\",\n      globals: {\n        three: \"THREE\",\n      },\n    },\n  },\n  {\n    input: \"src/index.ts\",\n    external: [\"three\"],\n    plugins: [\n      typescript({ tsconfig: \"./tsconfig.json\", declarationDir: \"./\" }),\n      babel({\n        presets: [\"@babel/preset-modules\"],\n        babelrc: false,\n        extensions: [\".js\", \".ts\"],\n        babelHelpers: \"bundled\",\n      }),\n      terser(terserOptions),\n    ],\n    output: {\n      file: \"dist/index.esm.js\",\n      sourcemap: true,\n      format: \"esm\",\n    },\n  },\n];\n"
  },
  {
    "path": "src/__tests__/__utils__/createWebGlContext.ts",
    "content": "/**\n * Copyright 2021 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// using 'jest-webgl-canvas-mock' as intended as a setup-script in the jest\n// configuration causes an error 'TypeError: Cannot redefine property: window'\n// in newer node-version (last known working version is 18.13.0), which is why\n// we do the initialization manually here.\n// @ts-ignore\nimport registerWebglMock from \"jest-webgl-canvas-mock/lib/window.js\";\n\n/**\n * Creates a mocked WebGL 1.0 context (based on the one provided by\n * the jest-webgl-canvas-mock package) three.js can work with.\n */\nexport function createWebGlContext() {\n  registerWebglMock(window);\n\n  const gl = new WebGLRenderingContext();\n  const glParameters: Record<number, unknown> = {\n    [gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: 8,\n    [gl.VERSION]: \"WebGL 1.0 (OpenGL ES 2.0 Chromium)\",\n    [gl.SCISSOR_BOX]: [0, 0, 100, 100],\n    [gl.VIEWPORT]: [0, 0, 100, 100],\n  };\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const glExtensions: Record<string, any> = {\n    EXT_blend_minmax: {},\n  };\n\n  jest.spyOn(gl, \"getContextAttributes\").mockReturnValue({});\n  jest.spyOn(gl, \"getParameter\").mockImplementation((key) => glParameters[key]);\n  jest.spyOn(gl, \"getShaderPrecisionFormat\").mockImplementation(() => ({\n    rangeMin: 127,\n    rangeMax: 127,\n    precision: 23,\n  }));\n\n  const getExtensionOrig = gl.getExtension;\n  jest.spyOn(gl, \"getExtension\").mockImplementation((id) => {\n    return glExtensions[id] || getExtensionOrig(id);\n  });\n\n  const canvas = document.createElement(\"canvas\");\n  canvas.width = 200;\n  canvas.height = 100;\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  (gl as any).canvas = canvas;\n\n  return gl;\n}\n"
  },
  {
    "path": "src/__tests__/three.test.ts",
    "content": "/**\n * Copyright 2021 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n\n// prevent \"WARNING: Multiple instances of Three.js being imported.” when\n// importing three.js\nObject.defineProperty(window, \"__THREE__\", {\n  get: () => null,\n  set: () => null,\n  configurable: false,\n});\n\nimport { ThreeJSOverlayView, ThreeJSOverlayViewOptions } from \"../three\";\nimport * as util from \"../util\";\n\nimport {\n  BoxGeometry,\n  Camera,\n  Group,\n  Light,\n  Matrix4,\n  Mesh,\n  Object3D,\n  PerspectiveCamera,\n  RaycasterParameters,\n  Scene,\n  Vector2,\n  Vector3,\n  Vector4,\n  WebGLRenderer,\n} from \"three\";\n\nimport \"jest-extended\";\nimport { initialize, Map } from \"@googlemaps/jest-mocks\";\nimport { createWebGlContext } from \"./__utils__/createWebGlContext\";\n\n// setup mocked dependencies\njest.mock(\"../util\");\n\nbeforeEach(() => {\n  initialize();\n  google.maps.WebGLOverlayView = jest.fn().mockImplementation(() => {\n    return new (class extends google.maps.MVCObject {\n      getMap = jest.fn();\n      setMap = jest.fn();\n      requestRedraw = jest.fn();\n      requestStateUpdate = jest.fn();\n      addListener = jest.fn().mockImplementation(() => {\n        return { remove: jest.fn() } as google.maps.MapsEventListener;\n      });\n    })();\n  });\n});\n\nafterEach(() => {\n  jest.restoreAllMocks();\n});\n\ndescribe(\"basic functions\", () => {\n  test(\"instantiates with defaults\", () => {\n    const overlay = new ThreeJSOverlayView();\n\n    expect(overlay[\"overlay\"]).toBeDefined();\n    expect(overlay[\"camera\"]).toBeInstanceOf(PerspectiveCamera);\n\n    expect(overlay.scene).toBeInstanceOf(Scene);\n\n    // required hooks must be defined\n    expect(overlay[\"overlay\"].onAdd).toBeDefined();\n    expect(overlay[\"overlay\"].onRemove).toBeDefined();\n    expect(overlay[\"overlay\"].onContextLost).toBeDefined();\n    expect(overlay[\"overlay\"].onContextRestored).toBeDefined();\n    expect(overlay[\"overlay\"].onDraw).toBeDefined();\n  });\n\n  test(\"instantiates with map and calls setMap\", () => {\n    const map = new Map(\n      document.createElement(\"div\"),\n      {}\n    ) as unknown as google.maps.Map;\n\n    const overlay = new ThreeJSOverlayView({\n      map,\n    });\n\n    expect(overlay[\"overlay\"].setMap).toHaveBeenCalledWith(map);\n  });\n\n  test(\"setMap is called on overlay\", () => {\n    const map = new Map(\n      document.createElement(\"div\"),\n      {}\n    ) as unknown as google.maps.Map;\n    const overlay = new ThreeJSOverlayView();\n    overlay.setMap(map);\n\n    expect(overlay[\"overlay\"].setMap).toHaveBeenCalledWith(map);\n  });\n\n  test(\"getMap is called on overlay\", () => {\n    const overlay = new ThreeJSOverlayView();\n    overlay.getMap();\n\n    expect(overlay[\"overlay\"].getMap).toHaveBeenCalledWith();\n  });\n\n  test(\"addListener is called on overlay\", () => {\n    const overlay = new ThreeJSOverlayView();\n    const handler = jest.fn();\n    const eventName = \"foo\";\n\n    expect(overlay.addListener(eventName, handler)).toBeDefined();\n    expect(overlay[\"overlay\"].addListener).toHaveBeenCalledWith(\n      eventName,\n      handler\n    );\n  });\n});\n\ndescribe(\"MVCObject interface\", () => {\n  let overlay: ThreeJSOverlayView;\n  let webglOverlay: google.maps.WebGLOverlayView;\n\n  beforeEach(() => {\n    overlay = new ThreeJSOverlayView();\n    webglOverlay = overlay[\"overlay\"];\n  });\n\n  test.each([\n    [\"bindTo\", \"eventName\", () => void 0, \"targetKey\", true],\n    [\"get\", \"key\"],\n    [\"notify\", \"key\"],\n    [\"set\", \"key\", \"value\"],\n    [\"setValues\", { key: \"value\" }],\n    [\"unbind\", \"key\"],\n    [\"unbindAll\"],\n  ] as const)(\n    \"method '%s' is forwarded to overlay\",\n    (method: keyof google.maps.MVCObject, ...args) => {\n      overlay[method].call(overlay, ...args);\n      expect(webglOverlay[method]).toHaveBeenCalledWith(...args);\n    }\n  );\n});\n\ndescribe(\"WebGLOverlayView interface\", () => {\n  let overlay: ThreeJSOverlayView;\n  let gl: WebGLRenderingContext;\n  let transformer: google.maps.CoordinateTransformer;\n  const projMatrixArray = new Float64Array([\n    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n  ]);\n\n  beforeEach(() => {\n    overlay = new ThreeJSOverlayView();\n    gl = createWebGlContext();\n\n    transformer = {\n      fromLatLngAltitude: jest.fn(() => projMatrixArray),\n      getCameraParams: jest.fn(),\n    };\n  });\n\n  test(\"onContextRestored creates the renderer\", () => {\n    overlay.onContextRestored({ gl });\n    const renderer: WebGLRenderer = overlay[\"renderer\"];\n    expect(renderer).toBeDefined();\n\n    const viewport = renderer.getViewport(new Vector4());\n    expect(viewport.x).toEqual(0);\n    expect(viewport.y).toEqual(0);\n    expect(viewport.width).toEqual(gl.canvas.width);\n    expect(viewport.height).toEqual(gl.canvas.height);\n  });\n\n  test(\"onDraw renders the scene and resets the state\", () => {\n    overlay.onContextRestored({ gl });\n    const renderer: WebGLRenderer = overlay[\"renderer\"];\n    let scene: Object3D, camera: Camera;\n    const renderSpy = jest\n      .spyOn(renderer, \"render\")\n      .mockImplementation((s, c) => {\n        scene = s;\n        camera = c;\n      });\n    const resetStateSpy = jest.spyOn(renderer, \"resetState\");\n\n    overlay.onDraw({ gl, transformer });\n\n    expect(renderSpy).toHaveBeenCalled();\n    expect(scene).toBe(overlay.scene);\n    expect(camera.projectionMatrix).toEqual(\n      new Matrix4().fromArray(projMatrixArray)\n    );\n    expect(resetStateSpy).toHaveBeenCalledAfter(renderSpy);\n  });\n\n  test(\"onBeforeDraw gets called before render\", () => {\n    overlay.onContextRestored({ gl });\n    const renderer: WebGLRenderer = overlay[\"renderer\"];\n    const renderSpy = jest\n      .spyOn(renderer, \"render\")\n      .mockImplementation(() => void 0);\n\n    overlay.onBeforeDraw = jest.fn();\n    overlay.onDraw({\n      gl,\n      transformer,\n    });\n\n    expect(overlay.onBeforeDraw).toHaveBeenCalled();\n    expect(overlay.onBeforeDraw).toHaveBeenCalledBefore(renderSpy);\n  });\n\n  test(\"onContextLost disposes of renderer\", () => {\n    overlay.onContextRestored({ gl });\n\n    const renderer: WebGLRenderer = overlay[\"renderer\"];\n    const disposeSpy = jest.spyOn(renderer, \"dispose\");\n    overlay.onContextLost();\n\n    expect(disposeSpy).toHaveBeenCalled();\n    expect(overlay[\"renderer\"]).toBeNull();\n  });\n\n  test(\"requestRedraw is forwarded to overlay\", () => {\n    overlay.requestRedraw();\n\n    expect(overlay[\"overlay\"].requestRedraw).toHaveBeenCalledWith();\n  });\n\n  test(\"requestStateUpdate is forwarded to overlay\", () => {\n    overlay.requestStateUpdate();\n\n    expect(overlay[\"overlay\"].requestStateUpdate).toHaveBeenCalledWith();\n  });\n});\n\ndescribe(\"setUpAxis() / scene orientation\", () => {\n  const latLngAlt = { lat: 0, lng: 0, altitude: 10 };\n\n  beforeEach(() => {\n    const mockedUtil = util as jest.Mocked<typeof util>;\n    mockedUtil.latLngToVector3Relative.mockImplementation(\n      (p, r, target = new Vector3()) => {\n        return target.set(1, 2, 3);\n      }\n    );\n  });\n\n  test.each([\n    [undefined, { x: 1, y: 2, z: 3 }],\n    [\"Z\", { x: 1, y: 2, z: 3 }],\n    [\"Y\", { x: 1, y: 3, z: -2 }],\n    [new Vector3(1, 0, 0), { x: 3, y: 2, z: -1 }],\n  ])(\"upAxis: %s\", (upAxis, expectedCoords) => {\n    const overlay = new ThreeJSOverlayView({\n      upAxis: upAxis as ThreeJSOverlayViewOptions[\"upAxis\"],\n    });\n\n    const v3 = overlay.latLngAltitudeToVector3(latLngAlt);\n    expect(v3.x).toBeCloseTo(expectedCoords.x, 8);\n    expect(v3.y).toBeCloseTo(expectedCoords.y, 8);\n    expect(v3.z).toBeCloseTo(expectedCoords.z, 8);\n  });\n\n  test(\"error for invalid upAxis values\", () => {\n    const mock = jest.spyOn(console, \"warn\").mockImplementation(() => void 0);\n    const overlay = new ThreeJSOverlayView({\n      upAxis: \"a\" as ThreeJSOverlayViewOptions[\"upAxis\"],\n    });\n\n    expect(mock).toHaveBeenCalled();\n\n    // check that the default z-up is used\n    const v3 = overlay.latLngAltitudeToVector3(latLngAlt);\n\n    expect(v3.x).toBeCloseTo(1, 8);\n    expect(v3.y).toBeCloseTo(2, 8);\n    expect(v3.z).toBeCloseTo(3, 8);\n  });\n});\n\ndescribe(\"latLngAltitudeToVector3()\", () => {\n  let mockedUtil: jest.Mocked<typeof util>;\n  beforeEach(() => {\n    mockedUtil = jest.mocked(util);\n    const { latLngToVector3Relative } = mockedUtil;\n\n    latLngToVector3Relative.mockImplementation(\n      (p, r, target = new Vector3()) => {\n        return target.set(1, 2, 3);\n      }\n    );\n  });\n\n  test(\"calls util-functions\", () => {\n    const overlay = new ThreeJSOverlayView({\n      anchor: { lat: 5, lng: 6, altitude: 7 },\n    });\n    const p = { lat: 0, lng: 0, altitude: 0 };\n    const v3 = overlay.latLngAltitudeToVector3(p);\n\n    expect(mockedUtil.latLngToVector3Relative).toHaveBeenCalled();\n    expect(v3).toEqual(new Vector3(1, 2, 3));\n  });\n\n  test(\"writes value to target parameter\", () => {\n    const overlay = new ThreeJSOverlayView({\n      anchor: { lat: 5, lng: 6, altitude: 7 },\n    });\n    const p = { lat: 0, lng: 0, altitude: 0 };\n    const t = new Vector3();\n    const v3 = overlay.latLngAltitudeToVector3(p, t);\n\n    expect(mockedUtil.latLngToVector3Relative).toHaveBeenCalled();\n    expect(v3).toBe(t);\n    expect(t).toEqual(new Vector3(1, 2, 3));\n  });\n});\n\ndescribe(\"addDefaultLighting()\", () => {\n  test(\"lights are added to the default scene\", () => {\n    const overlay = new ThreeJSOverlayView();\n\n    const lights: Light[] = [];\n    overlay.scene.traverse((o) => {\n      if ((o as Light).isLight) lights.push(o as Light);\n    });\n\n    expect(lights).not.toHaveLength(0);\n  });\n\n  test(\"addDefaultLighting:false\", () => {\n    const overlay = new ThreeJSOverlayView({ addDefaultLighting: false });\n\n    const lights: Light[] = [];\n    overlay.scene.traverse((o) => {\n      if ((o as Light).isLight) lights.push(o as Light);\n    });\n\n    expect(lights).toHaveLength(0);\n  });\n});\n\ndescribe(\"raycast()\", () => {\n  let overlay: ThreeJSOverlayView;\n  let camera: PerspectiveCamera;\n  let box: Mesh<BoxGeometry, never>;\n\n  // these values were taken from a running application and are known to work\n  const projMatrix = [\n    0.024288994132302996, -0.0001544860884193919, -0.00004410021260124961,\n    -0.00004410021260124961, 6.275603421503094e-20, 0.017096574772793482,\n    -0.002943529080808796, -0.002943529080808796, -0.00028262805230606344,\n    -0.01327650198026164, -0.0037899629741724055, -0.0037899629741724055,\n    -0.10144748239547549, 0.2775102128618734, 0.4125525158446316,\n    1.079219172577191,\n  ];\n  const boxPosition = new Vector3(0.12366377626911729, 0, 52.06138372088319);\n  const mouseHitPosition = new Vector2(-0.131, -0.464);\n\n  beforeEach(() => {\n    overlay = new ThreeJSOverlayView();\n\n    // this could be done by providing a mocked CoordinateTransformer\n    // to the onDraw function, but this is arguably easier (although\n    // it's not ideal to access protected members)\n    camera = overlay[\"camera\"];\n    camera.projectionMatrix.fromArray(projMatrix);\n\n    box = new Mesh(new BoxGeometry());\n    box.position.copy(boxPosition);\n  });\n\n  test(\"returns an empty array for an empty scene\", () => {\n    const res = overlay.raycast(new Vector2(0, 0));\n    expect(res).toEqual([]);\n  });\n\n  test(\"returns correct results in a known to work setting\", () => {\n    overlay.scene.add(box);\n    box.updateMatrixWorld(true);\n\n    // check for no hit at [0,0]\n    expect(overlay.raycast(new Vector2(0, 0))).toEqual([]);\n\n    let res;\n\n    // we know where the box would be rendered\n    res = overlay.raycast(mouseHitPosition);\n    expect(res).toHaveLength(1);\n    expect(res[0].object).toBe(box);\n\n    // check that it ignores {recursive:false} here and returns the same result\n    const res2 = overlay.raycast(mouseHitPosition, { recursive: false });\n    expect(res2).toEqual(res);\n\n    // test calls with explicit object-list\n    res = overlay.raycast(mouseHitPosition, [box], { recursive: false });\n    expect(res).toEqual(res);\n\n    const box2 = new Mesh(new BoxGeometry());\n    res = overlay.raycast(mouseHitPosition, [box2]);\n    expect(res).toEqual([]);\n\n    // test recursion\n    const g = new Group();\n    g.add(box);\n    res = overlay.raycast(mouseHitPosition, [g], { recursive: false });\n    expect(res).toEqual([]);\n  });\n\n  test(\"sets and restores raycaster parameters\", () => {\n    const raycaster = overlay[\"raycaster\"];\n\n    const origParams = {} as unknown as RaycasterParameters;\n    const customParams = {} as unknown as RaycasterParameters;\n\n    let currParams = origParams;\n    let intersectParams = null;\n\n    const setParamsMock = jest.fn((v) => (currParams = v));\n    const getParamsMock = jest.fn(() => origParams);\n\n    jest.spyOn(raycaster, \"intersectObjects\").mockImplementation(() => {\n      intersectParams = currParams;\n      return [];\n    });\n\n    Object.defineProperty(raycaster, \"params\", {\n      get: getParamsMock,\n      set: setParamsMock,\n    });\n\n    overlay.scene.add(box);\n    box.updateMatrixWorld(true);\n\n    overlay.raycast(mouseHitPosition, { raycasterParameters: customParams });\n\n    expect(setParamsMock).toHaveBeenCalledTimes(2);\n\n    const [[arg1], [arg2]] = setParamsMock.mock.calls;\n    expect(arg1).toBe(customParams);\n    expect(arg2).toBe(origParams);\n    expect(intersectParams).toBe(customParams);\n  });\n});\n"
  },
  {
    "path": "src/__tests__/util.test.ts",
    "content": "/**\n * Copyright 2021 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { initialize } from \"@googlemaps/jest-mocks\";\nimport {\n  latLngToXY,\n  latLngToVector3Relative,\n  toLatLngAltitudeLiteral,\n  xyToLatLng,\n} from \"../util\";\n\nbeforeEach(() => {\n  initialize();\n});\n\ndescribe(\"toLatLngAltitudeLiteral()\", () => {\n  test.each([\n    [\"LatLngLiteral\", { lat: 10, lng: 20 }, { lat: 10, lng: 20, altitude: 0 }],\n    [\n      \"LatLngAltitudeLiteral\",\n      { lat: 10, lng: 20, altitude: 30 },\n      { lat: 10, lng: 20, altitude: 30 },\n    ],\n    [\"LatLng\", { lat: 10, lng: 20 }, { lat: 10, lng: 20, altitude: 0 }],\n    [\n      \"LatLngAltitude\",\n      { lat: 10, lng: 20, altitude: 30 },\n      { lat: 10, lng: 20, altitude: 30 },\n    ],\n  ] as const)(\"toLatLngAltitudeLiteral: %p\", (type, json, output) => {\n    let input: Parameters<typeof toLatLngAltitudeLiteral>[0] = json;\n\n    if (type === \"LatLng\" || type === \"LatLngAltitude\") {\n      input = new google.maps[type]({ lat: 0, lng: 0 });\n      (input as google.maps.LatLng).toJSON = jest.fn(() => json);\n    }\n\n    expect(toLatLngAltitudeLiteral(input)).toEqual(output);\n  });\n});\n\ntest.each([\n  [\n    { lng: 0, lat: 0 },\n    { x: 0, y: 0 },\n  ],\n  [\n    { lng: -90, lat: 45 },\n    { x: -10007559.105973555, y: 5615239.936637378 },\n  ],\n  [\n    { lng: 90, lat: -45 },\n    { x: 10007559.105973555, y: -5615239.936637378 },\n  ],\n  [\n    { lng: 90, lat: 45 },\n    { x: 10007559.105973555, y: 5615239.936637378 },\n  ],\n  [\n    { lng: -90, lat: -45 },\n    { x: -10007559.105973555, y: -5615239.936637378 },\n  ],\n  [\n    { lng: 151.2093, lat: -33.8688 },\n    { x: 16813733.4125, y: -4006716.49009 },\n  ],\n])(\n  \"latLngToXY and xyToLatLng are correct for %p\",\n  (latLng: google.maps.LatLngLiteral, expected: { x: number; y: number }) => {\n    const [x, y] = latLngToXY(latLng);\n    expect(x).toBeCloseTo(expected.x);\n    expect(y).toBeCloseTo(expected.y);\n\n    const { lat, lng } = xyToLatLng([x, y]);\n    expect(lat).toBeCloseTo(latLng.lat);\n    expect(lng).toBeCloseTo(latLng.lng);\n  }\n);\n\ntest.each([\n  // 0 same\n  {\n    latLng: { lat: 0, lng: 0 },\n    reference: { lat: 0, lng: 0 },\n    relative: { x: 0, y: 0 },\n  },\n  // 1 northwest of reference\n  {\n    latLng: { lat: 0, lng: 0 },\n    reference: { lat: -1, lng: 1 },\n    relative: {\n      x: -111178.17,\n      y: 111183.81,\n    },\n  },\n  // 2 northeast of reference\n  {\n    latLng: { lat: 0, lng: 2 },\n    reference: { lat: -1, lng: 1 },\n    relative: {\n      x: 111178.17,\n      y: 111183.81,\n    },\n  },\n  // 3 southeast of reference\n  {\n    latLng: { lat: -2, lng: 2 },\n    reference: { lat: -1, lng: 1 },\n    relative: {\n      x: 111178.17,\n      y: -111217.69,\n    },\n  },\n  // 4 southwest of reference\n  {\n    latLng: { lat: -2, lng: 0 },\n    reference: { lat: -1, lng: 1 },\n    relative: {\n      x: -111178.17,\n      y: -111217.69,\n    },\n  },\n  {\n    latLng: { lat: 48.861168, lng: 2.324197 },\n    reference: { lat: 48.862676, lng: 2.319095 },\n    relative: {\n      x: 373.22,\n      y: -167.68,\n    },\n  },\n])(\n  \"latLngToVector3Relative is correct: %# %j\",\n  ({ latLng, reference, relative }) => {\n    const vector = latLngToVector3Relative(\n      { ...latLng, altitude: 0 },\n      { ...reference, altitude: 0 }\n    );\n    expect(vector.x).toBeCloseTo(relative.x, 2);\n    expect(vector.y).toBeCloseTo(relative.y, 2);\n    expect(vector.z).toBeCloseTo(0, 2);\n  }\n);\n"
  },
  {
    "path": "src/index.ts",
    "content": "/**\n * Copyright 2021 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from \"./three\";\nexport * from \"./util\";\n"
  },
  {
    "path": "src/three.ts",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  DirectionalLight,\n  Euler,\n  HemisphereLight,\n  Intersection,\n  MathUtils,\n  Matrix4,\n  Object3D,\n  PCFSoftShadowMap,\n  PerspectiveCamera,\n  Quaternion,\n  Raycaster,\n  RaycasterParameters,\n  REVISION,\n  Scene,\n  Vector2,\n  Vector3,\n  WebGLRenderer,\n} from \"three\";\nimport { latLngToVector3Relative, toLatLngAltitudeLiteral } from \"./util\";\n\nimport type { LatLngTypes } from \"./util\";\n\n// Since r162, the sRGBEncoding constant is no longer exported from three.\n// The value is kept here to keep compatibility with older three.js versions.\n// This will be removed with the next major release.\nconst sRGBEncoding = 3001;\n\nconst DEFAULT_UP = new Vector3(0, 0, 1);\n\nexport interface RaycastOptions {\n  /**\n   * Set to true to also test children of the specified objects for\n   * intersections.\n   *\n   * @default false\n   */\n  recursive?: boolean;\n\n  /**\n   * Update the inverse-projection-matrix before casting the ray (set this\n   * to false if you need to run multiple raycasts for the same frame).\n   *\n   * @default true\n   */\n  updateMatrix?: boolean;\n\n  /**\n   * Additional parameters to pass to the three.js raycaster.\n   *\n   * @see https://threejs.org/docs/#api/en/core/Raycaster.params\n   */\n  raycasterParameters?: RaycasterParameters;\n}\n\nexport interface ThreeJSOverlayViewOptions {\n  /**\n   * The anchor for the scene.\n   *\n   * @default {lat: 0, lng: 0, altitude: 0}\n   */\n  anchor?: LatLngTypes;\n\n  /**\n   * The axis pointing up in the scene. Can be specified as \"Z\", \"Y\" or a\n   * Vector3, in which case the normalized vector will become the up-axis.\n   *\n   * @default \"Z\"\n   */\n  upAxis?: \"Z\" | \"Y\" | Vector3;\n\n  /**\n   * The map the overlay will be added to.\n   * Can be set at initialization or by calling `setMap(map)`.\n   */\n  map?: google.maps.Map;\n\n  /**\n   * The scene object to render in the overlay. If no scene is specified, a\n   * new scene is created and can be accessed via `overlay.scene`.\n   */\n  scene?: Scene;\n\n  /**\n   * The animation mode controls when the overlay will redraw, either\n   * continuously (`always`) or on demand (`ondemand`). When using the\n   * on demand mode, the overlay will re-render whenever the map renders\n   * (camera movements) or when `requestRedraw()` is called.\n   *\n   * To achieve animations in this mode, you can either use an outside\n   * animation-loop that calls `requestRedraw()` as long as needed or call\n   * `requestRedraw()` from within the `onBeforeRender` function to\n   *\n   * @default \"ondemand\"\n   */\n  animationMode?: \"always\" | \"ondemand\";\n\n  /**\n   * Add default lighting to the scene.\n   * @default true\n   */\n  addDefaultLighting?: boolean;\n}\n\n/* eslint-disable @typescript-eslint/no-empty-function */\n\n/**\n * Add a [three.js](https://threejs.org) scene as a [Google Maps WebGLOverlayView](http://goo.gle/WebGLOverlayView-ref).\n */\nexport class ThreeJSOverlayView implements google.maps.WebGLOverlayView {\n  /** {@inheritDoc ThreeJSOverlayViewOptions.scene} */\n  public readonly scene: Scene;\n\n  /** {@inheritDoc ThreeJSOverlayViewOptions.animationMode} */\n  public animationMode: \"always\" | \"ondemand\" = \"ondemand\";\n\n  /** {@inheritDoc ThreeJSOverlayViewOptions.anchor} */\n  protected anchor: google.maps.LatLngAltitudeLiteral;\n  protected readonly camera: PerspectiveCamera;\n  protected readonly rotationArray: Float32Array = new Float32Array(3);\n  protected readonly rotationInverse: Quaternion = new Quaternion();\n  protected readonly projectionMatrixInverse = new Matrix4();\n\n  protected readonly overlay: google.maps.WebGLOverlayView;\n  protected renderer: WebGLRenderer;\n  protected raycaster: Raycaster = new Raycaster();\n\n  constructor(options: ThreeJSOverlayViewOptions = {}) {\n    const {\n      anchor = { lat: 0, lng: 0, altitude: 0 },\n      upAxis = \"Z\",\n      scene,\n      map,\n      animationMode = \"ondemand\",\n      addDefaultLighting = true,\n    } = options;\n\n    this.overlay = new google.maps.WebGLOverlayView();\n    this.renderer = null;\n    this.camera = null;\n    this.animationMode = animationMode;\n\n    this.setAnchor(anchor);\n    this.setUpAxis(upAxis);\n\n    this.scene = scene ?? new Scene();\n    if (addDefaultLighting) this.initSceneLights();\n\n    this.overlay.onAdd = this.onAdd.bind(this);\n    this.overlay.onRemove = this.onRemove.bind(this);\n    this.overlay.onContextLost = this.onContextLost.bind(this);\n    this.overlay.onContextRestored = this.onContextRestored.bind(this);\n    this.overlay.onStateUpdate = this.onStateUpdate.bind(this);\n    this.overlay.onDraw = this.onDraw.bind(this);\n\n    this.camera = new PerspectiveCamera();\n\n    if (map) {\n      this.setMap(map);\n    }\n  }\n\n  /**\n   * Sets the anchor-point.\n   * @param anchor\n   */\n  public setAnchor(anchor: LatLngTypes) {\n    this.anchor = toLatLngAltitudeLiteral(anchor);\n  }\n\n  /**\n   * Sets the axis to use as \"up\" in the scene.\n   * @param axis\n   */\n  public setUpAxis(axis: \"Y\" | \"Z\" | Vector3): void {\n    const upVector = new Vector3(0, 0, 1);\n    if (typeof axis !== \"string\") {\n      upVector.copy(axis);\n    } else {\n      if (axis.toLowerCase() === \"y\") {\n        upVector.set(0, 1, 0);\n      } else if (axis.toLowerCase() !== \"z\") {\n        console.warn(`invalid value '${axis}' specified as upAxis`);\n      }\n    }\n\n    upVector.normalize();\n\n    const q = new Quaternion();\n    q.setFromUnitVectors(upVector, DEFAULT_UP);\n\n    // inverse rotation is needed in latLngAltitudeToVector3()\n    this.rotationInverse.copy(q).invert();\n\n    // copy to rotationArray for transformer.fromLatLngAltitude()\n    const euler = new Euler().setFromQuaternion(q, \"XYZ\");\n    this.rotationArray[0] = MathUtils.radToDeg(euler.x);\n    this.rotationArray[1] = MathUtils.radToDeg(euler.y);\n    this.rotationArray[2] = MathUtils.radToDeg(euler.z);\n  }\n\n  /**\n   * Runs raycasting for the specified screen-coordinates against all objects\n   * in the scene.\n   *\n   * @param p normalized screenspace coordinates of the\n   *   mouse-cursor. x/y are in range [-1, 1], y is pointing up.\n   * @param options raycasting options. In this case the `recursive` option\n   *   has no effect as it is always recursive.\n   * @return the list of intersections\n   */\n  public raycast(p: Vector2, options?: RaycastOptions): Intersection[];\n\n  /**\n   * Runs raycasting for the specified screen-coordinates against the specified\n   * list of objects.\n   *\n   * Note for typescript users: the returned Intersection objects can only be\n   * properly typed for non-recursive lookups (this is handled by the internal\n   * signature below).\n   *\n   * @param p normalized screenspace coordinates of the\n   *   mouse-cursor. x/y are in range [-1, 1], y is pointing up.\n   * @param objects list of objects to test\n   * @param options raycasting options.\n   */\n  public raycast(\n    p: Vector2,\n    objects: Object3D[],\n    options?: RaycastOptions & { recursive: true }\n  ): Intersection[];\n\n  // additional signature to enable typings in returned objects when possible\n  public raycast<T extends Object3D>(\n    p: Vector2,\n    objects: T[],\n    options?:\n      | Omit<RaycastOptions, \"recursive\">\n      | (RaycastOptions & { recursive: false })\n  ): Intersection<T>[];\n\n  // implemetation\n  public raycast(\n    p: Vector2,\n    optionsOrObjects?: Object3D[] | RaycastOptions,\n    options: RaycastOptions = {}\n  ): Intersection[] {\n    let objects: Object3D[];\n    if (Array.isArray(optionsOrObjects)) {\n      objects = optionsOrObjects || null;\n    } else {\n      objects = [this.scene];\n      options = { ...optionsOrObjects, recursive: true };\n    }\n\n    const {\n      updateMatrix = true,\n      recursive = false,\n      raycasterParameters,\n    } = options;\n\n    // when `raycast()` is called from within the `onBeforeRender()` callback,\n    // the mvp-matrix for this frame has already been computed and stored in\n    // `this.camera.projectionMatrix`.\n    // The mvp-matrix transforms world-space meters to clip-space\n    // coordinates. The inverse matrix created here does the exact opposite\n    // and converts clip-space coordinates to world-space.\n    if (updateMatrix) {\n      this.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();\n    }\n\n    // create two points (with different depth) from the mouse-position and\n    // convert them into world-space coordinates to set up the ray.\n    this.raycaster.ray.origin\n      .set(p.x, p.y, 0)\n      .applyMatrix4(this.projectionMatrixInverse);\n\n    this.raycaster.ray.direction\n      .set(p.x, p.y, 0.5)\n      .applyMatrix4(this.projectionMatrixInverse)\n      .sub(this.raycaster.ray.origin)\n      .normalize();\n\n    // back up the raycaster parameters\n    const oldRaycasterParams = this.raycaster.params;\n    if (raycasterParameters) {\n      this.raycaster.params = raycasterParameters;\n    }\n\n    const results = this.raycaster.intersectObjects(objects, recursive);\n\n    // reset raycaster params to whatever they were before\n    this.raycaster.params = oldRaycasterParams;\n\n    return results;\n  }\n\n  /**\n   * Overwrite this method to handle any GL state updates outside the\n   * render animation frame.\n   * @param options\n   */\n  public onStateUpdate(options: google.maps.WebGLStateOptions): void;\n  public onStateUpdate(): void {}\n\n  /**\n   * Overwrite this method to fetch or create intermediate data structures\n   * before the overlay is drawn that don’t require immediate access to the\n   * WebGL rendering context.\n   */\n  public onAdd(): void {}\n\n  /**\n   * Overwrite this method to update your scene just before a new frame is\n   * drawn.\n   */\n  public onBeforeDraw(): void {}\n\n  /**\n   * This method is called when the overlay is removed from the map with\n   * `overlay.setMap(null)`, and is where you can remove all intermediate\n   * objects created in onAdd.\n   */\n  public onRemove(): void {}\n\n  /**\n   * Triggers the map to update GL state.\n   */\n  public requestStateUpdate(): void {\n    this.overlay.requestStateUpdate();\n  }\n\n  /**\n   * Triggers the map to redraw a frame.\n   */\n  public requestRedraw(): void {\n    this.overlay.requestRedraw();\n  }\n\n  /**\n   * Returns the map the overlay is added to.\n   */\n  public getMap(): google.maps.Map {\n    return this.overlay.getMap();\n  }\n\n  /**\n   * Adds the overlay to the map.\n   * @param map The map to access the div, model and view state.\n   */\n  public setMap(map: google.maps.Map): void {\n    this.overlay.setMap(map);\n  }\n\n  /**\n   * Adds the given listener function to the given event name. Returns an\n   * identifier for this listener that can be used with\n   * <code>google.maps.event.removeListener</code>.\n   */\n  public addListener(\n    eventName: string,\n    handler: (...args: unknown[]) => void\n  ): google.maps.MapsEventListener {\n    return this.overlay.addListener(eventName, handler);\n  }\n\n  /**\n   * This method is called once the rendering context is available. Use it to\n   * initialize or bind any WebGL state such as shaders or buffer objects.\n   * @param options that allow developers to restore the GL context.\n   */\n  public onContextRestored({ gl }: google.maps.WebGLStateOptions) {\n    this.renderer = new WebGLRenderer({\n      canvas: gl.canvas,\n      context: gl,\n      ...gl.getContextAttributes(),\n    });\n    this.renderer.autoClear = false;\n    this.renderer.autoClearDepth = false;\n    this.renderer.shadowMap.enabled = true;\n    this.renderer.shadowMap.type = PCFSoftShadowMap;\n\n    // Since r152, default outputColorSpace is SRGB\n    // Deprecated outputEncoding kept for backwards compatibility\n    if (Number(REVISION) < 152) {\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n      (this.renderer as any).outputEncoding = sRGBEncoding;\n    }\n\n    const { width, height } = gl.canvas;\n    this.renderer.setViewport(0, 0, width, height);\n  }\n\n  /**\n   * This method is called when the rendering context is lost for any reason,\n   * and is where you should clean up any pre-existing GL state, since it is\n   * no longer needed.\n   */\n  public onContextLost() {\n    if (!this.renderer) {\n      return;\n    }\n\n    this.renderer.dispose();\n    this.renderer = null;\n  }\n\n  /**\n   * Implement this method to draw WebGL content directly on the map. Note\n   * that if the overlay needs a new frame drawn then call {@link\n   * ThreeJSOverlayView.requestRedraw}.\n   * @param options that allow developers to render content to an associated\n   *     Google basemap.\n   */\n  public onDraw({ gl, transformer }: google.maps.WebGLDrawOptions): void {\n    this.camera.projectionMatrix.fromArray(\n      transformer.fromLatLngAltitude(this.anchor, this.rotationArray)\n    );\n\n    gl.disable(gl.SCISSOR_TEST);\n\n    this.onBeforeDraw();\n\n    this.renderer.render(this.scene, this.camera);\n    this.renderer.resetState();\n\n    if (this.animationMode === \"always\") this.requestRedraw();\n  }\n\n  /**\n   * Convert coordinates from WGS84 Latitude Longitude to world-space\n   * coordinates while taking the origin and orientation into account.\n   */\n  public latLngAltitudeToVector3(\n    position: LatLngTypes,\n    target = new Vector3()\n  ) {\n    latLngToVector3Relative(\n      toLatLngAltitudeLiteral(position),\n      this.anchor,\n      target\n    );\n\n    target.applyQuaternion(this.rotationInverse);\n\n    return target;\n  }\n\n  // MVCObject interface forwarded to the overlay\n\n  /**\n   * Binds a View to a Model.\n   */\n  public bindTo(\n    key: string,\n    target: google.maps.MVCObject,\n    targetKey?: string,\n    noNotify?: boolean\n  ): void {\n    this.overlay.bindTo(key, target, targetKey, noNotify);\n  }\n\n  /**\n   * Gets a value.\n   */\n  public get(key: string) {\n    return this.overlay.get(key);\n  }\n\n  /**\n   * Notify all observers of a change on this property. This notifies both\n   * objects that are bound to the object's property as well as the object\n   * that it is bound to.\n   */\n  public notify(key: string): void {\n    this.overlay.notify(key);\n  }\n\n  /**\n   * Sets a value.\n   */\n  public set(key: string, value: unknown): void {\n    this.overlay.set(key, value);\n  }\n\n  /**\n   * Sets a collection of key-value pairs.\n   */\n  public setValues(values?: object): void {\n    this.overlay.setValues(values);\n  }\n\n  /**\n   * Removes a binding. Unbinding will set the unbound property to the current\n   * value. The object will not be notified, as the value has not changed.\n   */\n  public unbind(key: string): void {\n    this.overlay.unbind(key);\n  }\n\n  /**\n   * Removes all bindings.\n   */\n  public unbindAll(): void {\n    this.overlay.unbindAll();\n  }\n\n  /**\n   * Creates lights (directional and hemisphere light) to illuminate the model\n   * (roughly approximates the lighting of buildings in maps)\n   */\n  private initSceneLights() {\n    const hemiLight = new HemisphereLight(0xffffff, 0x444444, 1);\n    hemiLight.position.set(0, -0.2, 1).normalize();\n\n    const dirLight = new DirectionalLight(0xffffff);\n    dirLight.position.set(0, 10, 100);\n\n    this.scene.add(hemiLight, dirLight);\n  }\n}\n"
  },
  {
    "path": "src/util.ts",
    "content": "/**\n * Copyright 2021 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MathUtils, Vector3 } from \"three\";\n\nexport type LatLngTypes =\n  | google.maps.LatLngLiteral\n  | google.maps.LatLng\n  | google.maps.LatLngAltitudeLiteral\n  | google.maps.LatLngAltitude;\n\n// shorthands for math-functions, makes equations more readable\nconst { atan, cos, exp, log, tan, PI } = Math;\nconst { degToRad, radToDeg } = MathUtils;\n\nexport const EARTH_RADIUS = 6371010.0;\nexport const WORLD_SIZE = Math.PI * EARTH_RADIUS;\n\n/**\n * Converts any of the supported position formats into the\n * google.maps.LatLngAltitudeLiteral format used for the calculations.\n * @param point\n */\nexport function toLatLngAltitudeLiteral(\n  point: LatLngTypes\n): google.maps.LatLngAltitudeLiteral {\n  if (\n    window.google &&\n    google.maps &&\n    (point instanceof google.maps.LatLng ||\n      point instanceof google.maps.LatLngAltitude)\n  ) {\n    return { altitude: 0, ...point.toJSON() };\n  }\n\n  return { altitude: 0, ...(point as google.maps.LatLngLiteral) };\n}\n\n/**\n * Converts latitude and longitude to world space coordinates relative\n * to a reference location with y up.\n */\nexport function latLngToVector3Relative(\n  point: google.maps.LatLngAltitudeLiteral,\n  reference: google.maps.LatLngAltitudeLiteral,\n  target = new Vector3()\n) {\n  const [px, py] = latLngToXY(point);\n  const [rx, ry] = latLngToXY(reference);\n\n  target.set(px - rx, py - ry, 0);\n\n  // apply the spherical mercator scale-factor for the reference latitude\n  target.multiplyScalar(cos(degToRad(reference.lat)));\n\n  target.z = point.altitude - reference.altitude;\n\n  return target;\n}\n\n/**\n * Converts WGS84 latitude and longitude to (uncorrected) WebMercator meters.\n * (WGS84 --> WebMercator (EPSG:3857))\n */\nexport function latLngToXY(position: google.maps.LatLngLiteral): number[] {\n  return [\n    EARTH_RADIUS * degToRad(position.lng),\n    EARTH_RADIUS * log(tan(0.25 * PI + 0.5 * degToRad(position.lat))),\n  ];\n}\n\n/**\n * Converts WebMercator meters to WGS84 latitude/longitude.\n * (WebMercator (EPSG:3857) --> WGS84)\n */\nexport function xyToLatLng(p: number[]): google.maps.LatLngLiteral {\n  const [x, y] = p;\n\n  return {\n    lat: radToDeg(PI * 0.5 - 2.0 * atan(exp(-y / EARTH_RADIUS))),\n    lng: radToDeg(x) / EARTH_RADIUS,\n  };\n}\n"
  },
  {
    "path": "tsconfig.examples.json",
    "content": "{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"declaration\": false,\n    \"noEmit\": true,\n    \"outDir\": null,\n    \"declarationDir\": null,\n    \"noImplicitAny\": false,\n    \"resolveJsonModule\": true\n  },\n  \"include\": [\"src/**/*\", \"examples/**/*\"]\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"declaration\": true,\n    \"declarationDir\": \"./dist\",\n    \"noImplicitAny\": true,\n    \"outDir\": \"./dist\",\n    \"sourceMap\": true,\n    \"esModuleInterop\": true,\n    \"lib\": [\"DOM\", \"ESNext\", \"ES2019\"],\n    \"target\": \"ES2020\",\n    \"module\": \"ES2020\",\n    \"moduleResolution\": \"node\",\n    \"skipLibCheck\": true,\n    \"resolveJsonModule\": true\n  },\n  \"include\": [\"src/**/*\"],\n  \"exclude\": [\"node_modules\", \"./dist\"]\n}\n"
  },
  {
    "path": "typedoc.cjs",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nmodule.exports = {\n  out: \"docs\",\n  exclude: [\"**/node_modules/**\", \"**/*.spec.ts\", \"**/*.test.ts\"],\n  name: \"@googlemaps/three\",\n  excludePrivate: true,\n  media: \"assets\",\n};\n"
  }
]