@needle-tools/engine 4.13.1 → 4.14.0-next.31f837e
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/components.needle.json +1 -1
- package/dist/generateMeshBVH.worker-DFcS3P04.js +21 -0
- package/dist/gltf-progressive-8voIgNp_.js +1528 -0
- package/dist/gltf-progressive-BRRBj-nY.umd.cjs +10 -0
- package/dist/gltf-progressive-Dkh3tG4-.min.js +10 -0
- package/dist/loader.worker-C6cXDgR1.js +23 -0
- package/dist/{materialx-BF23AVE8.umd.cjs → materialx-CxlgposR.umd.cjs} +1 -1
- package/dist/{materialx-fkoFuRh3.js → materialx-D66rYPqe.js} +2 -2
- package/dist/{materialx-B9ddsHcF.min.js → materialx-Dx8st96L.min.js} +1 -1
- package/dist/{needle-engine.bundle-tjI5Fq2c.umd.cjs → needle-engine.bundle-BQXG5qbQ.umd.cjs} +138 -145
- package/dist/{needle-engine.bundle-DauZUYl7.js → needle-engine.bundle-Byl5i6zJ.js} +6403 -6164
- package/dist/needle-engine.bundle-D7w0XD7M.min.js +1646 -0
- package/dist/needle-engine.d.ts +251 -23
- package/dist/needle-engine.js +416 -415
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-DdM-tz1j.js → postprocessing-BkSpxpYB.js} +2 -2
- package/dist/{postprocessing-BVNrgYZK.min.js → postprocessing-Ce5-UWiA.min.js} +1 -1
- package/dist/{postprocessing-CI2TjWpu.umd.cjs → postprocessing-DFVElmAh.umd.cjs} +1 -1
- package/dist/{three-BW2s1Yl-.umd.cjs → three-Bad8p1pf.umd.cjs} +46 -46
- package/dist/{three-I__hSXzr.min.js → three-CWn13_u1.min.js} +33 -33
- package/dist/{three-VvRoMeIN.js → three-DFV1-P9z.js} +4209 -4209
- package/dist/{three-examples-BhfOE7NG.js → three-examples-43yqn3mL.js} +1 -1
- package/dist/{three-examples-Bpfu6ke_.umd.cjs → three-examples-CO-tx3Sp.umd.cjs} +1 -1
- package/dist/{three-examples-D8zAE_7t.min.js → three-examples-DKuJVGT4.min.js} +1 -1
- package/dist/{three-mesh-ui-BU55xDxJ.umd.cjs → three-mesh-ui-ChzVOraf.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-C3QbemOV.min.js → three-mesh-ui-DyEA5HQF.min.js} +1 -1
- package/dist/{three-mesh-ui-CcMp-FQm.js → three-mesh-ui-fSAQJxdI.js} +1 -1
- package/dist/{vendor-COVQl0b8.umd.cjs → vendor-B51YffMU.umd.cjs} +1 -1
- package/dist/{vendor-BiyIZ61v.js → vendor-CgpZ5ivC.js} +1 -1
- package/dist/{vendor-DW7zqjuT.min.js → vendor-pe19S9r5.min.js} +1 -1
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.js +12 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_lightdata.js +8 -6
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +47 -0
- package/lib/engine/engine_materialpropertyblock.js +412 -0
- package/lib/engine/engine_materialpropertyblock.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +1 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +171 -14
- package/lib/engine/engine_utils_screenshot.js +65 -0
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.xr.js +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
- package/lib/engine/xr/NeedleXRSession.js +5 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +0 -1
- package/lib/engine-components/ReflectionProbe.js +15 -76
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/RendererLightmap.d.ts +13 -9
- package/lib/engine-components/RendererLightmap.js +68 -81
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js +6 -0
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +1 -0
- package/lib/engine-components/utils/OpenURL.js +1 -0
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +1 -0
- package/lib/engine-components/web/CursorFollow.js +1 -0
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +1 -0
- package/lib/engine-components/web/ScrollFollow.js +1 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +1 -0
- package/lib/engine-components/webxr/WebXR.js +1 -0
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/package.json +4 -4
- package/plugins/vite/build-pipeline.js +16 -2
- package/src/engine/api.ts +1 -0
- package/src/engine/engine_context.ts +17 -3
- package/src/engine/engine_lightdata.ts +8 -6
- package/src/engine/engine_materialpropertyblock.ts +500 -0
- package/src/engine/engine_utils.ts +1 -0
- package/src/engine/engine_utils_screenshot.ts +241 -17
- package/src/engine/engine_utils_screenshot.xr.ts +1 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
- package/src/engine/xr/NeedleXRSession.ts +5 -0
- package/src/engine-components/ContactShadows.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +17 -89
- package/src/engine-components/RendererLightmap.ts +76 -87
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/VideoPlayer.ts +6 -0
- package/src/engine-components/utils/OpenURL.ts +1 -0
- package/src/engine-components/web/CursorFollow.ts +1 -0
- package/src/engine-components/web/ScrollFollow.ts +1 -0
- package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
- package/src/engine-components/webxr/WebXR.ts +1 -0
- package/dist/generateMeshBVH.worker-iyfPIK6R.js +0 -21
- package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
- package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
- package/dist/gltf-progressive-eiJCrjLb.js +0 -1400
- package/dist/loader.worker-C1GG9A7C.js +0 -23
- package/dist/needle-engine.bundle-BNIUpreS.min.js +0 -1653
- package/src/include/three/DragControls.js +0 -232
package/dist/needle-engine.d.ts
CHANGED
|
@@ -4684,6 +4684,7 @@ export declare function createMotion(name: string, id?: InstantiateIdProvider):
|
|
|
4684
4684
|
*
|
|
4685
4685
|
* @summary Makes objects follow the cursor/touch position in 3D space
|
|
4686
4686
|
* @category Interactivity
|
|
4687
|
+
* @category Web
|
|
4687
4688
|
* @group Components
|
|
4688
4689
|
* @component
|
|
4689
4690
|
*/
|
|
@@ -5081,6 +5082,7 @@ declare enum DeviceType {
|
|
|
5081
5082
|
|
|
5082
5083
|
/**
|
|
5083
5084
|
* Utility functions to detect certain device types (mobile, desktop), browsers, or capabilities.
|
|
5085
|
+
* @category Utilities
|
|
5084
5086
|
*/
|
|
5085
5087
|
export declare namespace DeviceUtilities {
|
|
5086
5088
|
/** @returns `true` for MacOS or Windows devices. `false` for Hololens and other headsets. */
|
|
@@ -10054,6 +10056,40 @@ export declare class MaskableGraphic extends Graphic {
|
|
|
10054
10056
|
protected onAfterCreated(): void;
|
|
10055
10057
|
}
|
|
10056
10058
|
|
|
10059
|
+
export declare class MaterialPropertyBlock<T extends Material = Material> {
|
|
10060
|
+
private _overrides;
|
|
10061
|
+
private _defines;
|
|
10062
|
+
private _object;
|
|
10063
|
+
get object(): Object3D | null;
|
|
10064
|
+
constructor(object?: Object3D | null);
|
|
10065
|
+
static get<T extends Material = Material>(object: Object3D): MaterialPropertyBlock<T>;
|
|
10066
|
+
dispose(): void;
|
|
10067
|
+
setOverride<K extends NonFunctionPropertyNames<T>>(name: K, value: T[K], textureTransform?: TextureTransform): void;
|
|
10068
|
+
setOverride(name: string, value: MaterialPropertyType, textureTransform?: TextureTransform): void;
|
|
10069
|
+
getOverride(name: string): PropertyBlockOverride | undefined;
|
|
10070
|
+
clearOverride(name: string): void;
|
|
10071
|
+
clearAllOverrides(): void;
|
|
10072
|
+
removeOverride(name: string): void;
|
|
10073
|
+
get overrides(): PropertyBlockOverride[];
|
|
10074
|
+
hasOverrides(): boolean;
|
|
10075
|
+
/**
|
|
10076
|
+
* Set a shader define that will be included in the program cache key
|
|
10077
|
+
* This allows different objects sharing the same material to have different shader programs
|
|
10078
|
+
*/
|
|
10079
|
+
setDefine(name: string, value: string | number | boolean): void;
|
|
10080
|
+
/**
|
|
10081
|
+
* Remove a shader define
|
|
10082
|
+
*/
|
|
10083
|
+
clearDefine(name: string): void;
|
|
10084
|
+
/**
|
|
10085
|
+
* Get all defines set on this property block
|
|
10086
|
+
*/
|
|
10087
|
+
getDefines(): Readonly<Record<string, string | number | boolean>>;
|
|
10088
|
+
getCacheKey(): string;
|
|
10089
|
+
}
|
|
10090
|
+
|
|
10091
|
+
declare type MaterialPropertyType = number | number[] | Color | Texture | Vector2 | Vector3 | Vector4 | null;
|
|
10092
|
+
|
|
10057
10093
|
export declare namespace MaterialX {
|
|
10058
10094
|
/**
|
|
10059
10095
|
* Utility function to load a MaterialX material from a URL. This can be used in your own code to load MaterialX materials outside of the glTF loading process. The URL should point to a MaterialX XML file.
|
|
@@ -11319,7 +11355,12 @@ export declare type NeedleXRHitTestResult = {
|
|
|
11319
11355
|
* The XRRig can be accessed via the `rig` property
|
|
11320
11356
|
* Set a custom XRRig via `NeedleXRSession.addRig(...)` or `NeedleXRSession.removeRig(...)`
|
|
11321
11357
|
* By default the active XRRig with the highest priority in the scene is used
|
|
11358
|
+
*
|
|
11359
|
+
* ### Screenshots in XR
|
|
11360
|
+
* Screenshots work automatically during XR sessions, including AR camera feed compositing. See {@link screenshot2} for more information.
|
|
11361
|
+
*
|
|
11322
11362
|
* @category XR
|
|
11363
|
+
* @see {@link screenshot2} for taking screenshots in XR sessions
|
|
11323
11364
|
*/
|
|
11324
11365
|
export declare class NeedleXRSession implements INeedleXRSession {
|
|
11325
11366
|
private static _sync;
|
|
@@ -12177,6 +12218,10 @@ export declare class NoiseModule {
|
|
|
12177
12218
|
apply(_index: number, pos: Vec3, vel: Vec3, _deltaTime: number, age: number, life: number): void;
|
|
12178
12219
|
}
|
|
12179
12220
|
|
|
12221
|
+
declare type NonFunctionPropertyNames<T> = {
|
|
12222
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
12223
|
+
}[keyof T];
|
|
12224
|
+
|
|
12180
12225
|
/** Removes all undefined functions */
|
|
12181
12226
|
declare type NoUndefinedNoFunctions<T> = FilterTypes<T, Function | undefined | null>;
|
|
12182
12227
|
|
|
@@ -12592,6 +12637,7 @@ export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void):
|
|
|
12592
12637
|
* OpenURL behaviour opens a URL in a new tab or window when the object (or any if it's children) is clicked.
|
|
12593
12638
|
*
|
|
12594
12639
|
* @category Interactivity
|
|
12640
|
+
* @category Web
|
|
12595
12641
|
* @group Components
|
|
12596
12642
|
*/
|
|
12597
12643
|
export declare class OpenURL extends Component implements IPointerClickHandler {
|
|
@@ -14645,6 +14691,12 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
14645
14691
|
constructor(reason: string);
|
|
14646
14692
|
}
|
|
14647
14693
|
|
|
14694
|
+
declare interface PropertyBlockOverride {
|
|
14695
|
+
name: string;
|
|
14696
|
+
value: MaterialPropertyType;
|
|
14697
|
+
textureTransform?: TextureTransform;
|
|
14698
|
+
}
|
|
14699
|
+
|
|
14648
14700
|
export declare const PUBLIC_KEY: string;
|
|
14649
14701
|
|
|
14650
14702
|
/** Adds an entry to the browser history. Internally uses `window.history.pushState` */
|
|
@@ -15075,7 +15127,6 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
15075
15127
|
awake(): void;
|
|
15076
15128
|
start(): void;
|
|
15077
15129
|
onDestroy(): void;
|
|
15078
|
-
private static _rendererMaterialsCache;
|
|
15079
15130
|
onSet(_rend: IRenderer): void;
|
|
15080
15131
|
onUnset(_rend: IRenderer): void;
|
|
15081
15132
|
}
|
|
@@ -15477,23 +15528,27 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
15477
15528
|
private lightmapIndex;
|
|
15478
15529
|
private lightmapScaleOffset;
|
|
15479
15530
|
private readonly renderer;
|
|
15480
|
-
private
|
|
15531
|
+
private _isApplied;
|
|
15481
15532
|
private get context();
|
|
15482
15533
|
private get gameObject();
|
|
15483
15534
|
private lightmapTexture;
|
|
15484
|
-
private lightmapScaleOffsetUniform;
|
|
15485
|
-
private lightmapUniform;
|
|
15486
15535
|
constructor(renderer: Renderer);
|
|
15487
15536
|
init(lightmapIndex: number, lightmapScaleOffset: Vector4, lightmapTexture: Texture): void;
|
|
15488
|
-
updateLightmapUniforms(
|
|
15537
|
+
updateLightmapUniforms(_material: any): void;
|
|
15489
15538
|
/**
|
|
15490
|
-
* Apply the lightmap to the object
|
|
15539
|
+
* Apply the lightmap to the object using MaterialPropertyBlock instead of cloning materials.
|
|
15540
|
+
* The lightmap texture and its per-object UV transform are set as overrides via PropertyBlock.
|
|
15541
|
+
* Three.js reads material.lightMap to determine shader defines and upload uniforms,
|
|
15542
|
+
* and uses texture.offset/repeat to compute lightMapTransform in the vertex shader.
|
|
15491
15543
|
*/
|
|
15492
15544
|
applyLightmap(): void;
|
|
15545
|
+
/** Update the lightMap override on all property blocks (e.g. after LOD swap) */
|
|
15546
|
+
private updatePropertyBlockTexture;
|
|
15547
|
+
/**
|
|
15548
|
+
* Remove the lightmap from the object
|
|
15549
|
+
*/
|
|
15550
|
+
onUnset(): void;
|
|
15493
15551
|
private ensureLightmapUvs;
|
|
15494
|
-
private ensureLightmapMaterial;
|
|
15495
|
-
private assignLightmapTexture;
|
|
15496
|
-
private onBeforeCompile;
|
|
15497
15552
|
private setLightmapDebugMaterial;
|
|
15498
15553
|
}
|
|
15499
15554
|
|
|
@@ -16327,40 +16382,179 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
16327
16382
|
* const dataUrl = screenshot();
|
|
16328
16383
|
* saveImage(dataUrl, "screenshot.png");
|
|
16329
16384
|
* ```
|
|
16385
|
+
*
|
|
16330
16386
|
*/
|
|
16331
16387
|
export declare function screenshot(context?: Context, width?: number, height?: number, mimeType?: ScreenshotImageMimeType, camera?: Camera_2 | null): string | null;
|
|
16332
16388
|
|
|
16333
16389
|
/**
|
|
16334
|
-
* Take a screenshot from the current scene and return a {@link Texture}. This can applied to a surface in 3D space.
|
|
16390
|
+
* Take a screenshot from the current scene and return a {@link Texture}. This can be applied to a surface in 3D space.
|
|
16335
16391
|
* @param opts Provide `{ type: "texture" }` to get a texture instead of a data url.
|
|
16336
16392
|
* @returns The texture of the screenshot. Returns null if the screenshot could not be taken.
|
|
16393
|
+
* @category Utilities
|
|
16394
|
+
* @example
|
|
16395
|
+
* ```ts
|
|
16396
|
+
* // Create a texture from the current view
|
|
16397
|
+
* const screenshotTexture = screenshot2({ type: "texture", width: 512, height: 512 });
|
|
16398
|
+
* if (screenshotTexture) {
|
|
16399
|
+
* myMaterial.map = screenshotTexture;
|
|
16400
|
+
* myMaterial.needsUpdate = true;
|
|
16401
|
+
* }
|
|
16402
|
+
*
|
|
16403
|
+
* // Update an existing texture
|
|
16404
|
+
* const existingTexture = new Texture();
|
|
16405
|
+
* screenshot2({ type: "texture", target: existingTexture, transparent: true });
|
|
16406
|
+
* ```
|
|
16337
16407
|
*/
|
|
16338
16408
|
export declare function screenshot2(opts: ScreenshotOptionsTexture): Texture | null;
|
|
16339
16409
|
|
|
16340
16410
|
/**
|
|
16341
|
-
* Take a screenshot from the current scene.
|
|
16342
|
-
*
|
|
16343
|
-
* @
|
|
16411
|
+
* Take a screenshot from the current scene and return a data URL string.
|
|
16412
|
+
*
|
|
16413
|
+
* @param opts Screenshot options. All properties are optional.
|
|
16414
|
+
* @returns The data URL of the screenshot (e.g., "data:image/png;base64,..."). Returns null if the screenshot could not be taken.
|
|
16415
|
+
* @category Utilities
|
|
16416
|
+
*
|
|
16417
|
+
* @example Basic screenshot
|
|
16344
16418
|
* ```ts
|
|
16345
|
-
*
|
|
16346
|
-
*
|
|
16419
|
+
* // Take a simple screenshot with default settings
|
|
16420
|
+
* const dataUrl = screenshot2({});
|
|
16421
|
+
* console.log(dataUrl); // "data:image/webp;base64,..."
|
|
16422
|
+
* ```
|
|
16423
|
+
*
|
|
16424
|
+
* @example High-resolution screenshot with transparent background
|
|
16425
|
+
* ```ts
|
|
16426
|
+
* const dataUrl = screenshot2({
|
|
16427
|
+
* width: 2048,
|
|
16428
|
+
* height: 2048,
|
|
16429
|
+
* mimeType: "image/png",
|
|
16430
|
+
* transparent: true,
|
|
16431
|
+
* trim: true, // Remove transparent edges
|
|
16432
|
+
* });
|
|
16433
|
+
* ```
|
|
16434
|
+
*
|
|
16435
|
+
* @example Screenshot with custom background color
|
|
16436
|
+
* ```ts
|
|
16437
|
+
* import { Color } from "three";
|
|
16438
|
+
*
|
|
16439
|
+
* const dataUrl = screenshot2({
|
|
16440
|
+
* width: 1024,
|
|
16347
16441
|
* height: 1024,
|
|
16348
|
-
*
|
|
16349
|
-
*
|
|
16350
|
-
*
|
|
16351
|
-
*
|
|
16352
|
-
*
|
|
16442
|
+
* background: new Color(0x00ff00), // Green background
|
|
16443
|
+
* });
|
|
16444
|
+
* ```
|
|
16445
|
+
*
|
|
16446
|
+
* @example Download screenshot automatically
|
|
16447
|
+
* ```ts
|
|
16448
|
+
* screenshot2({
|
|
16449
|
+
* width: 1920,
|
|
16450
|
+
* height: 1080,
|
|
16451
|
+
* mimeType: "image/jpeg",
|
|
16452
|
+
* download_filename: "my-scene.jpg",
|
|
16453
|
+
* });
|
|
16454
|
+
* ```
|
|
16455
|
+
*
|
|
16456
|
+
* @example Manual download using saveImage
|
|
16457
|
+
* ```ts
|
|
16458
|
+
* const dataUrl = screenshot2({
|
|
16459
|
+
* width: 1024,
|
|
16460
|
+
* height: 1024,
|
|
16461
|
+
* mimeType: "image/webp",
|
|
16462
|
+
* transparent: true,
|
|
16463
|
+
* });
|
|
16464
|
+
* if (dataUrl) {
|
|
16465
|
+
* saveImage(dataUrl, "screenshot.webp");
|
|
16466
|
+
* }
|
|
16467
|
+
* ```
|
|
16468
|
+
*
|
|
16469
|
+
* @example Screenshot from specific camera
|
|
16470
|
+
* ```ts
|
|
16471
|
+
* const myCamera = this.gameObject.getComponent(Camera);
|
|
16472
|
+
* const dataUrl = screenshot2({
|
|
16473
|
+
* camera: myCamera,
|
|
16474
|
+
* width: 1024,
|
|
16475
|
+
* height: 1024,
|
|
16476
|
+
* });
|
|
16353
16477
|
* ```
|
|
16354
16478
|
*/
|
|
16355
16479
|
export declare function screenshot2(opts: ScreenshotOptionsDataUrl): string | null;
|
|
16356
16480
|
|
|
16357
16481
|
/**
|
|
16358
|
-
* Take a screenshot asynchronously
|
|
16359
|
-
*
|
|
16360
|
-
* @param
|
|
16482
|
+
* Take a screenshot asynchronously and return a Blob. This is useful when you need to process or upload the image data.
|
|
16483
|
+
*
|
|
16484
|
+
* @param opts Set `{ type: "blob" }` to get a blob instead of a data url. All other {@link ScreenshotOptions} are also available.
|
|
16485
|
+
* @returns A Promise that resolves with the Blob of the screenshot. Returns null if the screenshot could not be taken.
|
|
16486
|
+
* @category Utilities
|
|
16487
|
+
*
|
|
16488
|
+
* @example Upload screenshot to server
|
|
16489
|
+
* ```ts
|
|
16490
|
+
* const blob = await screenshot2({ type: "blob", mimeType: "image/png" });
|
|
16491
|
+
* if (blob) {
|
|
16492
|
+
* const formData = new FormData();
|
|
16493
|
+
* formData.append("screenshot", blob, "screenshot.png");
|
|
16494
|
+
* await fetch("/api/upload", { method: "POST", body: formData });
|
|
16495
|
+
* }
|
|
16496
|
+
* ```
|
|
16497
|
+
*
|
|
16498
|
+
* @example Save blob to file (browser download)
|
|
16499
|
+
* ```ts
|
|
16500
|
+
* const blob = await screenshot2({
|
|
16501
|
+
* type: "blob",
|
|
16502
|
+
* width: 1920,
|
|
16503
|
+
* height: 1080,
|
|
16504
|
+
* transparent: true
|
|
16505
|
+
* });
|
|
16506
|
+
* if (blob) {
|
|
16507
|
+
* const url = URL.createObjectURL(blob);
|
|
16508
|
+
* saveImage(url, "screenshot.png");
|
|
16509
|
+
* URL.revokeObjectURL(url); // Clean up
|
|
16510
|
+
* }
|
|
16511
|
+
* ```
|
|
16361
16512
|
*/
|
|
16362
16513
|
export declare function screenshot2(opts: ScreenshotOptionsBlob): Promise<Blob | null>;
|
|
16363
16514
|
|
|
16515
|
+
/**
|
|
16516
|
+
* Take a screenshot and share it using the Web Share API (mobile-friendly).
|
|
16517
|
+
*
|
|
16518
|
+
* **Note**: The Web Share API is only available in secure contexts (HTTPS) and may not be supported on all platforms/browsers.
|
|
16519
|
+
*
|
|
16520
|
+
* @param opts Set `{ type: "share" }` to share the screenshot. Additional options like `filename`, `title`, `text`, and `url` can be provided.
|
|
16521
|
+
* @returns A Promise that resolves with an object containing the blob and whether it was successfully shared.
|
|
16522
|
+
* @category Utilities
|
|
16523
|
+
*
|
|
16524
|
+
* @example Share screenshot on mobile
|
|
16525
|
+
* ```ts
|
|
16526
|
+
* const result = await screenshot2({
|
|
16527
|
+
* type: "share",
|
|
16528
|
+
* filename: "my-creation.png",
|
|
16529
|
+
* title: "Check out my 3D scene!",
|
|
16530
|
+
* text: "I created this with Needle Engine",
|
|
16531
|
+
* url: "https://engine.needle.tools",
|
|
16532
|
+
* mimeType: "image/png",
|
|
16533
|
+
* });
|
|
16534
|
+
*
|
|
16535
|
+
* if (result.shared) {
|
|
16536
|
+
* console.log("Screenshot shared successfully!");
|
|
16537
|
+
* } else {
|
|
16538
|
+
* console.log("User cancelled or sharing not supported");
|
|
16539
|
+
* }
|
|
16540
|
+
* ```
|
|
16541
|
+
*
|
|
16542
|
+
* @example Share with fallback
|
|
16543
|
+
* ```ts
|
|
16544
|
+
* const result = await screenshot2({
|
|
16545
|
+
* type: "share",
|
|
16546
|
+
* filename: "screenshot.webp",
|
|
16547
|
+
* file_type: "image/webp",
|
|
16548
|
+
* });
|
|
16549
|
+
*
|
|
16550
|
+
* if (!result.shared && result.blob) {
|
|
16551
|
+
* // Fallback: download the image instead
|
|
16552
|
+
* const url = URL.createObjectURL(result.blob);
|
|
16553
|
+
* saveImage(url, "screenshot.webp");
|
|
16554
|
+
* URL.revokeObjectURL(url);
|
|
16555
|
+
* }
|
|
16556
|
+
* ```
|
|
16557
|
+
*/
|
|
16364
16558
|
export declare function screenshot2(opts: ScreenshotOptionsShare): Promise<ScreenshotOptionsShareReturnType>;
|
|
16365
16559
|
|
|
16366
16560
|
declare type ScreenshotImageMimeType = "image/webp" | "image/png" | "image/jpeg";
|
|
@@ -16422,11 +16616,29 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
16422
16616
|
};
|
|
16423
16617
|
|
|
16424
16618
|
export declare type ScreenshotOptionsShare = ScreenshotOptions & {
|
|
16619
|
+
/**
|
|
16620
|
+
* Set `{ type: "share" }` to share the screenshot using the Web Share API. The promise will resolve with the blob of the screenshot and whether it was shared successfully or not. Note that the Web Share API is only available in secure contexts (HTTPS) and on some platforms.
|
|
16621
|
+
*/
|
|
16425
16622
|
type: "share";
|
|
16623
|
+
/**
|
|
16624
|
+
* The filename to use when sharing the screenshot. If not provided, a default filename will be used.
|
|
16625
|
+
*/
|
|
16426
16626
|
filename?: string;
|
|
16627
|
+
/**
|
|
16628
|
+
* The mime type of the shared file. If not provided, the mime type will be inferred from the screenshot options or default to "image/png".
|
|
16629
|
+
*/
|
|
16427
16630
|
file_type?: ScreenshotImageMimeType;
|
|
16631
|
+
/**
|
|
16632
|
+
* The title to use when sharing the screenshot. This is optional and may not be supported by all platforms.
|
|
16633
|
+
*/
|
|
16428
16634
|
title?: string;
|
|
16635
|
+
/**
|
|
16636
|
+
* The text to use when sharing the screenshot. This is optional and may not be supported by all platforms.
|
|
16637
|
+
*/
|
|
16429
16638
|
text?: string;
|
|
16639
|
+
/**
|
|
16640
|
+
* The URL to use when sharing the screenshot. This is optional and may not be supported by all platforms.
|
|
16641
|
+
*/
|
|
16430
16642
|
url?: string;
|
|
16431
16643
|
};
|
|
16432
16644
|
|
|
@@ -16568,6 +16780,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
16568
16780
|
*
|
|
16569
16781
|
* @summary Links scroll position to target objects
|
|
16570
16782
|
* @category Web
|
|
16783
|
+
* @category Interaction
|
|
16571
16784
|
* @group Components
|
|
16572
16785
|
* @component
|
|
16573
16786
|
*/
|
|
@@ -19105,6 +19318,11 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
19105
19318
|
/**@obsolete use Graphics.textureToCanvas */
|
|
19106
19319
|
export declare function textureToCanvas(texture: Texture, force?: boolean): HTMLCanvasElement | null;
|
|
19107
19320
|
|
|
19321
|
+
declare interface TextureTransform {
|
|
19322
|
+
offset?: Vector2;
|
|
19323
|
+
repeat?: Vector2;
|
|
19324
|
+
}
|
|
19325
|
+
|
|
19108
19326
|
declare enum TextWrapMode {
|
|
19109
19327
|
singleLine = "singleLine",
|
|
19110
19328
|
hardBreaks = "hardBreaks",
|
|
@@ -20779,11 +20997,20 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
20779
20997
|
/**
|
|
20780
20998
|
* WebARCameraBackground is a component that allows to display the camera feed as a background in an AR session to more easily blend the real world with the virtual world or applying effects to the camera feed.
|
|
20781
20999
|
*
|
|
21000
|
+
* This component automatically requests `camera-access` permission when entering AR mode, which is required to:
|
|
21001
|
+
* - Display the real-world camera feed as a background
|
|
21002
|
+
* - Include the camera feed in AR screenshots taken with {@link screenshot2}
|
|
21003
|
+
*
|
|
21004
|
+
* **Note**: If you want to take AR screenshots with the camera feed but don't need to display it as a background,
|
|
21005
|
+
* you can still add this component to your scene (it will request camera access) or manually request the
|
|
21006
|
+
* `camera-access` feature in your `onBeforeXR` method.
|
|
21007
|
+
*
|
|
20782
21008
|
* - Example: https://samples.needle.tools/ar-camera-background
|
|
20783
21009
|
*
|
|
20784
21010
|
* @summary Displays the camera feed as background in WebAR sessions
|
|
20785
21011
|
* @category XR
|
|
20786
21012
|
* @group Components
|
|
21013
|
+
* @see {@link screenshot2} for taking screenshots in AR (requires camera access for camera feed compositing)
|
|
20787
21014
|
*/
|
|
20788
21015
|
export declare class WebARCameraBackground extends Component {
|
|
20789
21016
|
/* Excluded from this release type: onBeforeXR */
|
|
@@ -20942,6 +21169,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
20942
21169
|
* @see {@link XRControllerMovement} for VR locomotion
|
|
20943
21170
|
* @see {@link WebARSessionRoot} for AR session configuration
|
|
20944
21171
|
* @see {@link Avatar} for networked user avatars
|
|
21172
|
+
* @see {@link screenshot2} for taking screenshots in XR (including AR camera feed compositing)
|
|
20945
21173
|
* @link https://engine.needle.tools/docs/xr.html
|
|
20946
21174
|
* @link https://engine.needle.tools/samples/?overlay=samples&tag=xr
|
|
20947
21175
|
* @link https://engine.needle.tools/samples/collaborative-sandbox
|