Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into main #352

Merged
merged 13 commits into from
May 4, 2024
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
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"node-cjs-example",
"node-esm-example",
"parcel-example",
"vite-example"
"vite-wasm-example",
"vite-worker-example"
],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
Expand Down
6 changes: 6 additions & 0 deletions .changeset/eighty-hounds-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@recast-navigation/core": minor
"recast-navigation": minor
---

feat: change Crowd and NavMeshQuery constructors to take NavMesh as first arg, and options as second
7 changes: 7 additions & 0 deletions .changeset/few-weeks-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@recast-navigation/core": minor
"@recast-navigation/wasm": minor
"recast-navigation": minor
---

fix: change findPolysAroundCircle resultCost to be a FloatArray, not a FloatRef
6 changes: 6 additions & 0 deletions .changeset/moody-boats-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@recast-navigation/core": minor
"recast-navigation": minor
---

feat(NavMeshQuery): rename closestPointOnPoly posOverPoly return to isPointOverPoly
32 changes: 32 additions & 0 deletions .changeset/real-boxes-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
"@recast-navigation/core": minor
"recast-navigation": minor
---

feat: support separate wasm file as well as inlined wasm file

Progresses https://github.com/isaac-mason/recast-navigation-js/issues/164

Now `init` can be optionally passed a default import of one of the `@recast-navigation/wasm` packages.

The `@recast-navigation/wasm` package is no longer included in the `@recast-navigation/core` package. If nothing is passed to `init`, the inlined wasm-compat flavor is dynamically imported.

Note that the other `wasm` flavor currently does not support node.js environments.

```ts
import { init } from 'recast-navigation';

// import the 'wasm' flavor - has a separate wasm file, not inlined
import RecastWasm from '@recast-navigation/wasm/wasm';

await init(RecastWasm);
```

It's still possible to use the inlined wasm flavor by not passing anything to `init` as before.

```ts
import { init } from 'recast-navigation';

// internally dynamically imports `@recast-navigation/wasm`
await init();
```
6 changes: 6 additions & 0 deletions .changeset/sharp-maps-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@recast-navigation/core": minor
"recast-navigation": minor
---

feat(Arrays): rename 'free' to 'destroy' for consistency with other methods
6 changes: 6 additions & 0 deletions .changeset/short-geese-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@recast-navigation/core": minor
"recast-navigation": minor
---

fix: missing cleanup for Raw Vec3 and \*Ref classes
4 changes: 2 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 18.x
- name: Setup Node.js 22.x
uses: actions/setup-node@v2
with:
node-version: 18.x
node-version: 22.x

- name: Install Dependencies
run: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 18.x
- name: Setup Node.js 22.x
uses: actions/setup-node@v2
with:
node-version: 18.x
node-version: 22.x

- name: Install Dependencies
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.12.1
v22.0.0
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The `recast-navigation-js` repository is structured as a yarn monorepo. You will

### Node Installation

**This project uses node 18.**
**This project uses node 22.**

If you don't already use a node version manager. Give nvm a try if you don't already have one.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ export const RecastAgent = forwardRef<RecastAgentRef, RecastAgentProps>(
return;
}

const navMeshQuery = new NavMeshQuery({ navMesh });
const navMeshQuery = new NavMeshQuery(navMesh);

const crowd = new Crowd({
navMesh,
const crowd = new Crowd(navMesh, {
maxAgents: 1,
maxAgentRadius: agentRadius,
});
Expand Down
84 changes: 84 additions & 0 deletions examples/no-bundler/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<html>
<script type="importmap">
{
"imports": {
"@recast-navigation/core": "https://unpkg.com/@recast-navigation/[email protected]/dist/index.mjs",
"@recast-navigation/wasm": "https://unpkg.com/@recast-navigation/[email protected]/dist/recast-navigation.wasm-compat.js",
"@recast-navigation/generators": "https://unpkg.com/@recast-navigation/[email protected]/dist/index.mjs",
"@recast-navigation/three": "https://unpkg.com/@recast-navigation/[email protected]/dist/index.mjs",
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/examples/jsm/controls/OrbitControls": "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import { init } from '@recast-navigation/core';
import { DebugDrawer, threeToSoloNavMesh } from '@recast-navigation/three';

await init();

const renderer = new THREE.WebGLRenderer();
document.body.appendChild(renderer.domElement);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera();
camera.position.set(10, 10, 10);

const orbitControls = new OrbitControls(camera, renderer.domElement);

const ground = new THREE.Mesh(
new THREE.BoxGeometry(10, 1, 10),
new THREE.MeshBasicMaterial({ color: '#333' })
);

scene.add(ground);

const box = new THREE.Mesh(
new THREE.BoxGeometry(2, 2, 2),
new THREE.MeshBasicMaterial({ color: '#555' })
);
box.position.set(0, 1, 0);

scene.add(box);

const { success, navMesh } = threeToSoloNavMesh([ground, box], {
cs: 0.05,
ch: 0.05,
});

const debugDrawer = new DebugDrawer();
debugDrawer.drawNavMesh(navMesh);

scene.add(debugDrawer);

const onWindowResize = () => {
debugDrawer.resize(window.innerWidth, window.innerHeight);

camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
};
onWindowResize();

window.addEventListener('resize', onWindowResize);

const animate = () => {
requestAnimationFrame(animate);
renderer.render(scene, camera);
};

animate();
</script>
<style>
body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100%;
height: 100vh;
}
</style>
</html>
2 changes: 1 addition & 1 deletion examples/node-cjs-example/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Recast.init().then(() => {

const { navMesh } = RecastGenerators.generateSoloNavMesh(positions, indices, config);

const navMeshQuery = new Recast.NavMeshQuery({ navMesh });
const navMeshQuery = new Recast.NavMeshQuery(navMesh);

const { point: closestPoint } = navMeshQuery.findClosestPoint({ x: 2, y: 1, z: 2 });

Expand Down
2 changes: 1 addition & 1 deletion examples/node-cjs-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "example of using recast-navigation in node",
"scripts": {
"start": "node index.cjs"
"start": "node --experimental-require-module index.cjs"
},
"author": "",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion examples/node-esm-example/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const indices = groundMesh.geometry.index.array;

const { navMesh } = generateSoloNavMesh(positions, indices, config);

const navMeshQuery = new NavMeshQuery({ navMesh });
const navMeshQuery = new NavMeshQuery(navMesh);

const { point: closestPoint } = navMeshQuery.findClosestPoint({ x: 2, y: 1, z: 2 });

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vite-example",
"name": "vite-wasm-example",
"private": true,
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Environment, OrbitControls } from '@react-three/drei';
import { OrbitControls } from '@react-three/drei';
import { Canvas, useThree } from '@react-three/fiber';
import RecastWasm from '@recast-navigation/wasm/wasm';
import { useEffect, useRef } from 'react';
import { NavMeshQuery, init } from 'recast-navigation';
import { NavMeshHelper, threeToSoloNavMesh } from 'recast-navigation/three';
Expand Down Expand Up @@ -39,7 +40,7 @@ const App = () => {

if (!success) return;

const navMeshQuery = new NavMeshQuery({ navMesh });
const navMeshQuery = new NavMeshQuery(navMesh);

const navMeshHelper = new NavMeshHelper({
navMesh,
Expand Down Expand Up @@ -109,7 +110,7 @@ const App = () => {
};

const RecastInit = (props: { children: JSX.Element }) => {
suspend(() => init(), []);
suspend(() => init(RecastWasm), []);

return props.children;
};
Expand All @@ -119,7 +120,8 @@ export default () => (
<Canvas camera={{ position: [5, 5, 5] }}>
<App />

<Environment preset="city" />
<ambientLight intensity={1.5} />
<directionalLight position={[5, 5, -5]} intensity={3} />

<OrbitControls />
</Canvas>
Expand Down
24 changes: 24 additions & 0 deletions examples/vite-worker-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions examples/vite-worker-example/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
13 changes: 13 additions & 0 deletions examples/vite-worker-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/vite-worker-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "vite-worker-example",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@react-three/drei": "^9.105.4",
"@react-three/fiber": "^8.15.12",
"react": "^18.3.1",
"react-dom": "^18.2.0",
"recast-navigation": "0.27.0",
"suspend-react": "^0.1.3",
"three": "^0.163.0"
},
"devDependencies": {
"@types/react": "^18.3.1",
"@types/react-dom": "^18.2.8",
"@types/three": "^0.163.0",
"@vitejs/plugin-react": "^4.2.0",
"typescript": "^5.4.3",
"vite": "^5.2.8"
}
}
Loading
Loading