Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/npm-publish-dry-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
pull_request:
types: [opened]

jobs:
test-build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Clear NPM cache
run: npm cache clean --force

- name: Install dependencies and build
run: npm ci

- name: Make release
run: npm run make
id: makeRelease

- name: Fail job if makeRelease failed
if: steps.makeRelease.outcome == 'failure'
run: exit 1

id: check-build-status
- name: Publish NPM package (regular)
if: "!github.event.release.prerelease"
run: |
npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

- name: Publish NPM package (pre-release)
if: "github.event.release.prerelease"
run: |
npm publish --tag next --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
50 changes: 45 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,53 @@ jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run make
- run: npm publish --access public

- name: Clear NPM cache
run: npm cache clean --force

- name: Install dependencies and build
run: npm ci

- name: Make release
run: npm run make
id: makeRelease

- name: Fail job if makeRelease failed
if: steps.makeRelease.outcome == 'failure'
run: exit 1

id: check-build-status
- name: Publish NPM package (regular)
if: "!github.event.release.prerelease"
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

- name: Publish NPM package (pre-release)
if: "github.event.release.prerelease"
run: |
npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
- name: Get Package version
id: version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Publish to CDN Cloudflar R2
uses: ryand56/[email protected]
with:
r2-account-id: ${{ secrets.CDN_MAPTILER_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.CDN_MAPTILER_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.CDN_MAPTILER_SECRET_ACCESS_KEY }}
r2-bucket: cdn-storage
source-dir: build
destination-dir: /maptiler-3d-js/v${{ env.PACKAGE_VERSION }}/
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MapTiler 3D Models Changelog
### NEXT (3.0.0)

### 3.0.0

## ✨ New Features
- GLTF Models are now animateable 🎬 🚀
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maptiler/3d",
"version": "2.2.0",
"version": "3.0.0",
"description": "Add 3D things to your map, plugin for MapTiler SDK",
"module": "dist/maptiler-3d.js",
"types": "dist/maptiler-3d.d.ts",
Expand Down
25 changes: 20 additions & 5 deletions src/WebGLRenderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
Point2D,
PointLike,
} from "@maptiler/sdk";
import type { Camera, Intersection, Scene } from "three";
import type { Camera, Intersection, Object3D, Scene } from "three";
import { Matrix4, Raycaster, Vector2, Vector3, WebGLRenderer } from "three";
import type { Layer3D } from "./Layer3D";
import {
Expand Down Expand Up @@ -243,14 +243,18 @@ export class WebGLRenderManager {

if (!intersections[0] && !this.currentRaycastIntersection) return;

if (this.currentRaycastIntersection?.object === intersections[0]?.object) return;
const group = getTopMostAncestorMesh(intersections[0]?.object);

const { object, ...intersection } = this.currentRaycastIntersection ?? intersections[0];
if (this.currentRaycastIntersection?.object === group) return;

const { object, ...intersection } = this.currentRaycastIntersection ?? { ...intersections[0], object: group };

const methodSymbol = this.currentRaycastIntersection
? handleMeshMouseLeaveMethodSymbol
: handleMeshMouseEnterMethodSymbol;

if (!object) return;

const mouse = {
x: this.pointer.x,
y: this.pointer.y,
Expand All @@ -265,7 +269,7 @@ export class WebGLRenderManager {
point: mouse,
});

this.currentRaycastIntersection = intersections[0] || null;
this.currentRaycastIntersection = intersections[0] ? { ...intersections[0], object } : null;
}
}

Expand Down Expand Up @@ -363,7 +367,7 @@ export class WebGLRenderManager {

this.raycaster.set(cameraPosition, viewDirection);

return this.raycaster.intersectObjects(scene.children, true);
return this.raycaster.intersectObjects(scene.children);
}

/**
Expand Down Expand Up @@ -493,3 +497,14 @@ export class WebGLManagerLayer implements CustomLayerInterface {
this.webGLRenderManager.render(options);
}
}

function getTopMostAncestorMesh(object?: Object3D) {
if (!object) return null;
let objectToActOn = object;
object.traverseAncestors((a) => {
if (a.userData.meshID) {
objectToActOn = a;
}
});
return objectToActOn;
}