-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: temporarily add heightfield helper 2 using duDebugDrawHeightfie…
…ldWalkable
- Loading branch information
1 parent
b503744
commit 87f43f1
Showing
7 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/recast-navigation-three/src/helpers/heightfield-helper-2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Raw, RecastHeightfield } from '@recast-navigation/core'; | ||
import { Object3D } from 'three'; | ||
import { DebugDraw } from '../debug-draw'; | ||
|
||
export type HeightfieldHelper2Params = { | ||
heightfields: RecastHeightfield[]; | ||
}; | ||
|
||
export class HeightfieldHelper2 extends Object3D { | ||
private heightfields: RecastHeightfield[]; | ||
|
||
private debugDraw: DebugDraw; | ||
|
||
constructor({ heightfields }: HeightfieldHelper2Params) { | ||
super(); | ||
|
||
this.heightfields = heightfields; | ||
|
||
this.debugDraw = new DebugDraw(); | ||
this.add(this.debugDraw.group); | ||
|
||
this.update(); | ||
} | ||
|
||
resize(width: number, height: number) { | ||
this.debugDraw.resize(width, height); | ||
} | ||
|
||
update(): void { | ||
this.debugDraw.reset(); | ||
|
||
for (const heightfield of this.heightfields) { | ||
Raw.RecastDebugDraw.debugDrawHeightfieldWalkable( | ||
this.debugDraw.raw, | ||
heightfield.raw | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
packages/recast-navigation/.storybook/stories/helpers/debug-draw.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters