@egret/engine 7.0.1-rc.3 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Engine.js +7 -2
- package/dist/animation/sequenceResetTypes.d.ts +6 -0
- package/dist/animation/types.d.ts +6 -0
- package/dist/assetBundle.d.ts +2 -0
- package/dist/assetGroupTypes.d.ts +2 -0
- package/dist/audioCues.d.ts +4 -0
- package/dist/audioTypes.d.ts +13 -0
- package/dist/bitmapButtonTypes.d.ts +2 -0
- package/dist/bitmapFontTypes.d.ts +3 -0
- package/dist/bitmapResourceSlot.d.ts +1 -0
- package/dist/camera2d.js +10 -2
- package/dist/cameraTypes.d.ts +12 -0
- package/dist/contentTypes.d.ts +2 -0
- package/dist/createEngineForProfile.js +8 -5
- package/dist/fontContentTypes.d.ts +5 -0
- package/dist/gameClockTypes.d.ts +6 -0
- package/dist/gameRun.d.ts +3 -0
- package/dist/gamepadTypes.d.ts +8 -0
- package/dist/hoverInputTypes.d.ts +10 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/inputActions.d.ts +5 -0
- package/dist/internal/uiFactoryState.d.ts +4 -0
- package/dist/internal/uiFactoryState.js +18 -2
- package/dist/keyboardInput.d.ts +1 -0
- package/dist/keyboardInput.js +1 -0
- package/dist/keyboardInputTypes.d.ts +12 -0
- package/dist/kit.d.ts +3 -1
- package/dist/kit.js +2 -1
- package/dist/manifestResourceState.d.ts +1 -0
- package/dist/manifestResourceState.js +1 -0
- package/dist/manifestResourceTypes.d.ts +1 -0
- package/dist/motion.d.ts +2 -0
- package/dist/mouseInputTypes.d.ts +4 -0
- package/dist/particleEmitter.js +8 -0
- package/dist/particleTypes.d.ts +8 -0
- package/dist/physics2d.d.ts +2 -2
- package/dist/physics2d.js +1 -1
- package/dist/physics2dTypes.d.ts +55 -1
- package/dist/physics2dWorld.js +209 -9
- package/dist/pointerInput.d.ts +1 -0
- package/dist/pointerInput.js +1 -0
- package/dist/pointerInputTypes.d.ts +3 -0
- package/dist/random.d.ts +1 -0
- package/dist/rendering/packSharedDraws2D.js +53 -5
- package/dist/rendering/prepareSharedDraws2D.d.ts +2 -0
- package/dist/rendering/prepareSharedDraws2D.js +17 -6
- package/dist/rendering/sharedColor2D.d.ts +35 -1
- package/dist/rendering/sharedColor2D.js +131 -8
- package/dist/rendering/sharedEffects2D.js +16 -8
- package/dist/rendering/world3d/Animation3D.d.ts +9 -0
- package/dist/rendering/world3d/Animation3D.js +4 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +6 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +2 -0
- package/dist/rendering/world3d/Batch3D.d.ts +4 -0
- package/dist/rendering/world3d/Batch3D.js +3 -0
- package/dist/rendering/world3d/Camera3D.d.ts +5 -0
- package/dist/rendering/world3d/Camera3D.js +3 -0
- package/dist/rendering/world3d/Character3D.d.ts +4 -0
- package/dist/rendering/world3d/Character3D.js +2 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +18 -3
- package/dist/rendering/world3d/Cloth3D.js +6 -1
- package/dist/rendering/world3d/Compression3D.d.ts +1 -0
- package/dist/rendering/world3d/Compression3D.js +1 -0
- package/dist/rendering/world3d/Curves3D.d.ts +8 -0
- package/dist/rendering/world3d/Curves3D.js +5 -0
- package/dist/rendering/world3d/Decal3D.d.ts +2 -0
- package/dist/rendering/world3d/Decal3D.js +1 -0
- package/dist/rendering/world3d/Export3D.d.ts +13 -0
- package/dist/rendering/world3d/Export3D.js +263 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +11 -1
- package/dist/rendering/world3d/Geometry3D.js +10 -1
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +2 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +5 -0
- package/dist/rendering/world3d/Gizmo3D.js +2 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +6 -0
- package/dist/rendering/world3d/Gltf3D.js +25 -5
- package/dist/rendering/world3d/GpuParticles3D.d.ts +2 -0
- package/dist/rendering/world3d/GpuParticles3D.js +1 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +2 -0
- package/dist/rendering/world3d/Hdr3D.js +1 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +2 -0
- package/dist/rendering/world3d/Jelly3D.js +1 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +3 -0
- package/dist/rendering/world3d/Light3D.d.ts +9 -0
- package/dist/rendering/world3d/Light3D.js +4 -0
- package/dist/rendering/world3d/Material3D.d.ts +10 -0
- package/dist/rendering/world3d/Material3D.js +2 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +4 -0
- package/dist/rendering/world3d/Mesh3D.js +16 -2
- package/dist/rendering/world3d/Meshopt3D.d.ts +3 -0
- package/dist/rendering/world3d/Meshopt3D.js +1 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +41 -1
- package/dist/rendering/world3d/Navigation3D.js +74 -2
- package/dist/rendering/world3d/Object3D.d.ts +11 -0
- package/dist/rendering/world3d/Object3D.js +10 -0
- package/dist/rendering/world3d/Particles3D.d.ts +5 -0
- package/dist/rendering/world3d/Particles3D.js +3 -0
- package/dist/rendering/world3d/Physics3D.d.ts +14 -0
- package/dist/rendering/world3d/Physics3D.js +5 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +2 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +5 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +2 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +5 -0
- package/dist/rendering/world3d/Ragdoll3D.js +2 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +3 -0
- package/dist/rendering/world3d/Raycast3D.js +1 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +3 -0
- package/dist/rendering/world3d/RenderList3D.js +12 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +1 -0
- package/dist/rendering/world3d/Rig3D.d.ts +57 -0
- package/dist/rendering/world3d/Rig3D.js +219 -0
- package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
- package/dist/rendering/world3d/Sdf3D.js +1136 -0
- package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
- package/dist/rendering/world3d/SdfLod3D.js +56 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +17 -0
- package/dist/rendering/world3d/Serialize3D.js +22 -0
- package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
- package/dist/rendering/world3d/Simplify3D.js +426 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +9 -0
- package/dist/rendering/world3d/StateMachine3D.js +3 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +21 -0
- package/dist/rendering/world3d/Terrain3D.js +25 -1
- package/dist/rendering/world3d/Text3D.d.ts +5 -0
- package/dist/rendering/world3d/Text3D.js +2 -0
- package/dist/rendering/world3d/Texture3D.d.ts +16 -1
- package/dist/rendering/world3d/Texture3D.js +19 -1
- package/dist/rendering/world3d/Trail3D.d.ts +3 -0
- package/dist/rendering/world3d/Trail3D.js +2 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +5 -0
- package/dist/rendering/world3d/Vehicle3D.js +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +1 -0
- package/dist/rendering/world3d/Water3D.d.ts +2 -0
- package/dist/rendering/world3d/Water3D.js +1 -0
- package/dist/rendering/world3d/core3D.d.ts +2 -0
- package/dist/rendering/world3d/debug3D.d.ts +5 -0
- package/dist/rendering/world3d/debug3D.js +5 -0
- package/dist/rendering/world3d/geometries3D.d.ts +12 -0
- package/dist/rendering/world3d/geometries3D.js +5 -0
- package/dist/rendering/world3d/helpers3D.d.ts +2 -0
- package/dist/rendering/world3d/helpers3D.js +1 -0
- package/dist/rendering/world3d/index.d.ts +12 -0
- package/dist/rendering/world3d/index.js +6 -0
- package/dist/rendering/world3d/math3D.d.ts +36 -0
- package/dist/rendering/world3d/math3D.js +35 -0
- package/dist/rendering/world3d/primitives3D.d.ts +7 -0
- package/dist/rendering/world3d/primitives3D.js +1 -0
- package/dist/saveStore.d.ts +18 -3
- package/dist/saveStore.js +23 -4
- package/dist/semanticList.d.ts +4 -0
- package/dist/semanticList.js +1 -0
- package/dist/semanticTree.js +11 -4
- package/dist/semanticTypes.d.ts +8 -0
- package/dist/sequencePlaybackTypes.d.ts +3 -0
- package/dist/text.d.ts +1 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tilemapTypes.d.ts +13 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tweenTypes.d.ts +4 -0
- package/dist/ui/controlKeys.d.ts +4 -0
- package/dist/ui/controlKeys.js +1 -0
- package/dist/ui/controls.d.ts +6 -0
- package/dist/ui/controls.js +2 -0
- package/dist/ui/layerTypes.d.ts +7 -0
- package/dist/ui/rangeControl.d.ts +3 -0
- package/dist/ui/rangeControl.js +1 -0
- package/dist/ui/scrollControl.d.ts +12 -0
- package/dist/ui/scrollControl.js +5 -1
- package/dist/ui/stateControls.d.ts +8 -0
- package/dist/ui/stateControls.js +3 -0
- package/dist/ui/textEditor.d.ts +1 -0
- package/dist/ui/textEditor.js +1 -0
- package/dist/ui/textEditorTypes.d.ts +7 -0
- package/dist/ui/textFieldControl.d.ts +4 -0
- package/dist/ui/textFieldControl.js +1 -0
- package/dist/ui/theme.d.ts +5 -0
- package/dist/ui/theme.js +1 -0
- package/dist/ui/types.d.ts +20 -0
- package/dist/ui/uiRoot.js +38 -9
- package/dist/ui/uiRootModel.d.ts +3 -1
- package/dist/ui/uiRootModel.js +8 -2
- package/dist/videoTypes.d.ts +3 -0
- package/dist/web/BrowserAssetBundle.d.ts +2 -0
- package/dist/web/BrowserAudio.d.ts +34 -1
- package/dist/web/BrowserAudio.js +69 -39
- package/dist/web/BrowserFrameLoop.d.ts +4 -0
- package/dist/web/BrowserGame.d.ts +64 -2
- package/dist/web/BrowserGame.js +129 -8
- package/dist/web/BrowserGamepadInput.d.ts +3 -0
- package/dist/web/BrowserHoverInput.d.ts +1 -0
- package/dist/web/BrowserImageTextures.d.ts +6 -0
- package/dist/web/BrowserInputActions.d.ts +10 -0
- package/dist/web/BrowserInputActions.js +4 -1
- package/dist/web/BrowserPlay.d.ts +130 -2
- package/dist/web/BrowserPlay.js +366 -19
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +2 -0
- package/dist/web/BrowserStatsPanel.d.ts +10 -0
- package/dist/web/BrowserStatsPanel.js +9 -3
- package/dist/web/BrowserStorage.d.ts +2 -0
- package/dist/web/BrowserTextEditor.d.ts +3 -0
- package/dist/web/BrowserTextInput.d.ts +6 -0
- package/dist/web/BrowserTextureProvider.d.ts +6 -0
- package/dist/web/BrowserVideo.d.ts +13 -1
- package/dist/web/BrowserVideo.js +28 -2
- package/dist/web/CanvasKitFontSetProvider.d.ts +3 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +4 -0
- package/dist/web/CanvasKitParagraphProvider.js +1 -0
- package/dist/web/ManifestByteSource.d.ts +4 -0
- package/dist/web/ManifestByteSource.js +1 -0
- package/dist/web/ManifestFontContentLoader.d.ts +1 -0
- package/dist/web/WebGL2Host.js +64 -25
- package/dist/web/WebGPUHost.d.ts +13 -0
- package/dist/web/WebGPUHost.js +117 -36
- package/dist/web/audio.d.ts +2 -2
- package/dist/web/audio.js +1 -1
- package/dist/web/editorFonts.d.ts +4 -0
- package/dist/web/game.d.ts +1 -1
- package/dist/web/imageProjections2D.d.ts +2 -0
- package/dist/web/kit.d.ts +1 -0
- package/dist/web/kit.js +1 -0
- package/dist/web/play.d.ts +6 -1
- package/dist/web/play.js +4 -1
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -0
- package/dist/web/playTouch.d.ts +45 -0
- package/dist/web/playTouch.js +141 -0
- package/dist/web/playWidgets.d.ts +71 -0
- package/dist/web/playWidgets.js +431 -0
- package/dist/web/prepareSharedSubmission2D.js +9 -3
- package/dist/web/resources.d.ts +2 -0
- package/dist/web/sharedEffectShaders.d.ts +6 -2
- package/dist/web/sharedEffectShaders.js +23 -7
- package/dist/web/sharedSubmissionStorage2D.js +1 -1
- package/dist/web/sharedWebGL2Options.d.ts +3 -0
- package/dist/web/sharedWebGL2Options.js +8 -2
- package/dist/web/sharedWebGL2Shaders.d.ts +15 -2
- package/dist/web/sharedWebGL2Shaders.js +108 -14
- package/dist/web/sharedWebGPUOptions.d.ts +5 -1
- package/dist/web/sharedWebGPUOptions.js +6 -2
- package/dist/web/video.d.ts +1 -1
- package/dist/web/webgl2Native.d.ts +3 -1
- package/dist/web/webgl2Native.js +9 -5
- package/dist/web/webgl2Types.d.ts +18 -0
- package/dist/web/webgpuImageResidency.d.ts +5 -2
- package/dist/web/webgpuImageResidency.js +7 -3
- package/dist/web/webgpuRetentionPool.d.ts +2 -2
- package/dist/web/webgpuRetentionPool.js +2 -1
- package/dist/web/webgpuSharedPass.d.ts +1 -1
- package/dist/web/webgpuSharedPass.js +87 -5
- package/dist/web/webgpuSharedResolvePass.d.ts +1 -1
- package/dist/web/webgpuSharedResolvePass.js +9 -4
- package/dist/web/world3d/Audio3D.d.ts +18 -1
- package/dist/web/world3d/Audio3D.js +62 -3
- package/dist/web/world3d/BrowserPlay3D.d.ts +115 -2
- package/dist/web/world3d/BrowserPlay3D.js +448 -43
- package/dist/web/world3d/FlyControls3D.d.ts +4 -0
- package/dist/web/world3d/FlyControls3D.js +2 -0
- package/dist/web/world3d/FollowControls3D.d.ts +3 -0
- package/dist/web/world3d/FollowControls3D.js +2 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +3 -0
- package/dist/web/world3d/OrbitControls3D.js +2 -0
- package/dist/web/world3d/TransformControls3D.d.ts +5 -2
- package/dist/web/world3d/TransformControls3D.js +7 -4
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +3 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +2 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +2 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1 -0
- package/dist/web/world3d/World3DView.d.ts +3 -0
- package/dist/web/world3d/World3DView.js +2 -0
- package/dist/web/world3d/app3D.d.ts +7 -0
- package/dist/web/world3d/app3D.js +1 -0
- package/dist/web/world3d/assets3D.d.ts +1 -0
- package/dist/web/world3d/atmosphere3D.d.ts +9 -0
- package/dist/web/world3d/atmosphere3D.js +19 -4
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +2 -0
- package/dist/web/world3d/host3D.d.ts +1 -0
- package/dist/web/world3d/index.d.ts +4 -2
- package/dist/web/world3d/index.js +2 -1
- package/dist/web/world3d/loaders3D.d.ts +1 -0
- package/dist/web/world3d/markers3D.d.ts +4 -0
- package/dist/web/world3d/overlay3D.d.ts +19 -0
- package/dist/web/world3d/overlay3D.js +21 -4
- package/dist/web/world3d/post3D.d.ts +4 -0
- package/dist/web/world3d/post3D.js +3 -0
- package/dist/web/world3d/probe3D.d.ts +1 -0
- package/dist/web/world3d/stats3D.d.ts +3 -0
- package/dist/web/world3d/stats3D.js +1 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +5 -0
- package/dist/web/world3d/webgpu.d.ts +2 -0
- package/dist/web/world3d/webgpu.js +1 -0
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CubeTexture3D } from './Texture3D.js';
|
|
2
2
|
import type { TexturePixels3D } from './Texture3D.js';
|
|
3
|
+
/** The largest HDR image read. */
|
|
3
4
|
export declare const HDR3D_LIMITS: Readonly<{
|
|
4
5
|
readonly maxEdge: 16384;
|
|
5
6
|
readonly maxPixels: 67108864;
|
|
@@ -12,6 +13,7 @@ export interface HdrImage3D {
|
|
|
12
13
|
}
|
|
13
14
|
/** Decode a Radiance .hdr file (flat or run-length encoded, -Y +X orientation). */
|
|
14
15
|
export declare function parseRgbe3D(bytes: Uint8Array): HdrImage3D;
|
|
16
|
+
/** How an equirectangular image is turned into a cube: its size, exposure and brightest value. */
|
|
15
17
|
export interface EquirectOptions3D {
|
|
16
18
|
/** Edge of each cube face in texels. */
|
|
17
19
|
readonly size?: number;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { World3DError, requireCount3D } from './core3D.js';
|
|
6
6
|
import { linearToSrgb, srgbToLinear } from './math3D.js';
|
|
7
7
|
import { CubeTexture3D } from './Texture3D.js';
|
|
8
|
+
/** The largest HDR image read. */
|
|
8
9
|
export const HDR3D_LIMITS = Object.freeze({ maxEdge: 16384, maxPixels: 67108864 });
|
|
9
10
|
function fail(detail) {
|
|
10
11
|
throw new World3DError('WORLD3D_INPUT_INVALID', 'hdr: ' + detail);
|
|
@@ -2,6 +2,7 @@ import { type CustomShader3D } from './Material3D.js';
|
|
|
2
2
|
import { Mesh3D } from './Mesh3D.js';
|
|
3
3
|
import type { Object3D } from './Object3D.js';
|
|
4
4
|
import type { RigidBody3D } from './Physics3D.js';
|
|
5
|
+
/** How a jelly wobbles: its stiffness and damping, how far it squashes, how it reacts, and how it idles. */
|
|
5
6
|
export interface JellyOptions3D {
|
|
6
7
|
/** How many times per second the shape swings back and forth after a knock. Defaults to 3.5. */
|
|
7
8
|
readonly stiffness?: number;
|
|
@@ -71,5 +72,6 @@ export declare class Jelly3D {
|
|
|
71
72
|
/** Where the shader puts a world-space point, for tests and for attaching things to the surface. */
|
|
72
73
|
deform(out: Float32Array | Float64Array | number[], x: number, y: number, z: number): typeof out;
|
|
73
74
|
}
|
|
75
|
+
/** Makes an object squash, stretch and wobble like jelly as it moves. */
|
|
74
76
|
export declare function createJelly3D(target: Object3D, options?: JellyOptions3D): Jelly3D;
|
|
75
77
|
//# sourceMappingURL=Jelly3D.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompressedPixels3D, TextureColorSpace3D, TexturePixels3D } from './Texture3D.js';
|
|
2
|
+
/** What a KTX2 file holds: its format, size, levels and supercompression. */
|
|
2
3
|
export interface Ktx2Info3D {
|
|
3
4
|
/** Vulkan format number; 0 marks a Basis Universal payload. */
|
|
4
5
|
readonly vkFormat: number;
|
|
@@ -12,10 +13,12 @@ export interface Ktx2Info3D {
|
|
|
12
13
|
/** The complete file, for transcoders that parse the container themselves. */
|
|
13
14
|
readonly file: Uint8Array;
|
|
14
15
|
}
|
|
16
|
+
/** A transcoded KTX2 texture: its pixels and color space. */
|
|
15
17
|
export interface Ktx2Result3D {
|
|
16
18
|
readonly source: TexturePixels3D | CompressedPixels3D;
|
|
17
19
|
readonly colorSpace: TextureColorSpace3D;
|
|
18
20
|
}
|
|
21
|
+
/** How a KTX2 file is transcoded for the GPU in use. */
|
|
19
22
|
export interface Ktx2Options3D {
|
|
20
23
|
/** Convert supercompressed or unknown-format payloads, overriding built-in decompression when provided. */
|
|
21
24
|
readonly transcode?: (info: Ktx2Info3D) => Promise<Ktx2Result3D> | Ktx2Result3D;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ColorInput3D } from './Material3D.js';
|
|
2
2
|
import { Object3D } from './Object3D.js';
|
|
3
|
+
/** The kind of a light: ambient, hemisphere, directional, point or spot. */
|
|
3
4
|
export type LightType3D = 'ambient' | 'hemisphere' | 'directional' | 'point' | 'spot';
|
|
5
|
+
/** The most directional, point, tiled point and spot lights a scene lights, and the most shadows. */
|
|
4
6
|
export declare const LIGHT3D_LIMITS: Readonly<{
|
|
5
7
|
readonly maxDirectional: 4;
|
|
6
8
|
readonly maxPoint: 8;
|
|
@@ -9,6 +11,7 @@ export declare const LIGHT3D_LIMITS: Readonly<{
|
|
|
9
11
|
readonly maxSpot: 4;
|
|
10
12
|
readonly maxShadows: 4;
|
|
11
13
|
}>;
|
|
14
|
+
/** How a light casts shadows: its map size, biases, range, extent, softness and cascades. */
|
|
12
15
|
export interface LightShadow3D {
|
|
13
16
|
/** Edge of this light's square tile in the shared shadow atlas, in texels. */
|
|
14
17
|
mapSize: number;
|
|
@@ -33,21 +36,25 @@ export interface LightShadow3D {
|
|
|
33
36
|
/** Split distribution: 0 spaces cascades evenly, 1 logarithmically. */
|
|
34
37
|
cascadeLambda: number;
|
|
35
38
|
}
|
|
39
|
+
/** A light to make: its color and intensity, and whether it casts shadows. */
|
|
36
40
|
export interface LightOptions3D {
|
|
37
41
|
readonly color?: ColorInput3D;
|
|
38
42
|
readonly intensity?: number;
|
|
39
43
|
readonly castShadow?: boolean;
|
|
40
44
|
}
|
|
45
|
+
/** A point light to make: how far it reaches. */
|
|
41
46
|
export interface PointLightOptions3D extends LightOptions3D {
|
|
42
47
|
/** Distance at which the light fades to zero; 0 means unbounded inverse-square falloff. */
|
|
43
48
|
readonly range?: number;
|
|
44
49
|
}
|
|
50
|
+
/** A spot light to make: its cone's angle and soft edge. */
|
|
45
51
|
export interface SpotLightOptions3D extends PointLightOptions3D {
|
|
46
52
|
/** Half angle of the cone in radians. */
|
|
47
53
|
readonly angle?: number;
|
|
48
54
|
/** Fraction of the cone over which intensity falls off, in [0, 1]. */
|
|
49
55
|
readonly penumbra?: number;
|
|
50
56
|
}
|
|
57
|
+
/** A light in a scene: its kind and its shadow. */
|
|
51
58
|
export declare class Light3D extends Object3D {
|
|
52
59
|
readonly lightType: LightType3D;
|
|
53
60
|
readonly color: Float32Array<ArrayBuffer>;
|
|
@@ -70,6 +77,8 @@ export declare function createHemisphereLight3D(options?: LightOptions3D & {
|
|
|
70
77
|
}): Light3D;
|
|
71
78
|
/** Parallel rays, such as sunlight. Aim it with lookAt(). */
|
|
72
79
|
export declare function createDirectionalLight3D(options?: LightOptions3D): Light3D;
|
|
80
|
+
/** Makes a light that shines from a point in every direction. */
|
|
73
81
|
export declare function createPointLight3D(options?: PointLightOptions3D): Light3D;
|
|
82
|
+
/** Makes a light that shines from a point in a cone. */
|
|
74
83
|
export declare function createSpotLight3D(options?: SpotLightOptions3D): Light3D;
|
|
75
84
|
//# sourceMappingURL=Light3D.d.ts.map
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Z axis, matching cameras and glTF punctual lights. Colors are linear RGB.
|
|
4
4
|
import { setColor3D } from './Material3D.js';
|
|
5
5
|
import { Object3D } from './Object3D.js';
|
|
6
|
+
/** The most directional, point, tiled point and spot lights a scene lights, and the most shadows. */
|
|
6
7
|
export const LIGHT3D_LIMITS = Object.freeze({
|
|
7
8
|
maxDirectional: 4,
|
|
8
9
|
maxPoint: 8,
|
|
@@ -11,6 +12,7 @@ export const LIGHT3D_LIMITS = Object.freeze({
|
|
|
11
12
|
maxSpot: 4,
|
|
12
13
|
maxShadows: 4
|
|
13
14
|
});
|
|
15
|
+
/** A light in a scene: its kind and its shadow. */
|
|
14
16
|
export class Light3D extends Object3D {
|
|
15
17
|
lightType;
|
|
16
18
|
color = new Float32Array([1, 1, 1]);
|
|
@@ -78,11 +80,13 @@ export function createHemisphereLight3D(options = {}) {
|
|
|
78
80
|
export function createDirectionalLight3D(options = {}) {
|
|
79
81
|
return base(new Light3D('directional'), options);
|
|
80
82
|
}
|
|
83
|
+
/** Makes a light that shines from a point in every direction. */
|
|
81
84
|
export function createPointLight3D(options = {}) {
|
|
82
85
|
const light = base(new Light3D('point'), options);
|
|
83
86
|
light.range = options.range ?? 0;
|
|
84
87
|
return light;
|
|
85
88
|
}
|
|
89
|
+
/** Makes a light that shines from a point in a cone. */
|
|
86
90
|
export function createSpotLight3D(options = {}) {
|
|
87
91
|
const light = base(new Light3D('spot'), options);
|
|
88
92
|
light.range = options.range ?? 0;
|
|
@@ -35,6 +35,7 @@ export interface CustomShader3D {
|
|
|
35
35
|
/** Four vec4 parameters, written by the application (time, colors, thresholds). */
|
|
36
36
|
readonly uniforms: Float32Array;
|
|
37
37
|
}
|
|
38
|
+
/** Makes a material drawn by shaders of your own. */
|
|
38
39
|
export declare function createCustomShader3D(input: {
|
|
39
40
|
readonly key: string;
|
|
40
41
|
readonly glsl?: string;
|
|
@@ -45,12 +46,17 @@ export declare function createCustomShader3D(input: {
|
|
|
45
46
|
readonly wgslNormal?: string;
|
|
46
47
|
readonly uniforms?: ArrayLike<number>;
|
|
47
48
|
}): CustomShader3D;
|
|
49
|
+
/** How a material is lit: not at all, Lambert, Phong, physically based, toon, or by a matcap. */
|
|
48
50
|
export type Shading3D = 'unlit' | 'lambert' | 'phong' | 'standard' | 'toon' | 'matcap';
|
|
51
|
+
/** Which sides of a material's triangles are drawn. */
|
|
49
52
|
export type Side3D = 'front' | 'back' | 'double';
|
|
53
|
+
/** How a material's alpha is used: ignored, cut at a threshold, or blended. */
|
|
50
54
|
export type AlphaMode3D = 'opaque' | 'mask' | 'blend';
|
|
55
|
+
/** How a material's color mixes with what is behind it. */
|
|
51
56
|
export type Blending3D = 'normal' | 'additive' | 'multiply' | 'premultiplied';
|
|
52
57
|
/** A color as 0xRRGGBB sRGB hex or linear RGB components. */
|
|
53
58
|
export type ColorInput3D = number | readonly [number, number, number];
|
|
59
|
+
/** A material to make: its color and maps, its sides and alpha, its blending and depth, and its emission, normals and occlusion. */
|
|
54
60
|
export interface MaterialOptions3D {
|
|
55
61
|
readonly name?: string;
|
|
56
62
|
readonly color?: ColorInput3D;
|
|
@@ -76,10 +82,12 @@ export interface MaterialOptions3D {
|
|
|
76
82
|
readonly flatShading?: boolean;
|
|
77
83
|
readonly wireframe?: boolean;
|
|
78
84
|
}
|
|
85
|
+
/** A Phong material's specular color and shininess. */
|
|
79
86
|
export interface PhongMaterialOptions3D extends MaterialOptions3D {
|
|
80
87
|
readonly specular?: ColorInput3D;
|
|
81
88
|
readonly shininess?: number;
|
|
82
89
|
}
|
|
90
|
+
/** A physically based material's metalness and roughness, and how much the environment lights it. */
|
|
83
91
|
export interface StandardMaterialOptions3D extends MaterialOptions3D {
|
|
84
92
|
readonly metallic?: number;
|
|
85
93
|
readonly roughness?: number;
|
|
@@ -87,12 +95,14 @@ export interface StandardMaterialOptions3D extends MaterialOptions3D {
|
|
|
87
95
|
readonly metallicRoughnessMap?: Texture3D;
|
|
88
96
|
readonly environmentIntensity?: number;
|
|
89
97
|
}
|
|
98
|
+
/** A sprite material: whether sprites shrink with distance, and their rotation. */
|
|
90
99
|
export interface SpriteMaterialOptions3D extends MaterialOptions3D {
|
|
91
100
|
/** Keep a constant on-screen size regardless of distance. */
|
|
92
101
|
readonly sizeAttenuation?: boolean;
|
|
93
102
|
/** Rotation about the view axis in radians. */
|
|
94
103
|
readonly rotation?: number;
|
|
95
104
|
}
|
|
105
|
+
/** Writes a color into a float array as red, green and blue. */
|
|
96
106
|
export declare function setColor3D(out: Float32Array, input: ColorInput3D): Float32Array;
|
|
97
107
|
/**
|
|
98
108
|
* One material class carries the superset of surface parameters; `shading`
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// values are linear RGB; factories accept 0xRRGGBB sRGB hex for convenience.
|
|
4
4
|
import { Resource3D, World3DError } from './core3D.js';
|
|
5
5
|
import { colorFromHex } from './math3D.js';
|
|
6
|
+
/** Makes a material drawn by shaders of your own. */
|
|
6
7
|
export function createCustomShader3D(input) {
|
|
7
8
|
if (!input || typeof input.key !== 'string' || input.key.length === 0 || /[\s|/]/.test(input.key))
|
|
8
9
|
throw new World3DError('WORLD3D_INPUT_INVALID', 'shader key');
|
|
@@ -27,6 +28,7 @@ export function createCustomShader3D(input) {
|
|
|
27
28
|
uniforms
|
|
28
29
|
});
|
|
29
30
|
}
|
|
31
|
+
/** Writes a color into a float array as red, green and blue. */
|
|
30
32
|
export function setColor3D(out, input) {
|
|
31
33
|
if (typeof input === 'number')
|
|
32
34
|
colorFromHex(out, input);
|
|
@@ -2,11 +2,13 @@ import { Geometry3D } from './Geometry3D.js';
|
|
|
2
2
|
import { Material3D } from './Material3D.js';
|
|
3
3
|
import type { SpriteMaterialOptions3D } from './Material3D.js';
|
|
4
4
|
import { Object3D } from './Object3D.js';
|
|
5
|
+
/** The most bones, instances and materials a mesh has. */
|
|
5
6
|
export declare const MESH3D_LIMITS: Readonly<{
|
|
6
7
|
readonly maxBones: 1024;
|
|
7
8
|
readonly maxInstances: 1048576;
|
|
8
9
|
readonly maxMaterials: 64;
|
|
9
10
|
}>;
|
|
11
|
+
/** A bone of a skeleton. */
|
|
10
12
|
export declare class Bone3D extends Object3D {
|
|
11
13
|
constructor();
|
|
12
14
|
}
|
|
@@ -24,6 +26,7 @@ export declare class Skeleton3D {
|
|
|
24
26
|
/** Recompute skinning matrices once per frame id; later calls in the same frame are free. */
|
|
25
27
|
update(frame: number): void;
|
|
26
28
|
}
|
|
29
|
+
/** A geometry drawn with materials, with its morph weights and skeleton. */
|
|
27
30
|
export declare class Mesh3D extends Object3D {
|
|
28
31
|
#private;
|
|
29
32
|
/** Optional hook the render list calls once per frame before the mesh is culled and sorted. */
|
|
@@ -103,6 +106,7 @@ export declare class Sprite3D extends Mesh3D {
|
|
|
103
106
|
get worldBoundingSphere(): Float32Array;
|
|
104
107
|
clone(): this;
|
|
105
108
|
}
|
|
109
|
+
/** Makes a sprite: a picture that always faces the camera. */
|
|
106
110
|
export declare function createSprite3D(options?: SpriteMaterialOptions3D): Sprite3D;
|
|
107
111
|
export {};
|
|
108
112
|
//# sourceMappingURL=Mesh3D.d.ts.map
|
|
@@ -7,7 +7,9 @@ import { Material3D, createSpriteMaterial3D } from './Material3D.js';
|
|
|
7
7
|
import { box3Empty, box3ExpandByPoint, mat4Compose, mat4Copy, mat4Identity, mat4Invert, mat4Multiply, sphereFromBox, sphereTransform } from './math3D.js';
|
|
8
8
|
import { Object3D } from './Object3D.js';
|
|
9
9
|
import { createQuadGeometry3D } from './primitives3D.js';
|
|
10
|
+
/** The most bones, instances and materials a mesh has. */
|
|
10
11
|
export const MESH3D_LIMITS = Object.freeze({ maxBones: 1024, maxInstances: 1048576, maxMaterials: 64 });
|
|
12
|
+
/** A bone of a skeleton. */
|
|
11
13
|
export class Bone3D extends Object3D {
|
|
12
14
|
constructor() {
|
|
13
15
|
super('bone');
|
|
@@ -64,6 +66,7 @@ export class Skeleton3D {
|
|
|
64
66
|
this.version++;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
/** A geometry drawn with materials, with its morph weights and skeleton. */
|
|
67
70
|
export class Mesh3D extends Object3D {
|
|
68
71
|
geometry;
|
|
69
72
|
/** false leaves the mesh out of ray picking, as for effects whose drawn shape is not their geometry. */
|
|
@@ -153,7 +156,9 @@ export class Mesh3D extends Object3D {
|
|
|
153
156
|
if (this.skeleton)
|
|
154
157
|
return this.skinnedBounds();
|
|
155
158
|
// Compared as numbers: this runs for every mesh on every frame.
|
|
156
|
-
const geometry = this.geometry,
|
|
159
|
+
const geometry = this.geometry,
|
|
160
|
+
// A geometry whose points moved in place (cloth, a rope, a trail) has new bounds without a new structure.
|
|
161
|
+
version = geometry.version * 4294967296 + geometry.boundsVersion, world = this.worldVersion;
|
|
157
162
|
if (geometry !== this.#sphereGeometry || version !== this.#sphereVersion || world !== this.#sphereWorld) {
|
|
158
163
|
sphereTransform(this.#worldSphere, geometry.boundingSphere, this.matrixWorld);
|
|
159
164
|
this.#sphereGeometry = geometry;
|
|
@@ -212,6 +217,8 @@ export class InstancedMesh3D extends Mesh3D {
|
|
|
212
217
|
boundsScale = 1;
|
|
213
218
|
#boundsVersion = 0;
|
|
214
219
|
#boundsCount = -1;
|
|
220
|
+
#boundsGeometry = undefined;
|
|
221
|
+
#boundsShape = -1;
|
|
215
222
|
#instanceSphere = new Float32Array(4);
|
|
216
223
|
constructor(geometry, material, capacity, instanceColorSize = 3) {
|
|
217
224
|
super(geometry, material);
|
|
@@ -270,7 +277,11 @@ export class InstancedMesh3D extends Mesh3D {
|
|
|
270
277
|
/** Sphere enclosing every instance, in world space. */
|
|
271
278
|
get worldBoundingSphere() {
|
|
272
279
|
const sphere = this.#instanceSphere;
|
|
273
|
-
|
|
280
|
+
const shape = this.geometry.version * 4294967296 + this.geometry.boundsVersion;
|
|
281
|
+
if (this.#boundsVersion !== this.instanceVersion ||
|
|
282
|
+
this.#boundsCount !== this.count ||
|
|
283
|
+
this.#boundsGeometry !== this.geometry ||
|
|
284
|
+
this.#boundsShape !== shape) {
|
|
274
285
|
const base = this.geometry.boundingSphere, box = box3Empty(new Float32Array(6)), m = this.instanceMatrices;
|
|
275
286
|
let radius = 0;
|
|
276
287
|
for (let i = 0; i < this.count; i++) {
|
|
@@ -284,6 +295,8 @@ export class InstancedMesh3D extends Mesh3D {
|
|
|
284
295
|
this.localSphere[3] += radius;
|
|
285
296
|
this.#boundsVersion = this.instanceVersion;
|
|
286
297
|
this.#boundsCount = this.count;
|
|
298
|
+
this.#boundsGeometry = this.geometry;
|
|
299
|
+
this.#boundsShape = shape;
|
|
287
300
|
}
|
|
288
301
|
return sphereTransform(sphere, this.localSphere, this.matrixWorld);
|
|
289
302
|
}
|
|
@@ -317,6 +330,7 @@ export class Sprite3D extends Mesh3D {
|
|
|
317
330
|
return copy;
|
|
318
331
|
}
|
|
319
332
|
}
|
|
333
|
+
/** Makes a sprite: a picture that always faces the camera. */
|
|
320
334
|
export function createSprite3D(options = {}) {
|
|
321
335
|
return new Sprite3D(createSpriteMaterial3D(options));
|
|
322
336
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/** What meshopt data encodes: vertex attributes, triangles or indices. */
|
|
1
2
|
export type MeshoptMode3D = 'ATTRIBUTES' | 'TRIANGLES' | 'INDICES';
|
|
3
|
+
/** The filter meshopt data was encoded with. */
|
|
2
4
|
export type MeshoptFilter3D = 'NONE' | 'OCTAHEDRAL' | 'QUATERNION' | 'EXPONENTIAL';
|
|
5
|
+
/** The largest stride and count of meshopt data. */
|
|
3
6
|
export declare const MESHOPT3D_LIMITS: Readonly<{
|
|
4
7
|
readonly maxStride: 256;
|
|
5
8
|
readonly maxElements: 268435456;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// three post-decoding filters. It needs no WebAssembly and no dependency, so
|
|
6
6
|
// glTF files compressed this way load without a decoder hook.
|
|
7
7
|
import { World3DError } from './core3D.js';
|
|
8
|
+
/** The largest stride and count of meshopt data. */
|
|
8
9
|
export const MESHOPT3D_LIMITS = Object.freeze({ maxStride: 256, maxElements: 268435456 });
|
|
9
10
|
const bad = (detail) => new World3DError('WORLD3D_GLTF_INVALID', 'meshopt ' + detail);
|
|
10
11
|
/** Vertex codec: each byte of the element is stored as deltas against the previous element, in groups of sixteen. */
|
|
@@ -1,23 +1,48 @@
|
|
|
1
1
|
import { Geometry3D } from './Geometry3D.js';
|
|
2
2
|
import type { Object3D } from './Object3D.js';
|
|
3
|
+
import { HeightField3D } from './Terrain3D.js';
|
|
4
|
+
/** The most triangles, agents and grid cells navigation holds. */
|
|
3
5
|
export declare const NAVIGATION3D_LIMITS: Readonly<{
|
|
4
6
|
readonly maxTriangles: 1048576;
|
|
5
7
|
readonly maxAgents: 4096;
|
|
6
8
|
readonly maxGridCells: 16777216;
|
|
7
9
|
readonly maxCellReferences: 8388608;
|
|
8
10
|
}>;
|
|
11
|
+
/** A point on a navigation mesh as x, y and z. */
|
|
9
12
|
export type NavPoint3D = [number, number, number];
|
|
13
|
+
/** A navigation mesh to make: the steepest walkable slope, and how close vertices are welded. */
|
|
10
14
|
export interface NavMeshOptions3D {
|
|
11
15
|
/** Steepest walkable slope in radians. Defaults to 45 degrees. */
|
|
12
16
|
readonly slopeLimit?: number;
|
|
13
17
|
/** Corners closer than this are treated as one, which joins triangles that only touch. Defaults to 0.001. */
|
|
14
18
|
readonly weldTolerance?: number;
|
|
19
|
+
/** From a height field only: where its centre is in the world, `[x, z]`. Defaults to `[0, 0]`. */
|
|
20
|
+
readonly center?: readonly [number, number];
|
|
21
|
+
/** From a height field only: the world rectangle to cover, `{ x, z, width, depth }` from its -X, -Z corner. Defaults to the whole field. */
|
|
22
|
+
readonly region?: {
|
|
23
|
+
readonly x: number;
|
|
24
|
+
readonly z: number;
|
|
25
|
+
readonly width: number;
|
|
26
|
+
readonly depth: number;
|
|
27
|
+
};
|
|
28
|
+
/** From a height field only: the size of a cell of the mesh, in world units. Defaults to the field's own cell. */
|
|
29
|
+
readonly cellSize?: number;
|
|
30
|
+
/** From a height field only: circles `{ x, z, radius }` in the world left out, around rocks, trees and posts. */
|
|
31
|
+
readonly holes?: readonly {
|
|
32
|
+
readonly x: number;
|
|
33
|
+
readonly z: number;
|
|
34
|
+
readonly radius: number;
|
|
35
|
+
}[];
|
|
36
|
+
/** From a height field only: ground lower than this is left out, as under water. */
|
|
37
|
+
readonly minHeight?: number;
|
|
15
38
|
}
|
|
39
|
+
/** Where a point is on a navigation mesh: its triangle and the point itself. */
|
|
16
40
|
export interface NavLocation3D {
|
|
17
41
|
/** Index of the triangle the point lies on. */
|
|
18
42
|
readonly triangle: number;
|
|
19
43
|
readonly point: NavPoint3D;
|
|
20
44
|
}
|
|
45
|
+
/** How a path is found: the agent's radius, whether it follows the ground, and how far its ends may snap. */
|
|
21
46
|
export interface NavPathOptions3D {
|
|
22
47
|
/** Keeps the path this far from the mesh edges at corners, and rules out gaps narrower than twice this. */
|
|
23
48
|
readonly agentRadius?: number;
|
|
@@ -26,6 +51,7 @@ export interface NavPathOptions3D {
|
|
|
26
51
|
/** How far the start and end may lie from the mesh. Defaults to 2. */
|
|
27
52
|
readonly snapDistance?: number;
|
|
28
53
|
}
|
|
54
|
+
/** A path found on a navigation mesh: its points, whether it reaches the goal, and its length. */
|
|
29
55
|
export interface NavPath3D {
|
|
30
56
|
readonly points: NavPoint3D[];
|
|
31
57
|
/** False when the end could not be reached and the path stops at the closest reachable place. */
|
|
@@ -33,6 +59,7 @@ export interface NavPath3D {
|
|
|
33
59
|
/** Length of the path. */
|
|
34
60
|
readonly length: number;
|
|
35
61
|
}
|
|
62
|
+
/** The walkable surface of a level: find paths, nearest points and ray hits on it, and set the cost of its areas. */
|
|
36
63
|
export declare class NavMesh3D {
|
|
37
64
|
#private;
|
|
38
65
|
/** Welded corner positions, three floats each. */
|
|
@@ -99,10 +126,11 @@ export declare class NavMesh3D {
|
|
|
99
126
|
* meshes are merged with their world transforms. Faces steeper than
|
|
100
127
|
* `slopeLimit` and faces pointing down are left out.
|
|
101
128
|
*/
|
|
102
|
-
export declare function createNavMesh3D(source: Geometry3D | Object3D | {
|
|
129
|
+
export declare function createNavMesh3D(source: Geometry3D | Object3D | HeightField3D | {
|
|
103
130
|
readonly positions: ArrayLike<number>;
|
|
104
131
|
readonly indices?: ArrayLike<number>;
|
|
105
132
|
}, options?: NavMeshOptions3D): NavMesh3D;
|
|
133
|
+
/** An agent to add: where it starts, its radius, speed and acceleration, and the node it moves. */
|
|
106
134
|
export interface NavAgentOptions3D {
|
|
107
135
|
readonly position: ArrayLike<number>;
|
|
108
136
|
readonly radius?: number;
|
|
@@ -112,8 +140,14 @@ export interface NavAgentOptions3D {
|
|
|
112
140
|
readonly acceleration?: number;
|
|
113
141
|
/** Scene node moved with the agent; it must not have a transformed parent. */
|
|
114
142
|
readonly node?: Object3D;
|
|
143
|
+
/**
|
|
144
|
+
* Turn the node to face the way the agent walks, about the vertical axis, at most this many radians per second; its
|
|
145
|
+
* local -Z is its front. Undefined (the default) leaves the node's turning to the game; Infinity turns at once.
|
|
146
|
+
*/
|
|
147
|
+
readonly turnSpeed?: number;
|
|
115
148
|
readonly userData?: unknown;
|
|
116
149
|
}
|
|
150
|
+
/** An agent of a crowd: where it is and how it moves; give it a target, or stop it. */
|
|
117
151
|
export declare class NavAgent3D {
|
|
118
152
|
readonly position: NavPoint3D;
|
|
119
153
|
readonly velocity: NavPoint3D;
|
|
@@ -121,6 +155,10 @@ export declare class NavAgent3D {
|
|
|
121
155
|
speed: number;
|
|
122
156
|
acceleration: number;
|
|
123
157
|
node: Object3D | undefined;
|
|
158
|
+
/** Radians per second the node turns to face the way it walks; undefined leaves its turning to the game. */
|
|
159
|
+
turnSpeed: number | undefined;
|
|
160
|
+
/** The angle about the vertical axis the node faces, in radians, 0 facing -Z; kept while `turnSpeed` is set. */
|
|
161
|
+
heading: number;
|
|
124
162
|
userData: unknown;
|
|
125
163
|
/** True once the agent has reached its target, or has none. */
|
|
126
164
|
arrived: boolean;
|
|
@@ -156,7 +194,9 @@ export declare class NavCrowd3D {
|
|
|
156
194
|
/** Advance every agent by `deltaSeconds`. */
|
|
157
195
|
update(deltaSeconds: number): void;
|
|
158
196
|
}
|
|
197
|
+
/** Makes a crowd of agents that move along a navigation mesh and keep apart. */
|
|
159
198
|
export declare function createNavCrowd3D(navMesh: NavMesh3D): NavCrowd3D;
|
|
199
|
+
/** How a grid path is found: whether it moves diagonally, and how many cells it visits at most. */
|
|
160
200
|
export interface GridPathOptions3D {
|
|
161
201
|
/** Allow diagonal steps (never cutting a blocked corner). Defaults to true. */
|
|
162
202
|
readonly diagonal?: boolean;
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { World3DError, requireFinite3D, requirePositive3D } from './core3D.js';
|
|
9
9
|
import { Geometry3D, createGeometry3D } from './Geometry3D.js';
|
|
10
10
|
import { createMeshShape3D } from './PhysicsMesh3D.js';
|
|
11
|
+
import { HeightField3D } from './Terrain3D.js';
|
|
12
|
+
/** The most triangles, agents and grid cells navigation holds. */
|
|
11
13
|
export const NAVIGATION3D_LIMITS = Object.freeze({
|
|
12
14
|
maxTriangles: 1048576,
|
|
13
15
|
maxAgents: 4096,
|
|
@@ -66,6 +68,7 @@ class Heap {
|
|
|
66
68
|
return undefined;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
71
|
+
/** The walkable surface of a level: find paths, nearest points and ray hits on it, and set the cost of its areas. */
|
|
69
72
|
export class NavMesh3D {
|
|
70
73
|
/** Welded corner positions, three floats each. */
|
|
71
74
|
vertices;
|
|
@@ -668,6 +671,8 @@ export class NavMesh3D {
|
|
|
668
671
|
* `slopeLimit` and faces pointing down are left out.
|
|
669
672
|
*/
|
|
670
673
|
export function createNavMesh3D(source, options = {}) {
|
|
674
|
+
if (source instanceof HeightField3D)
|
|
675
|
+
return heightFieldNavMesh(source, options);
|
|
671
676
|
if (source instanceof Geometry3D || (typeof source === 'object' && source !== null && 'traverse' in source)) {
|
|
672
677
|
const shape = createMeshShape3D(source);
|
|
673
678
|
return new NavMesh3D(shape.positions, shape.indices, options);
|
|
@@ -676,6 +681,54 @@ export function createNavMesh3D(source, options = {}) {
|
|
|
676
681
|
throw new World3DError('WORLD3D_INPUT_INVALID', 'navigation source');
|
|
677
682
|
return new NavMesh3D(source.positions, source.indices, options);
|
|
678
683
|
}
|
|
684
|
+
/** A grid of two triangles a cell over the ground of a height field, less the holes and what lies too low. */
|
|
685
|
+
function heightFieldNavMesh(field, options) {
|
|
686
|
+
const [cx, cz] = options.center ?? [0, 0];
|
|
687
|
+
requireFinite3D(cx, 'center');
|
|
688
|
+
requireFinite3D(cz, 'center');
|
|
689
|
+
const region = options.region ?? {
|
|
690
|
+
x: cx - field.width / 2,
|
|
691
|
+
z: cz - field.depth / 2,
|
|
692
|
+
width: field.width,
|
|
693
|
+
depth: field.depth
|
|
694
|
+
};
|
|
695
|
+
const x0 = requireFinite3D(region.x, 'region'), z0 = requireFinite3D(region.z, 'region'), width = requirePositive3D(region.width, 'region'), depth = requirePositive3D(region.depth, 'region'), cell = requirePositive3D(options.cellSize ?? Math.min(field.cellWidth, field.cellDepth), 'cellSize'), floor = options.minHeight === undefined ? -Infinity : requireFinite3D(options.minHeight, 'minHeight');
|
|
696
|
+
const holes = (options.holes ?? []).map(hole => [
|
|
697
|
+
requireFinite3D(hole.x, 'hole'),
|
|
698
|
+
requireFinite3D(hole.z, 'hole'),
|
|
699
|
+
requirePositive3D(hole.radius, 'hole')
|
|
700
|
+
]);
|
|
701
|
+
const columns = Math.ceil(width / cell - 1e-9), rows = Math.ceil(depth / cell - 1e-9);
|
|
702
|
+
if (columns * rows * 2 > NAVIGATION3D_LIMITS.maxTriangles)
|
|
703
|
+
throw new World3DError('WORLD3D_BUDGET', 'navigation triangles');
|
|
704
|
+
// Corners clamp to the field: a region past its edge stops at the edge.
|
|
705
|
+
const halfW = field.width / 2, halfD = field.depth / 2, positions = new Float32Array((columns + 1) * (rows + 1) * 3), open = new Uint8Array((columns + 1) * (rows + 1));
|
|
706
|
+
for (let row = 0; row <= rows; row++)
|
|
707
|
+
for (let column = 0; column <= columns; column++) {
|
|
708
|
+
const x = x0 + Math.min(column * cell, width), z = z0 + Math.min(row * cell, depth), lx = Math.max(-halfW, Math.min(halfW, x - cx)), lz = Math.max(-halfD, Math.min(halfD, z - cz)), y = field.heightAt(lx, lz), i = row * (columns + 1) + column;
|
|
709
|
+
positions[i * 3] = lx + cx;
|
|
710
|
+
positions[i * 3 + 1] = y;
|
|
711
|
+
positions[i * 3 + 2] = lz + cz;
|
|
712
|
+
open[i] =
|
|
713
|
+
y >= floor && holes.every(([hx, hz, r]) => (lx + cx - hx) ** 2 + (lz + cz - hz) ** 2 > r * r) ? 1 : 0;
|
|
714
|
+
}
|
|
715
|
+
const indices = [];
|
|
716
|
+
const add = (a, b, c) => {
|
|
717
|
+
if (open[a] && open[b] && open[c])
|
|
718
|
+
indices.push(a, b, c);
|
|
719
|
+
};
|
|
720
|
+
for (let row = 0; row < rows; row++)
|
|
721
|
+
for (let column = 0; column < columns; column++) {
|
|
722
|
+
const a = row * (columns + 1) + column, b = a + columns + 1;
|
|
723
|
+
// Counter-clockwise seen from above: (x, z), (x, z + 1), (x + 1, z), then (x + 1, z), (x, z + 1), (x + 1, z + 1).
|
|
724
|
+
add(a, b, a + 1);
|
|
725
|
+
add(a + 1, b, b + 1);
|
|
726
|
+
}
|
|
727
|
+
if (indices.length === 0)
|
|
728
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'no walkable ground in the region');
|
|
729
|
+
return new NavMesh3D(positions, indices, options);
|
|
730
|
+
}
|
|
731
|
+
/** An agent of a crowd: where it is and how it moves; give it a target, or stop it. */
|
|
679
732
|
export class NavAgent3D {
|
|
680
733
|
position = [0, 0, 0];
|
|
681
734
|
velocity = [0, 0, 0];
|
|
@@ -683,6 +736,10 @@ export class NavAgent3D {
|
|
|
683
736
|
speed;
|
|
684
737
|
acceleration;
|
|
685
738
|
node;
|
|
739
|
+
/** Radians per second the node turns to face the way it walks; undefined leaves its turning to the game. */
|
|
740
|
+
turnSpeed;
|
|
741
|
+
/** The angle about the vertical axis the node faces, in radians, 0 facing -Z; kept while `turnSpeed` is set. */
|
|
742
|
+
heading = 0;
|
|
686
743
|
userData;
|
|
687
744
|
/** True once the agent has reached its target, or has none. */
|
|
688
745
|
arrived = true;
|
|
@@ -699,6 +756,9 @@ export class NavAgent3D {
|
|
|
699
756
|
this.speed = requirePositive3D(options.speed ?? 3.5, 'agent speed');
|
|
700
757
|
this.acceleration = requirePositive3D(options.acceleration ?? 20, 'agent acceleration');
|
|
701
758
|
this.node = options.node;
|
|
759
|
+
if (options.turnSpeed !== undefined)
|
|
760
|
+
this.turnSpeed =
|
|
761
|
+
options.turnSpeed === Infinity ? Infinity : requirePositive3D(options.turnSpeed, 'agent turn speed');
|
|
702
762
|
this.userData = options.userData;
|
|
703
763
|
}
|
|
704
764
|
/** Walk to a point; the path is worked out on the next crowd update. */
|
|
@@ -758,10 +818,21 @@ export class NavCrowd3D {
|
|
|
758
818
|
if (index >= 0)
|
|
759
819
|
this.agents.splice(index, 1);
|
|
760
820
|
}
|
|
761
|
-
sync(agent) {
|
|
821
|
+
sync(agent, dt = 0) {
|
|
762
822
|
const node = agent.node;
|
|
763
823
|
if (node) {
|
|
764
824
|
node.position.set(agent.position);
|
|
825
|
+
const turn = agent.turnSpeed, vx = agent.velocity[0], vz = agent.velocity[2];
|
|
826
|
+
// Standing still, or nearly, keeps the way it faced.
|
|
827
|
+
if (turn !== undefined && dt > 0 && vx * vx + vz * vz > 1e-4) {
|
|
828
|
+
const wanted = Math.atan2(-vx, -vz);
|
|
829
|
+
let delta = wanted - agent.heading;
|
|
830
|
+
delta -= Math.round(delta / (2 * Math.PI)) * 2 * Math.PI;
|
|
831
|
+
const most = turn * dt;
|
|
832
|
+
agent.heading += Math.abs(delta) <= most ? delta : Math.sign(delta) * most;
|
|
833
|
+
agent.heading -= Math.round(agent.heading / (2 * Math.PI)) * 2 * Math.PI;
|
|
834
|
+
node.setQuaternion(0, Math.sin(agent.heading / 2), 0, Math.cos(agent.heading / 2));
|
|
835
|
+
}
|
|
765
836
|
node.markTransformDirty();
|
|
766
837
|
}
|
|
767
838
|
}
|
|
@@ -891,9 +962,10 @@ export class NavCrowd3D {
|
|
|
891
962
|
}
|
|
892
963
|
}
|
|
893
964
|
for (const agent of agents)
|
|
894
|
-
this.sync(agent);
|
|
965
|
+
this.sync(agent, dt);
|
|
895
966
|
}
|
|
896
967
|
}
|
|
968
|
+
/** Makes a crowd of agents that move along a navigation mesh and keep apart. */
|
|
897
969
|
export function createNavCrowd3D(navMesh) {
|
|
898
970
|
return new NavCrowd3D(navMesh);
|
|
899
971
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
/** What kind of node an object is. */
|
|
1
2
|
export type Object3DKind = 'object' | 'scene' | 'mesh' | 'camera' | 'light' | 'bone';
|
|
3
|
+
/** How deep a scene nests, how many children a node has, and how long a name is, at most. */
|
|
2
4
|
export declare const WORLD3D_LIMITS: Readonly<{
|
|
3
5
|
readonly maxDepth: 256;
|
|
4
6
|
readonly maxChildren: 65536;
|
|
5
7
|
readonly maxNameLength: 256;
|
|
6
8
|
}>;
|
|
9
|
+
/** A node of a 3D scene: its children, place, rotation and scale, and calls that move and find nodes. */
|
|
7
10
|
export declare class Object3D {
|
|
8
11
|
#private;
|
|
9
12
|
readonly id: number;
|
|
@@ -24,6 +27,13 @@ export declare class Object3D {
|
|
|
24
27
|
castShadow: boolean;
|
|
25
28
|
receiveShadow: boolean;
|
|
26
29
|
frustumCulled: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A mesh further from the camera than this, in world units, from the camera to the near side of its bounds, is not
|
|
32
|
+
* drawn and casts no shadow: for grass, trees and props that are too small to see far off. Infinity (the default)
|
|
33
|
+
* keeps it at any distance. For a near and a far version of the same thing, use `Lod3D`. Not written by
|
|
34
|
+
* `serializeScene3D`.
|
|
35
|
+
*/
|
|
36
|
+
cullDistance: number;
|
|
27
37
|
/** Free-form application data; never read by the engine. */
|
|
28
38
|
userData: Record<string, unknown>;
|
|
29
39
|
constructor(kind?: Object3DKind);
|
|
@@ -76,6 +86,7 @@ export declare class Object3D {
|
|
|
76
86
|
clone(recursive?: boolean): this;
|
|
77
87
|
protected copyFrom(source: this): void;
|
|
78
88
|
}
|
|
89
|
+
/** Fog that fades a scene into a color: linearly between two distances, or exponentially by a density. */
|
|
79
90
|
export type Fog3D = {
|
|
80
91
|
readonly kind: 'linear';
|
|
81
92
|
readonly color: readonly [number, number, number];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// nothing per frame.
|
|
5
5
|
import { World3DError, allocateId3D } from './core3D.js';
|
|
6
6
|
import { mat4Compose, mat4Copy, mat4Decompose, mat4Identity, mat4Invert, mat4LookAt, mat4Multiply, quatFromAxisAngle, quatFromEuler, quatFromRotationMatrix, quatMultiply, quatNormalize, vec3TransformMat4 } from './math3D.js';
|
|
7
|
+
/** How deep a scene nests, how many children a node has, and how long a name is, at most. */
|
|
7
8
|
export const WORLD3D_LIMITS = Object.freeze({
|
|
8
9
|
maxDepth: 256,
|
|
9
10
|
maxChildren: 65536,
|
|
@@ -13,6 +14,7 @@ const UP = new Float32Array([0, 1, 0]);
|
|
|
13
14
|
const scratchMatrix = new Float32Array(16);
|
|
14
15
|
const scratchVector = new Float32Array(3);
|
|
15
16
|
const scratchQuat = new Float32Array(4);
|
|
17
|
+
/** A node of a 3D scene: its children, place, rotation and scale, and calls that move and find nodes. */
|
|
16
18
|
export class Object3D {
|
|
17
19
|
id = allocateId3D();
|
|
18
20
|
kind;
|
|
@@ -32,6 +34,13 @@ export class Object3D {
|
|
|
32
34
|
castShadow = false;
|
|
33
35
|
receiveShadow = true;
|
|
34
36
|
frustumCulled = true;
|
|
37
|
+
/**
|
|
38
|
+
* A mesh further from the camera than this, in world units, from the camera to the near side of its bounds, is not
|
|
39
|
+
* drawn and casts no shadow: for grass, trees and props that are too small to see far off. Infinity (the default)
|
|
40
|
+
* keeps it at any distance. For a near and a far version of the same thing, use `Lod3D`. Not written by
|
|
41
|
+
* `serializeScene3D`.
|
|
42
|
+
*/
|
|
43
|
+
cullDistance = Infinity;
|
|
35
44
|
/** Free-form application data; never read by the engine. */
|
|
36
45
|
userData = {};
|
|
37
46
|
#parent;
|
|
@@ -278,6 +287,7 @@ export class Object3D {
|
|
|
278
287
|
this.castShadow = source.castShadow;
|
|
279
288
|
this.receiveShadow = source.receiveShadow;
|
|
280
289
|
this.frustumCulled = source.frustumCulled;
|
|
290
|
+
this.cullDistance = source.cullDistance;
|
|
281
291
|
this.userData = { ...source.userData };
|
|
282
292
|
this.#localDirty = true;
|
|
283
293
|
}
|