@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
|
@@ -26,6 +26,23 @@ const TINT = `fn tint(value: vec4<f32>, light: vec4<f32>, dark: vec3<f32>, opaci
|
|
|
26
26
|
return vec4<f32>(factor * (v * draw.materialLight.rgb + (vec3<f32>(a) - v) * draw.materialDark.rgb), factor * a);
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
|
+
/**
|
|
30
|
+
* What a draw writes to its target: the linear premultiplied colour to a target that mixes light, or, to one that
|
|
31
|
+
* mixes the stored codes as a 2D canvas does, the colour encoded and then multiplied by its alpha. Light added with
|
|
32
|
+
* no alpha, as an additive draw may give, is encoded as it is.
|
|
33
|
+
*/
|
|
34
|
+
const finished = (srgb) => srgb
|
|
35
|
+
? `fn finished(c: vec4<f32>) -> vec4<f32> {
|
|
36
|
+
let a = clamp(c.a, 0.0, 1.0);
|
|
37
|
+
var u = c.rgb; if (a > 0.0) { u = c.rgb / a; }
|
|
38
|
+
u = clamp(u, vec3<f32>(0.0), vec3<f32>(1.0));
|
|
39
|
+
let e = select(12.92 * u, 1.055 * pow(u, vec3<f32>(1.0 / 2.4)) - vec3<f32>(0.055), u > vec3<f32>(0.0031308));
|
|
40
|
+
if (a > 0.0) { return vec4<f32>(a * e, a); }
|
|
41
|
+
return vec4<f32>(e, a);
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
: `fn finished(c: vec4<f32>) -> vec4<f32> { return c; }
|
|
45
|
+
`;
|
|
29
46
|
// A draw without a region has no region table to read.
|
|
30
47
|
const SOLID = BLOCK +
|
|
31
48
|
TINT +
|
|
@@ -40,7 +57,9 @@ const SOLID = BLOCK +
|
|
|
40
57
|
1.0 - 2.0 * position.y / draw.viewport.y, 0.0, 1.0);
|
|
41
58
|
result.uv = uv; result.light = light; result.dark = dark; result.opacity = slotOpacity.y; return result;
|
|
42
59
|
}
|
|
43
|
-
@fragment fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
60
|
+
@fragment fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
61
|
+
return finished(tint(vec4<f32>(1.0), input.light, input.dark, input.opacity));
|
|
62
|
+
}
|
|
44
63
|
`;
|
|
45
64
|
// The vertex stage of a sampled draw reads its region from the bound window of the region table, three
|
|
46
65
|
// vec4<u32> for each of 341 regions, and hands it to every fragment of the triangle unchanged. The row names
|
|
@@ -86,6 +105,9 @@ const pages = (paged) => `@group(0) @binding(1) var page0: texture_2d<f32>;
|
|
|
86
105
|
${paged ? [1, 2, 3, 4, 5, 6, 7].map(unit => `@group(0) @binding(${2 + unit}) var page${unit}: texture_2d<f32>;`).join('\n') + '\n' : ''}fn pageLoad(unit: u32, at: vec2<i32>) -> vec4<f32> {
|
|
87
106
|
${paged ? units(page => `textureLoad(${page}, at, 0)`) : ' return textureLoad(page0, at, 0);'}
|
|
88
107
|
}
|
|
108
|
+
fn levelLoad(unit: u32, at: vec2<i32>, level: i32) -> vec4<f32> {
|
|
109
|
+
${paged ? units(page => `textureLoad(${page}, at, level)`) : ' return textureLoad(page0, at, level);'}
|
|
110
|
+
}
|
|
89
111
|
fn pageSample(unit: u32, at: vec2<f32>) -> vec4<f32> {
|
|
90
112
|
${paged ? units(page => `textureSampleLevel(${page}, pageSampler, at, 0.0)`) : ' return textureSampleLevel(page0, pageSampler, at, 0.0);'}
|
|
91
113
|
}
|
|
@@ -144,7 +166,67 @@ fn sampled(input: VertexOutput) -> vec4<f32> {
|
|
|
144
166
|
return pageSample(input.page.x, (vec2<f32>(input.contentOrigin.zw) + packed) / pageSize)
|
|
145
167
|
* (coverage.x * coverage.y);
|
|
146
168
|
}
|
|
147
|
-
|
|
169
|
+
// A draw whose material asks for smaller copies reads them when it is drawn smaller than its texels, by the
|
|
170
|
+
// same rules as the WebGL2 Host: see MIPMAPPED there. Its texels are loaded, never filtered by a sampler.
|
|
171
|
+
fn levelPage(q: vec2<f32>, level: i32, modes: vec2<u32>, input: VertexOutput) -> vec4<f32> {
|
|
172
|
+
let full = vec2<i32>(input.page.yz);
|
|
173
|
+
let size = max(vec2<i32>(1), full >> vec2<u32>(u32(level)));
|
|
174
|
+
let shifted = q * vec2<f32>(size) / vec2<f32>(full) - vec2<f32>(0.5);
|
|
175
|
+
let base = vec2<i32>(floor(shifted)); let w = fract(shifted);
|
|
176
|
+
var taps: array<vec4<f32>, 4>;
|
|
177
|
+
for (var i = 0; i < 4; i++) {
|
|
178
|
+
let at = base + vec2<i32>(i & 1, i >> 1u);
|
|
179
|
+
taps[i] = levelLoad(input.page.x, vec2<i32>(addressed(at.x, size.x, modes.x), addressed(at.y, size.y, modes.y)), level);
|
|
180
|
+
}
|
|
181
|
+
return mix(mix(taps[0], taps[1], w.x), mix(taps[2], taps[3], w.x), w.y);
|
|
182
|
+
}
|
|
183
|
+
fn levelRegionTap(logical: vec2<i32>, level: i32, input: VertexOutput) -> vec4<f32> {
|
|
184
|
+
let shift = vec2<u32>(u32(level));
|
|
185
|
+
let extent = vec2<i32>(input.logicalTrim.xy) >> shift;
|
|
186
|
+
let index = clamp(logical, vec2<i32>(0), extent - vec2<i32>(1));
|
|
187
|
+
let local = index - (vec2<i32>(input.logicalTrim.zw) >> shift);
|
|
188
|
+
let size = vec2<i32>(input.contentOrigin.xy) >> shift;
|
|
189
|
+
if (any(local < vec2<i32>(0)) || any(local >= size)) { return vec4<f32>(0.0); }
|
|
190
|
+
var packed = local;
|
|
191
|
+
switch input.quarterTurn {
|
|
192
|
+
case 1u: { packed = vec2<i32>(size.y - 1 - local.y, local.x); }
|
|
193
|
+
case 2u: { packed = size - vec2<i32>(1) - local; }
|
|
194
|
+
case 3u: { packed = vec2<i32>(local.y, size.x - 1 - local.x); }
|
|
195
|
+
default: {}
|
|
196
|
+
}
|
|
197
|
+
return levelLoad(input.page.x, (vec2<i32>(input.contentOrigin.zw) >> shift) + packed, level);
|
|
198
|
+
}
|
|
199
|
+
fn atLevel(input: VertexOutput, level: i32) -> vec4<f32> {
|
|
200
|
+
if (draw.domain.w == 1u) { return levelPage(input.uv * vec2<f32>(input.page.yz), level, draw.samplerPolicy.xy, input); }
|
|
201
|
+
let extent = vec2<f32>(input.logicalTrim.xy);
|
|
202
|
+
let q = clamp(input.uv * extent, vec2<f32>(0.0), extent);
|
|
203
|
+
if (draw.domain.z == 1u) { return levelPage(q, level, vec2<u32>(0u), input); }
|
|
204
|
+
let shifted = q / f32(1 << u32(level)) - vec2<f32>(0.5);
|
|
205
|
+
let base = vec2<i32>(floor(shifted)); let w = fract(shifted);
|
|
206
|
+
return mix(mix(levelRegionTap(base, level, input), levelRegionTap(base + vec2<i32>(1, 0), level, input), w.x),
|
|
207
|
+
mix(levelRegionTap(base + vec2<i32>(0, 1), level, input), levelRegionTap(base + vec2<i32>(1, 1), level, input), w.x), w.y);
|
|
208
|
+
}
|
|
209
|
+
fn mipmapped(top: vec4<f32>, input: VertexOutput, rho: f32) -> vec4<f32> {
|
|
210
|
+
let deepest = i32(draw.domain.y);
|
|
211
|
+
let lod = clamp(log2(max(rho, 1e-6)), 0.0, f32(deepest));
|
|
212
|
+
if (lod <= 0.0) { return top; }
|
|
213
|
+
let level = i32(floor(lod));
|
|
214
|
+
let blend = lod - f32(level);
|
|
215
|
+
var near = top;
|
|
216
|
+
if (level > 0) { near = atLevel(input, level); }
|
|
217
|
+
if (level >= deepest || blend == 0.0) { return near; }
|
|
218
|
+
return mix(near, atLevel(input, level + 1), blend);
|
|
219
|
+
}
|
|
220
|
+
@fragment fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
221
|
+
// Derivatives are taken here, where every fragment of the draw runs: the block is the same for all of them.
|
|
222
|
+
var extent = vec2<f32>(input.logicalTrim.xy);
|
|
223
|
+
if (draw.domain.w == 1u) { extent = vec2<f32>(input.page.yz); }
|
|
224
|
+
let texels = input.uv * extent;
|
|
225
|
+
let rho = max(length(dpdx(texels)), length(dpdy(texels)));
|
|
226
|
+
var value = sampled(input);
|
|
227
|
+
if (draw.domain.x == 1u) { value = mipmapped(value, input, rho); }
|
|
228
|
+
return finished(tint(value, input.light, input.dark, input.opacity));
|
|
229
|
+
}
|
|
148
230
|
`;
|
|
149
231
|
function blendState(blend) {
|
|
150
232
|
const alpha = { operation: 'add', srcFactor: 'one', dstFactor: 'one-minus-src-alpha' };
|
|
@@ -176,9 +258,9 @@ function blendState(blend) {
|
|
|
176
258
|
/** The pipelines of a draw without a region, of a batch of one page, and of a batch of several pages. */
|
|
177
259
|
export const SHARED_PIPELINE_KINDS = ['solid', 'sampled', 'paged'];
|
|
178
260
|
/** All shaders and promises are immediately owned by the Host's captured startup boundaries. */
|
|
179
|
-
export function createSharedWebGPUPipeline(shader, pipeline, kind, blend) {
|
|
261
|
+
export function createSharedWebGPUPipeline(shader, pipeline, kind, blend, srgb = false) {
|
|
180
262
|
const module = shader({
|
|
181
|
-
code: kind === 'solid' ? SOLID : header(kind === 'paged') + pages(kind === 'paged') + SAMPLED
|
|
263
|
+
code: finished(srgb) + (kind === 'solid' ? SOLID : header(kind === 'paged') + pages(kind === 'paged') + SAMPLED)
|
|
182
264
|
});
|
|
183
265
|
return pipeline({
|
|
184
266
|
layout: 'auto',
|
|
@@ -202,7 +284,7 @@ export function createSharedWebGPUPipeline(shader, pipeline, kind, blend) {
|
|
|
202
284
|
fragment: {
|
|
203
285
|
module,
|
|
204
286
|
entryPoint: 'fragmentMain',
|
|
205
|
-
targets: [{ format: 'rgba8unorm-srgb', writeMask: 15, blend: blendState(blend) }]
|
|
287
|
+
targets: [{ format: srgb ? 'rgba8unorm' : 'rgba8unorm-srgb', writeMask: 15, blend: blendState(blend) }]
|
|
206
288
|
},
|
|
207
289
|
primitive: { topology: 'triangle-list', frontFace: 'ccw', cullMode: 'none', unclippedDepth: false },
|
|
208
290
|
multisample: { count: 1, alphaToCoverageEnabled: false }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Integer target loads and one explicit output transfer; the canvas view is ordinary UNORM. */
|
|
2
|
-
export declare function createSharedResolvePipeline(shader: (d: GPUShaderModuleDescriptor) => GPUShaderModule, pipeline: (d: GPURenderPipelineDescriptor) => Promise<GPURenderPipeline>, format: 'rgba8unorm' | 'bgra8unorm', opaque: boolean): Promise<GPURenderPipeline>;
|
|
2
|
+
export declare function createSharedResolvePipeline(shader: (d: GPUShaderModuleDescriptor) => GPUShaderModule, pipeline: (d: GPURenderPipelineDescriptor) => Promise<GPURenderPipeline>, format: 'rgba8unorm' | 'bgra8unorm', opaque: boolean, srgb?: boolean): Promise<GPURenderPipeline>;
|
|
3
3
|
//# sourceMappingURL=webgpuSharedResolvePass.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Integer target loads and one explicit output transfer; the canvas view is ordinary UNORM. */
|
|
2
|
-
export function createSharedResolvePipeline(shader, pipeline, format, opaque) {
|
|
2
|
+
export function createSharedResolvePipeline(shader, pipeline, format, opaque, srgb = false) {
|
|
3
3
|
const module = shader({
|
|
4
4
|
code: `@group(0) @binding(0) var workingTexture: texture_2d<f32>;
|
|
5
5
|
fn encoded(c: vec3<f32>) -> vec3<f32> {
|
|
@@ -13,9 +13,14 @@ fn encoded(c: vec3<f32>) -> vec3<f32> {
|
|
|
13
13
|
let value = textureLoad(workingTexture, vec2<i32>(position.xy), 0);
|
|
14
14
|
let a = clamp(value.a, 0.0, 1.0); let c = clamp(value.rgb, vec3<f32>(0.0), vec3<f32>(a));
|
|
15
15
|
` +
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// A target that mixes codes already holds the canvas's codes.
|
|
17
|
+
(srgb
|
|
18
|
+
? opaque
|
|
19
|
+
? 'return vec4<f32>(clamp(value.rgb, vec3<f32>(0.0), vec3<f32>(1.0)), 1.0);'
|
|
20
|
+
: 'if (a == 0.0) { return vec4<f32>(0.0); } return vec4<f32>(c, a);'
|
|
21
|
+
: opaque
|
|
22
|
+
? 'return vec4<f32>(encoded(clamp(value.rgb, vec3<f32>(0.0), vec3<f32>(1.0))), 1.0);'
|
|
23
|
+
: 'if (a == 0.0) { return vec4<f32>(0.0); } return vec4<f32>(a * encoded(c / a), a);') +
|
|
19
24
|
'\n}'
|
|
20
25
|
});
|
|
21
26
|
return pipeline({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Disposable } from '@egret/contracts';
|
|
2
2
|
import { Object3D } from '../../rendering/world3d/Object3D.js';
|
|
3
|
+
/** An audio listener to make: its audio context and volume. */
|
|
3
4
|
export interface AudioListenerOptions3D {
|
|
4
5
|
/** Reuse an existing context; otherwise one is created. */
|
|
5
6
|
readonly context?: AudioContext;
|
|
@@ -18,12 +19,19 @@ export declare class AudioListener3D extends Object3D implements Disposable {
|
|
|
18
19
|
resume(): Promise<void>;
|
|
19
20
|
/** Fetch and decode a sound file into a buffer that any number of sources can share. */
|
|
20
21
|
load(url: string, signal?: AbortSignal): Promise<AudioBuffer>;
|
|
22
|
+
/**
|
|
23
|
+
* A buffer of samples made in code, for a sound synthesized rather than loaded: one array per channel, or one array
|
|
24
|
+
* for mono, each value from -1 to 1, at `sampleRate` samples a second (default: the context's). Share it between
|
|
25
|
+
* sources as a loaded buffer.
|
|
26
|
+
*/
|
|
27
|
+
bufferFrom(samples: ArrayLike<number> | readonly ArrayLike<number>[], sampleRate?: number): AudioBuffer;
|
|
21
28
|
/** @internal */ register(source: PositionalAudio3D): void;
|
|
22
29
|
/** @internal */ unregister(source: PositionalAudio3D): void;
|
|
23
30
|
/** Copy this node's world pose to the audio listener and every source's to its panner. */
|
|
24
31
|
update(): void;
|
|
25
32
|
dispose(): void;
|
|
26
33
|
}
|
|
34
|
+
/** A positional sound to make: its buffer and volume, how it fades with distance, its cone, rate, and whether it is spatial. */
|
|
27
35
|
export interface PositionalAudioOptions3D {
|
|
28
36
|
readonly buffer?: AudioBuffer;
|
|
29
37
|
readonly loop?: boolean;
|
|
@@ -50,11 +58,18 @@ export declare class PositionalAudio3D extends Object3D implements Disposable {
|
|
|
50
58
|
readonly panner: PannerNode | undefined;
|
|
51
59
|
buffer: AudioBuffer | undefined;
|
|
52
60
|
loop: boolean;
|
|
53
|
-
playbackRate: number;
|
|
54
61
|
constructor(listener: AudioListener3D, options?: PositionalAudioOptions3D);
|
|
55
62
|
get volume(): number;
|
|
56
63
|
set volume(value: number);
|
|
57
64
|
get isPlaying(): boolean;
|
|
65
|
+
/** The speed and pitch of the voices: set, it changes the voices playing now as well as those to come. */
|
|
66
|
+
get playbackRate(): number;
|
|
67
|
+
set playbackRate(value: number);
|
|
68
|
+
/**
|
|
69
|
+
* Changes the speed and pitch of every voice, playing or to come, gliding over `rampSeconds` (default 0, at once): an
|
|
70
|
+
* engine's note following its speed.
|
|
71
|
+
*/
|
|
72
|
+
setPlaybackRate(rate: number, rampSeconds?: number): void;
|
|
58
73
|
/** Start a voice after `delaySeconds`, from `offsetSeconds` into the buffer. */
|
|
59
74
|
play(delaySeconds?: number, offsetSeconds?: number): AudioBufferSourceNode;
|
|
60
75
|
/** Stop every voice of this source. */
|
|
@@ -63,6 +78,8 @@ export declare class PositionalAudio3D extends Object3D implements Disposable {
|
|
|
63
78
|
updatePanner(): void;
|
|
64
79
|
dispose(): void;
|
|
65
80
|
}
|
|
81
|
+
/** Makes the listener 3D sounds are heard by, usually on the camera. */
|
|
66
82
|
export declare function createAudioListener3D(options?: AudioListenerOptions3D): AudioListener3D;
|
|
83
|
+
/** Makes a sound that plays from a place in the scene. */
|
|
67
84
|
export declare function createPositionalAudio3D(listener: AudioListener3D, options?: PositionalAudioOptions3D): PositionalAudio3D;
|
|
68
85
|
//# sourceMappingURL=Audio3D.d.ts.map
|
|
@@ -47,6 +47,32 @@ export class AudioListener3D extends Object3D {
|
|
|
47
47
|
throw new World3DError('WORLD3D_RESOURCE_FAILED', 'audio decode: ' + url, cause);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* A buffer of samples made in code, for a sound synthesized rather than loaded: one array per channel, or one array
|
|
52
|
+
* for mono, each value from -1 to 1, at `sampleRate` samples a second (default: the context's). Share it between
|
|
53
|
+
* sources as a loaded buffer.
|
|
54
|
+
*/
|
|
55
|
+
bufferFrom(samples, sampleRate = this.context.sampleRate) {
|
|
56
|
+
if (this.#disposed)
|
|
57
|
+
throw new World3DError('WORLD3D_DISPOSED', 'audio');
|
|
58
|
+
const channels = Array.isArray(samples) && typeof samples[0] === 'object'
|
|
59
|
+
? samples
|
|
60
|
+
: [samples];
|
|
61
|
+
const length = channels[0]?.length ?? 0;
|
|
62
|
+
if (channels.length < 1 ||
|
|
63
|
+
channels.length > 32 ||
|
|
64
|
+
length < 1 ||
|
|
65
|
+
!channels.every(channel => channel !== null && typeof channel === 'object' && channel.length === length) ||
|
|
66
|
+
!(sampleRate >= 3000 && sampleRate <= 768000))
|
|
67
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'audio samples');
|
|
68
|
+
const buffer = this.context.createBuffer(channels.length, length, sampleRate);
|
|
69
|
+
channels.forEach((channel, index) => {
|
|
70
|
+
const target = buffer.getChannelData(index);
|
|
71
|
+
for (let i = 0; i < length; i++)
|
|
72
|
+
target[i] = Math.max(-1, Math.min(1, Number(channel[i]) || 0));
|
|
73
|
+
});
|
|
74
|
+
return buffer;
|
|
75
|
+
}
|
|
50
76
|
/** @internal */ register(source) {
|
|
51
77
|
this.#sources.add(source);
|
|
52
78
|
}
|
|
@@ -98,7 +124,7 @@ export class PositionalAudio3D extends Object3D {
|
|
|
98
124
|
panner;
|
|
99
125
|
buffer;
|
|
100
126
|
loop;
|
|
101
|
-
playbackRate;
|
|
127
|
+
#playbackRate;
|
|
102
128
|
#voices = new Set();
|
|
103
129
|
#disposed = false;
|
|
104
130
|
constructor(listener, options = {}) {
|
|
@@ -109,7 +135,7 @@ export class PositionalAudio3D extends Object3D {
|
|
|
109
135
|
const context = listener.context;
|
|
110
136
|
this.buffer = options.buffer;
|
|
111
137
|
this.loop = options.loop ?? false;
|
|
112
|
-
this
|
|
138
|
+
this.#playbackRate = options.playbackRate ?? 1;
|
|
113
139
|
this.gain = context.createGain();
|
|
114
140
|
this.gain.gain.value = options.volume ?? 1;
|
|
115
141
|
if (options.spatial ?? true) {
|
|
@@ -138,6 +164,37 @@ export class PositionalAudio3D extends Object3D {
|
|
|
138
164
|
get isPlaying() {
|
|
139
165
|
return this.#voices.size > 0;
|
|
140
166
|
}
|
|
167
|
+
/** The speed and pitch of the voices: set, it changes the voices playing now as well as those to come. */
|
|
168
|
+
get playbackRate() {
|
|
169
|
+
return this.#playbackRate;
|
|
170
|
+
}
|
|
171
|
+
set playbackRate(value) {
|
|
172
|
+
this.setPlaybackRate(value);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Changes the speed and pitch of every voice, playing or to come, gliding over `rampSeconds` (default 0, at once): an
|
|
176
|
+
* engine's note following its speed.
|
|
177
|
+
*/
|
|
178
|
+
setPlaybackRate(rate, rampSeconds = 0) {
|
|
179
|
+
if (!(typeof rate === 'number' && rate > 0 && rate <= 16))
|
|
180
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'playbackRate');
|
|
181
|
+
if (!(typeof rampSeconds === 'number' && rampSeconds >= 0 && Number.isFinite(rampSeconds)))
|
|
182
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'rampSeconds');
|
|
183
|
+
this.#playbackRate = rate;
|
|
184
|
+
const now = this.listener.context.currentTime;
|
|
185
|
+
for (const voice of this.#voices) {
|
|
186
|
+
const param = voice.playbackRate;
|
|
187
|
+
if (rampSeconds === 0) {
|
|
188
|
+
param.cancelScheduledValues?.(now);
|
|
189
|
+
param.setValueAtTime(rate, now);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
param.cancelScheduledValues?.(now);
|
|
193
|
+
param.setValueAtTime(param.value, now);
|
|
194
|
+
param.linearRampToValueAtTime(rate, now + rampSeconds);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
141
198
|
/** Start a voice after `delaySeconds`, from `offsetSeconds` into the buffer. */
|
|
142
199
|
play(delaySeconds = 0, offsetSeconds = 0) {
|
|
143
200
|
if (this.#disposed)
|
|
@@ -147,7 +204,7 @@ export class PositionalAudio3D extends Object3D {
|
|
|
147
204
|
const context = this.listener.context, voice = context.createBufferSource();
|
|
148
205
|
voice.buffer = this.buffer;
|
|
149
206
|
voice.loop = this.loop;
|
|
150
|
-
voice.playbackRate.value = this
|
|
207
|
+
voice.playbackRate.value = this.#playbackRate;
|
|
151
208
|
voice.connect(this.gain);
|
|
152
209
|
voice.onended = () => {
|
|
153
210
|
voice.disconnect();
|
|
@@ -203,9 +260,11 @@ export class PositionalAudio3D extends Object3D {
|
|
|
203
260
|
this.listener.unregister(this);
|
|
204
261
|
}
|
|
205
262
|
}
|
|
263
|
+
/** Makes the listener 3D sounds are heard by, usually on the camera. */
|
|
206
264
|
export function createAudioListener3D(options = {}) {
|
|
207
265
|
return new AudioListener3D(options);
|
|
208
266
|
}
|
|
267
|
+
/** Makes a sound that plays from a place in the scene. */
|
|
209
268
|
export function createPositionalAudio3D(listener, options = {}) {
|
|
210
269
|
return new PositionalAudio3D(listener, options);
|
|
211
270
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DisplayObject } from '@egret/runtime';
|
|
2
|
+
import { play } from '../play.js';
|
|
2
3
|
import type { PlayGame, PlayOptions } from '../play.js';
|
|
3
4
|
import { Object3D, Scene3D } from '../../rendering/world3d/Object3D.js';
|
|
4
5
|
import type { Geometry3D } from '../../rendering/world3d/Geometry3D.js';
|
|
@@ -66,11 +67,65 @@ export declare class PlayThing3D {
|
|
|
66
67
|
/** Its colour, `0xRRGGBB`. What is not a colour is not taken; a model keeps the colours it has. */
|
|
67
68
|
get color(): number;
|
|
68
69
|
set color(value: number);
|
|
70
|
+
/**
|
|
71
|
+
* How much it shines with its own colour, lit or not: 0 (the default) not at all, 1 as bright as its colour,
|
|
72
|
+
* more for a lamp or a screen. A thing that glows is not hidden by fog. A model keeps the materials it has.
|
|
73
|
+
*/
|
|
74
|
+
get glow(): number;
|
|
75
|
+
set glow(value: number);
|
|
76
|
+
/**
|
|
77
|
+
* How much of it is seen, 0 to 1: 1 (the default) is solid, less lets what is behind it show through, as glass, a
|
|
78
|
+
* ghost or, with `glow`, a beam of light, whose light is added to what is behind it. A see-through thing casts no
|
|
79
|
+
* shadow. A model keeps the materials it has.
|
|
80
|
+
*/
|
|
81
|
+
get opacity(): number;
|
|
82
|
+
set opacity(value: number);
|
|
69
83
|
/** Whether `game.remove` has taken it out of the world. Setting it afterwards does nothing that is seen. */
|
|
70
84
|
get removed(): boolean;
|
|
71
85
|
/** Used by game removal and teardown; only resources made for this thing are retired. */
|
|
72
86
|
leave(): void;
|
|
73
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* A lamp: light from a point of the world that fades out by `range`. It is placed and changed by plain numbers, and
|
|
90
|
+
* `game.remove` puts it out. Up to eight are lit fully; more are lit by a coarser way.
|
|
91
|
+
*/
|
|
92
|
+
export declare class PlayLamp3D {
|
|
93
|
+
#private;
|
|
94
|
+
readonly node: Light3D;
|
|
95
|
+
constructor(color: number, intensity: number, range: number);
|
|
96
|
+
get x(): number;
|
|
97
|
+
set x(value: number);
|
|
98
|
+
get y(): number;
|
|
99
|
+
set y(value: number);
|
|
100
|
+
get z(): number;
|
|
101
|
+
set z(value: number);
|
|
102
|
+
get color(): number;
|
|
103
|
+
set color(value: number);
|
|
104
|
+
/** How bright it is; 0 is dark. */
|
|
105
|
+
get intensity(): number;
|
|
106
|
+
set intensity(value: number);
|
|
107
|
+
/** How far it reaches before it has faded out, in units of the world. */
|
|
108
|
+
get range(): number;
|
|
109
|
+
set range(value: number);
|
|
110
|
+
get visible(): boolean;
|
|
111
|
+
set visible(value: boolean);
|
|
112
|
+
get removed(): boolean;
|
|
113
|
+
leave(): void;
|
|
114
|
+
}
|
|
115
|
+
/** A lamp to light: how bright, and how far it reaches. */
|
|
116
|
+
export interface PlayLampOptions3D {
|
|
117
|
+
/** How bright it is: 4 unless given. */
|
|
118
|
+
readonly intensity?: number;
|
|
119
|
+
/** How far it reaches: 8 unless given. */
|
|
120
|
+
readonly range?: number;
|
|
121
|
+
}
|
|
122
|
+
/** What falls from the sky: snow, rain, or nothing. */
|
|
123
|
+
export type PlayWeather3D = 'snow' | 'rain' | 'none';
|
|
124
|
+
/** Weather to show: how much rain or snow. */
|
|
125
|
+
export interface PlayWeatherOptions3D {
|
|
126
|
+
/** How much falls: 1 unless given, from 0 to 3. */
|
|
127
|
+
readonly amount?: number;
|
|
128
|
+
}
|
|
74
129
|
/** The camera: where it is and what it looks at, by plain numbers. */
|
|
75
130
|
export interface PlayCamera3D {
|
|
76
131
|
x: number;
|
|
@@ -82,6 +137,7 @@ export interface PlayCamera3D {
|
|
|
82
137
|
lookAt(x: number, y: number, z: number): void;
|
|
83
138
|
readonly node: Camera3D;
|
|
84
139
|
}
|
|
140
|
+
/** How the camera follows: where it sits behind, how smoothly, and whether it turns with the target. */
|
|
85
141
|
export interface PlayFollow3D {
|
|
86
142
|
/** Where the camera stays from the thing: 0, 4 and 8 unless given, which is above and behind. */
|
|
87
143
|
readonly x?: number;
|
|
@@ -94,7 +150,13 @@ export interface PlayFollow3D {
|
|
|
94
150
|
* `{ y: 3, z: 7, turn: true }` is above and behind whichever way the thing faces. False unless given.
|
|
95
151
|
*/
|
|
96
152
|
readonly turn?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* How far above the thing the camera looks: 0 unless given. A tall tower or a sky the thing moves under is framed by
|
|
155
|
+
* looking higher; the camera keeps its place.
|
|
156
|
+
*/
|
|
157
|
+
readonly lookY?: number;
|
|
97
158
|
}
|
|
159
|
+
/** A burst of particles: its color and count, how fast and how long they fly, their size and gravity. */
|
|
98
160
|
export interface PlayBurst3D {
|
|
99
161
|
readonly color?: number;
|
|
100
162
|
readonly count?: number;
|
|
@@ -105,6 +167,29 @@ export interface PlayBurst3D {
|
|
|
105
167
|
}
|
|
106
168
|
type Body = PlayThing3D | DisplayObject;
|
|
107
169
|
/** What `play3d` gives: everything `play` gives for the interface and the game's time, and a world of things. */
|
|
170
|
+
export type PlayLookName3D = 'day' | 'dusk' | 'night' | 'fog' | 'snow';
|
|
171
|
+
/** How a 3D play game looks: its background and sky, its ground, its light and sun, and its fog. */
|
|
172
|
+
export interface PlayLook3D {
|
|
173
|
+
/** What is behind everything, and the colour of the fog. */
|
|
174
|
+
readonly background?: number;
|
|
175
|
+
/** The colour of the light from above. */
|
|
176
|
+
readonly sky?: number;
|
|
177
|
+
/** The colour of the light from below. */
|
|
178
|
+
readonly ground?: number;
|
|
179
|
+
/** How strong the light from above and below is, 0 to 16: 0.22 at night, 0.9 by day. */
|
|
180
|
+
readonly light?: number;
|
|
181
|
+
/** The colour of the sun. */
|
|
182
|
+
readonly sun?: number;
|
|
183
|
+
/** How strong the sun is, 0 to 16: 0.35 at night, 2.4 by day. */
|
|
184
|
+
readonly sunIntensity?: number;
|
|
185
|
+
/** The side the sun shines from, as `[x, y, z]`; y up. */
|
|
186
|
+
readonly sunFrom?: readonly [number, number, number];
|
|
187
|
+
/** How thick the air is: 0 is clear, 0.02 a haze, 0.06 a fog. */
|
|
188
|
+
readonly fog?: number;
|
|
189
|
+
}
|
|
190
|
+
/** The looks every game is given, by name. */
|
|
191
|
+
export declare const PLAY_LOOKS_3D: Readonly<Record<PlayLookName3D, Required<PlayLook3D>>>;
|
|
192
|
+
/** Everything a small 3D game is given: its scene and camera, its input, and calls that make, move and light things. */
|
|
108
193
|
export interface Play3DGame extends Omit<PlayGame, 'remove' | 'near' | 'overlaps' | 'hits' | 'hitsAll' | 'pushOut' | 'burst' | 'shake' | 'onTap'> {
|
|
109
194
|
readonly scene: Scene3D;
|
|
110
195
|
readonly camera: PlayCamera3D;
|
|
@@ -112,6 +197,12 @@ export interface Play3DGame extends Omit<PlayGame, 'remove' | 'near' | 'overlaps
|
|
|
112
197
|
readonly sun: Light3D;
|
|
113
198
|
/** The World3D app under the game, for what this does not cover. */
|
|
114
199
|
readonly app: World3DApp;
|
|
200
|
+
/**
|
|
201
|
+
* The light and air of the world: `'day'`, `'dusk'`, `'night'`, `'fog'` or `'snow'`, or the parts of one to change:
|
|
202
|
+
* `{ background, sky, ground, light, sun, sunIntensity, sunFrom, fog }`, colours as `0xRRGGBB`, `sunFrom` the side
|
|
203
|
+
* the sun shines from as `[x, y, z]`, and `fog` its thickness, 0 for none. A restart keeps it.
|
|
204
|
+
*/
|
|
205
|
+
look(look: PlayLookName3D | PlayLook3D): void;
|
|
115
206
|
/** A box of this width, height and depth, its middle at the place given. */
|
|
116
207
|
box(width: number, height: number, depth: number, color: number, at?: PlayPlace3D): PlayThing3D;
|
|
117
208
|
/** A ball. */
|
|
@@ -132,8 +223,8 @@ export interface Play3DGame extends Omit<PlayGame, 'remove' | 'near' | 'overlaps
|
|
|
132
223
|
* nearest thing hit gets it. A sprite of the interface is given to `onTap` of `play` as before.
|
|
133
224
|
*/
|
|
134
225
|
onTap(target: PlayThing3D | DisplayObject, callback: () => unknown): void;
|
|
135
|
-
/** Takes a thing out of the world, or a sprite off the interface. */
|
|
136
|
-
remove(body: Body): void;
|
|
226
|
+
/** Takes a thing or a lamp out of the world, or a sprite off the interface. */
|
|
227
|
+
remove(body: Body | PlayLamp3D): void;
|
|
137
228
|
/** Whether the middles of two things are within a distance: the sum of their radii unless given. */
|
|
138
229
|
near(a: Body, b: Body, distance?: number): boolean;
|
|
139
230
|
/** Whether two things overlap, taken as upright boxes. */
|
|
@@ -155,7 +246,21 @@ export interface Play3DGame extends Omit<PlayGame, 'remove' | 'near' | 'overlaps
|
|
|
155
246
|
shake(amount?: number, seconds?: number): void;
|
|
156
247
|
/** Throws small pieces out from a point of the world. */
|
|
157
248
|
burst(x: number, y: number, z: number, options?: PlayBurst3D): void;
|
|
249
|
+
/**
|
|
250
|
+
* Makes things one: a group that is placed, turned, scaled, tweened and tested as one thing, with the things in
|
|
251
|
+
* it where they are within it. Their places are now from the group's place, which is `at`, 0 unless given. Test
|
|
252
|
+
* the group, not its parts, for overlaps; removing the group removes its parts.
|
|
253
|
+
*/
|
|
254
|
+
group(parts: readonly PlayThing3D[], at?: PlayPlace3D): PlayThing3D;
|
|
255
|
+
/** A lamp at a place: light of a colour that fades out by its range. */
|
|
256
|
+
lamp(color: number, at?: PlayPlace3D, options?: PlayLampOptions3D): PlayLamp3D;
|
|
257
|
+
/**
|
|
258
|
+
* Snow or rain falling around what the camera looks at, or `'none'` to stop it. `{ amount }` is how much, 1
|
|
259
|
+
* unless given. A restart keeps it.
|
|
260
|
+
*/
|
|
261
|
+
weather(kind: PlayWeather3D, options?: PlayWeatherOptions3D): void;
|
|
158
262
|
}
|
|
263
|
+
/** A small 3D game to start: its setup and update, and the options of a 2D play game. */
|
|
159
264
|
export interface Play3DOptions extends Omit<PlayOptions, 'setup' | 'update' | 'canvas'> {
|
|
160
265
|
readonly setup?: (game: Play3DGame) => void | Promise<void>;
|
|
161
266
|
readonly update?: (seconds: number, game: Play3DGame) => void;
|
|
@@ -176,7 +281,15 @@ export declare function pushOut3D(a: PlayThing3D, b: PlayThing3D): {
|
|
|
176
281
|
y: number;
|
|
177
282
|
z: number;
|
|
178
283
|
} | undefined;
|
|
284
|
+
interface Play3DSurface {
|
|
285
|
+
readonly ready?: Promise<World3DApp>;
|
|
286
|
+
show?(scene: Scene3D, camera: Camera3D): void;
|
|
287
|
+
unplace?(): void;
|
|
288
|
+
remove?(): void;
|
|
289
|
+
}
|
|
179
290
|
/** Starts a 3D game in the page. See the guide `play3d.md`. */
|
|
180
291
|
export declare function play3d(options: Play3DOptions): Promise<Play3DGame>;
|
|
292
|
+
/** Internal host entry. The flat session owns input and UI; the surface presents the original scene. */
|
|
293
|
+
export declare function createPlay3DSession(options: Play3DOptions, startFlat: typeof play, attach: (given: PlayGame, options: Play3DOptions) => Play3DSurface): Promise<Play3DGame>;
|
|
181
294
|
export {};
|
|
182
295
|
//# sourceMappingURL=BrowserPlay3D.d.ts.map
|