🤖 Merge PR #60143 [three] r140 by @joshuaellis

* [three] – r129

* fix: export MathUtils under namespace in index

* fix: export Pass and FullScreenQuad from EffectComposer

* fix: use long export method to avoid ts bump

* r130

* feat: minor amends to r130

* [three] r131

* feat: add static slerp to Quaternion

* chore: update OTHER_FILES.txt

* chore: incl WebGLCubeUVMaps in exports

* minor fixes to current release

* [three]: r132 release

* three: r133

* Update OTHER_FILES.txt

* Update OTHER_FILES.txt

* Update OTHER_FILES.txt

* Update ArcballControls.d.ts

* feat: add default to `Intersection` generic

* chore: add test

* r134

* r135

* fix: tslint

* r136

* fix: export FramebufferTexture from THREE

* [three] r137

* [three] r138

* fix stupid OSS bot rule

* [three] r139

* Update types/three/examples/jsm/exporters/EXRExporter.d.ts

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

* r140

* fix: add es2015.generator to aframe config

* fix: SavePass constructor

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
This commit is contained in:
Josh
2022-05-03 17:37:08 +01:00
committed by GitHub
parent eefa7b7fce
commit 05ee023521
30 changed files with 285 additions and 43 deletions

View File

@@ -5,6 +5,7 @@
"es5",
"dom",
"es2015.iterable",
"es2015.generator",
"es2015.promise"
],
"noImplicitAny": true,

View File

@@ -118,7 +118,6 @@ examples/jsm/postprocessing/OutlinePass.d.ts
examples/jsm/postprocessing/RenderPass.d.ts
examples/jsm/postprocessing/BloomPass.d.ts
examples/jsm/postprocessing/SAOPass.d.ts
examples/jsm/postprocessing/SavePass.d.ts
examples/jsm/postprocessing/SMAAPass.d.ts
examples/jsm/postprocessing/SSAARenderPass.d.ts
examples/jsm/postprocessing/SSAOPass.d.ts

View File

@@ -52,7 +52,7 @@ export class OrbitControls {
update(): boolean;
listenToKeyEvents(domElement: HTMLElement): void;
listenToKeyEvents(domElement: HTMLElement | Window): void;
saveState(): void;

View File

@@ -1,4 +1,4 @@
import { Object3D, Camera, MOUSE, Raycaster } from '../../../src/Three';
import { Object3D, Camera, MOUSE, Raycaster, Mesh, Vector3, Quaternion } from '../../../src/Three';
export class TransformControls extends Object3D {
constructor(object: Camera, domElement?: HTMLElement);
@@ -40,3 +40,43 @@ export class TransformControls extends Object3D {
reset(): void;
dispose(): void;
}
export class TransformControlsGizmo extends Object3D {
type: 'TransformControlsGizmo';
isTransformControlsGizmo: true;
gizmo: {
translate: Object3D;
rotate: Object3D;
scale: Object3D;
};
helper: {
translate: Object3D;
rotate: Object3D;
scale: Object3D;
};
picker: {
translate: Object3D;
rotate: Object3D;
scale: Object3D;
};
constructor();
}
export class TransformControlsPlane extends Mesh {
type: 'TransformControlsPlane';
isTransformControlsPlane: true;
constructor();
mode: 'translate' | 'scale' | 'rotate';
axis: 'X' | 'Y' | 'Z' | 'XY' | 'YZ' | 'XZ' | 'XYZ' | 'E';
space: 'local' | 'world';
eye: Vector3;
worldPosition: Vector3;
worldQuaternion: Quaternion;
}

View File

@@ -1,20 +1,117 @@
import { Object3D, AnimationClip } from '../../../src/Three';
import { Object3D, AnimationClip, Texture, Material, Mesh } from '../../../src/Three';
export interface GLTFExporterOptions {
binary?: boolean;
/**
* Export position, rotation and scale instead of matrix per node. Default is false
*/
trs?: boolean;
/**
* Export only visible objects. Default is true.
*/
onlyVisible?: boolean;
/**
* Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.
*/
truncateDrawRange?: boolean;
/**
* Export in binary (.glb) format, returning an ArrayBuffer. Default is false.
*/
binary?: boolean;
/**
* Export with images embedded into the glTF asset. Default is true.
*/
embedImages?: boolean;
/**
* Restricts the image maximum size (both width and height) to the given value. This option works only if embedImages is true. Default is Infinity.
*/
maxTextureSize?: number;
/**
* List of animations to be included in the export.
*/
animations?: AnimationClip[];
/**
* Generate indices for non-index geometry and export with them. Default is false.
*/
forceIndices?: boolean;
forcePowerOfTwoTextures?: boolean;
/**
* Export custom glTF extensions defined on an object's userData.gltfExtensions property. Default is false.
*/
includeCustomExtensions?: boolean;
}
export class GLTFExporter {
constructor();
parse(input: Object3D, onCompleted: (gltf: object) => void, options: GLTFExporterOptions): void;
parseAsync(input: Object3D, options: GLTFExporterOptions): Promise<void>;
register(callback: (writer: GLTFWriter) => GLTFExporterPlugin): this;
unregister(callback: (writer: GLTFWriter) => GLTFExporterPlugin): this;
/**
* Generates a .gltf (JSON) or .glb (binary) output from the input (Scenes or Objects)
*
* @param input Scenes or objects to export. Valid options:
* - Export scenes
* ```js
* exporter.parse( scene1, ... )
* exporter.parse( [ scene1, scene2 ], ... )
* ```
* - Export objects (It will create a new Scene to hold all the objects)
* ```js
* exporter.parse( object1, ... )
* exporter.parse( [ object1, object2 ], ... )
* ```
* - Mix scenes and objects (It will export the scenes as usual but it will create a new scene to hold all the single objects).
* ```js
* exporter.parse( [ scene1, object1, object2, scene2 ], ... )
* ```
* @param onDone Will be called when the export completes. The argument will be the generated glTF JSON or binary ArrayBuffer.
* @param onError Will be called if there are any errors during the gltf generation.
* @param options Export options
*/
parse(
input: Object3D | Object3D[],
onDone: (gltf: ArrayBuffer | { [key: string]: any }) => void,
onError: (error: ErrorEvent) => void,
options?: GLTFExporterOptions,
): void;
parseAsync(
input: Object3D | Object3D[],
options?: GLTFExporterOptions,
): Promise<ArrayBuffer | { [key: string]: any }>;
}
export class GLTFWriter {
constructor();
setPlugins(plugins: GLTFExporterPlugin[]);
/**
* Parse scenes and generate GLTF output
*
* @param input Scene or Array of THREE.Scenes
* @param onDone Callback on completed
* @param options options
*/
write(
input: Object3D | Object3D[],
onDone: (gltf: ArrayBuffer | { [key: string]: any }) => void,
options?: GLTFExporterOptions,
): Promise<void>;
}
export interface GLTFExporterPlugin {
writeTexture?: (map: Texture, textureDef: { [key: string]: any }) => void;
writeMaterial?: (material: Material, materialDef: { [key: string]: any }) => void;
writeMesh?: (mesh: Mesh, meshDef: { [key: string]: any }) => void;
writeNode?: (object: Object3D, nodeDef: { [key: string]: any }) => void;
beforeParse?: (input: Object3D | Object3D[]) => void;
afterParse?: (input: Object3D | Object3D[]) => void;
}

View File

@@ -91,10 +91,15 @@ export class GLTFParser {
fileLoader: FileLoader;
textureLoader: TextureLoader | ImageBitmapLoader;
plugins: GLTFLoaderPlugin;
plugins: { [name: string]: GLTFLoaderPlugin };
extensions: { [name: string]: any };
associations: Map<Object3D | Material | Texture, GLTFReference>;
setExtensions(extensions: { [name: string]: any }): void;
setPlugins(plugins: { [name: string]: GLTFLoaderPlugin }): void;
parse(onLoad: (gltf: GLTF) => void, onError?: (event: ErrorEvent) => void): void;
getDependency: (type: string, index: number) => Promise<any>;
getDependencies: (type: string) => Promise<any[]>;
loadBuffer: (bufferIndex: number) => Promise<ArrayBuffer>;

View File

@@ -1,4 +1,11 @@
import { Mesh, BufferGeometry, ColorRepresentation, TextureEncoding, WebGLRenderTarget } from '../../../src/Three';
import {
Mesh,
BufferGeometry,
ColorRepresentation,
TextureEncoding,
WebGLRenderTarget,
PerspectiveCamera,
} from '../../../src/Three';
export interface ReflectorOptions {
color?: ColorRepresentation;
@@ -11,6 +18,9 @@ export interface ReflectorOptions {
}
export class Reflector extends Mesh {
type: 'Reflector';
camera: PerspectiveCamera;
constructor(geometry?: BufferGeometry, options?: ReflectorOptions);
getRenderTarget(): WebGLRenderTarget;

View File

@@ -1,4 +1,11 @@
import { Mesh, BufferGeometry, ColorRepresentation, TextureEncoding, WebGLRenderTarget } from '../../../src/Three';
import {
Mesh,
BufferGeometry,
ColorRepresentation,
TextureEncoding,
WebGLRenderTarget,
PerspectiveCamera,
} from '../../../src/Three';
export interface RefractorOptions {
color?: ColorRepresentation;
@@ -11,6 +18,9 @@ export interface RefractorOptions {
}
export class Refractor extends Mesh {
type: 'Refractor';
camera: PerspectiveCamera;
constructor(geometry?: BufferGeometry, options?: RefractorOptions);
getRenderTarget(): WebGLRenderTarget;

View File

@@ -3,7 +3,7 @@ import { ShaderMaterial, WebGLRenderTarget } from '../../../src/Three';
import { Pass } from './Pass';
export class SavePass extends Pass {
constructor(renderTarget: WebGLRenderTarget);
constructor(renderTarget?: WebGLRenderTarget);
textureID: string;
renderTarget: WebGLRenderTarget;
uniforms: object;

View File

@@ -15,5 +15,11 @@ export function estimateBytesUsed(geometry: BufferGeometry): number;
export function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
export function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
export function computeMorphedAttributes(object: Mesh | Line | Points): object;
export function computeTangents(geometry: BufferGeometry, negateSign?: boolean): BufferGeometry;
export function computeMikkTSpaceTangents(
geometry: BufferGeometry,
MikkTSpace: unknown,
negateSign?: boolean,
): BufferGeometry;
export function mergeGroups(geometry: BufferGeometry): BufferGeometry;
export function deinterleaveAttribute(geometry: BufferGeometry): void;
export function deinterleaveGeometry(geometry: BufferGeometry): void;

View File

@@ -1,30 +1,34 @@
import { AnimationClip, Bone, Matrix4, Object3D, Skeleton, SkeletonHelper } from '../../../src/Three';
export namespace SkeletonUtils {
function retarget(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): void;
export function retarget(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): void;
function retargetClip(
export function retargetClip(
target: Skeleton | Object3D,
source: Skeleton | Object3D,
clip: AnimationClip,
options: {},
): AnimationClip;
function getHelperFromSkeleton(skeleton: Skeleton): SkeletonHelper;
export function getHelperFromSkeleton(skeleton: Skeleton): SkeletonHelper;
function getSkeletonOffsets(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): Matrix4[];
export function getSkeletonOffsets(
target: Object3D | Skeleton,
source: Object3D | Skeleton,
options: {},
): Matrix4[];
function renameBones(skeleton: Skeleton, names: {}): any;
export function renameBones(skeleton: Skeleton, names: {}): any;
function getBones(skeleton: Skeleton | Bone[]): Bone[];
export function getBones(skeleton: Skeleton | Bone[]): Bone[];
function getBoneByName(name: string, skeleton: Skeleton): Bone;
export function getBoneByName(name: string, skeleton: Skeleton): Bone;
function getNearestBone(bone: Bone, names: {}): Bone;
export function getNearestBone(bone: Bone, names: {}): Bone;
function findBoneTrackData(name: string, tracks: any[]): {};
export function findBoneTrackData(name: string, tracks: any[]): {};
function getEqualsBonesNames(skeleton: Skeleton, targetSkeleton: Skeleton): string[];
export function getEqualsBonesNames(skeleton: Skeleton, targetSkeleton: Skeleton): string[];
function clone(source: Object3D): Object3D;
export function clone(source: Object3D): Object3D;
}

View File

@@ -1,14 +1,15 @@
// Type definitions for three 0.139
// Type definitions for three 0.140
// Project: https://threejs.org/
// Definitions by: Josh Ellis <https://github.com/joshuaellis>
// Nathan Bierema <https://github.com/Methuselah96>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.6
// To update three.js type definition, please make changes to the repository at:
// https://github.com/three-types/three-ts-types.
// Periodically, the updates from the repository are pushed to DefinitelyTyped
// and released in the @types/three npm package.
export * from './src/Three';
/*~ If this module is a UMD module that exposes a global variable 'myLib' when
*~ loaded outside a module loader environment, declare that global here.
*~ Otherwise, delete this declaration.
*/
export as namespace THREE;

View File

@@ -65,6 +65,7 @@ export * from './extras/core/ShapePath';
export * from './extras/core/CurvePath';
export * from './extras/core/Curve';
export * from './extras/DataUtils';
export * from './extras/Earcut';
export * from './extras/ImageUtils';
export * from './extras/ShapeUtils';
export * from './extras/PMREMGenerator';

View File

@@ -301,7 +301,6 @@ export const TriangleFanDrawMode: TrianglesDrawModes;
export enum TextureEncoding {}
export const LinearEncoding: TextureEncoding;
export const sRGBEncoding: TextureEncoding;
export const LogLuvEncoding: TextureEncoding;
// Depth packing strategies
export enum DepthPackingStrategies {}

4
types/three/src/extras/Earcut.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
import { Triangle } from '../Three';
export namespace Earcut {
function triangulate(data: number[], holeIndices: number[], dim: number): Triangle[];
}

View File

@@ -13,9 +13,6 @@ import {
StencilOp,
PixelFormat,
} from '../constants';
import { ColorRepresentation } from '../utils';
import { Color } from '../math/Color';
import { Texture } from '../textures/Texture';
export interface MaterialParameters {
alphaTest?: number | undefined;
@@ -35,7 +32,6 @@ export interface MaterialParameters {
depthFunc?: DepthModes | undefined;
depthTest?: boolean | undefined;
depthWrite?: boolean | undefined;
fog?: boolean | undefined;
name?: string | undefined;
opacity?: number | undefined;
polygonOffset?: boolean | undefined;
@@ -175,12 +171,6 @@ export class Material extends EventDispatcher {
*/
depthWrite: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
/**
* Unique number of this material instance.
*/

View File

@@ -16,6 +16,7 @@ export interface MeshBasicMaterialParameters extends MaterialParameters {
aoMapIntensity?: number | undefined;
specularMap?: Texture | null | undefined;
alphaMap?: Texture | null | undefined;
fog?: boolean | undefined;
envMap?: Texture | null | undefined;
combine?: Combine | undefined;
reflectivity?: number | undefined;
@@ -114,5 +115,11 @@ export class MeshBasicMaterial extends Material {
*/
wireframeLinejoin: string;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: MeshBasicMaterialParameters): void;
}

View File

@@ -24,6 +24,7 @@ export interface MeshLambertMaterialParameters extends MaterialParameters {
wireframeLinewidth?: number | undefined;
wireframeLinecap?: string | undefined;
wireframeLinejoin?: string | undefined;
fog?: boolean | undefined;
}
export class MeshLambertMaterial extends Material {
@@ -129,5 +130,11 @@ export class MeshLambertMaterial extends Material {
*/
wireframeLinejoin: string;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: MeshLambertMaterialParameters): void;
}

View File

@@ -18,7 +18,7 @@ export interface MeshMatcapMaterialParameters extends MaterialParameters {
displacementScale?: number | undefined;
displacementBias?: number | undefined;
alphaMap?: Texture | null | undefined;
fog?: boolean | undefined;
flatShading?: boolean | undefined;
}
@@ -101,5 +101,11 @@ export class MeshMatcapMaterial extends Material {
*/
flatShading: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: MeshMatcapMaterialParameters): void;
}

View File

@@ -37,7 +37,7 @@ export interface MeshPhongMaterialParameters extends MaterialParameters {
wireframeLinewidth?: number | undefined;
wireframeLinecap?: string | undefined;
wireframeLinejoin?: string | undefined;
fog?: boolean | undefined;
flatShading?: boolean | undefined;
}
@@ -205,5 +205,11 @@ export class MeshPhongMaterial extends Material {
*/
metal: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: MeshPhongMaterialParameters): void;
}

View File

@@ -32,7 +32,7 @@ export interface MeshStandardMaterialParameters extends MaterialParameters {
envMapIntensity?: number | undefined;
wireframe?: boolean | undefined;
wireframeLinewidth?: number | undefined;
fog?: boolean | undefined;
flatShading?: boolean | undefined;
}
@@ -195,6 +195,12 @@ export class MeshStandardMaterial extends Material {
*/
flatShading: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
isMeshStandardMaterial: boolean;
setValues(parameters: MeshStandardMaterialParameters): void;

View File

@@ -31,6 +31,7 @@ export interface MeshToonMaterialParameters extends MaterialParameters {
wireframeLinewidth?: number | undefined;
wireframeLinecap?: string | undefined;
wireframeLinejoin?: string | undefined;
fog?: boolean | undefined;
}
export class MeshToonMaterial extends Material {
@@ -161,5 +162,11 @@ export class MeshToonMaterial extends Material {
*/
wireframeLinejoin: string;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: MeshToonMaterialParameters): void;
}

View File

@@ -9,6 +9,7 @@ export interface PointsMaterialParameters extends MaterialParameters {
alphaMap?: Texture | null | undefined;
size?: number | undefined;
sizeAttenuation?: boolean | undefined;
fog?: boolean | undefined;
}
export class PointsMaterial extends Material {
@@ -44,5 +45,11 @@ export class PointsMaterial extends Material {
*/
sizeAttenuation: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
setValues(parameters: PointsMaterialParameters): void;
}

View File

@@ -4,6 +4,7 @@ import { MaterialParameters, Material } from './Material';
export interface ShadowMaterialParameters extends MaterialParameters {
color?: ColorRepresentation | undefined;
fog?: boolean | undefined;
}
export class ShadowMaterial extends Material {
@@ -23,4 +24,10 @@ export class ShadowMaterial extends Material {
* @default true
*/
transparent: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
}

View File

@@ -9,6 +9,7 @@ export interface SpriteMaterialParameters extends MaterialParameters {
alphaMap?: Texture | null | undefined;
rotation?: number | undefined;
sizeAttenuation?: boolean | undefined;
fog?: boolean | undefined;
}
export class SpriteMaterial extends Material {
@@ -48,6 +49,12 @@ export class SpriteMaterial extends Material {
*/
transparent: boolean;
/**
* Whether the material is affected by fog. Default is true.
* @default fog
*/
fog: boolean;
readonly isSpriteMaterial: true;
setValues(parameters: SpriteMaterialParameters): void;

View File

@@ -175,6 +175,8 @@ export class Color {
fromBufferAttribute(attribute: BufferAttribute, index: number): this;
[Symbol.iterator](): Generator<number, void>;
/**
* List of X11 color names.
*/

View File

@@ -42,4 +42,6 @@ export class Euler {
static RotationOrders: string[];
static DefaultOrder: string;
[Symbol.iterator](): Generator<string | number, void>;
}

View File

@@ -174,4 +174,6 @@ export class Quaternion {
inverse(): Quaternion;
random(): Quaternion;
[Symbol.iterator](): Generator<number, void>;
}

View File

@@ -0,0 +1,8 @@
import * as THREE from 'three';
import { SavePass } from 'three/examples/jsm/postprocessing/SavePass';
let pass = new SavePass(); // $ExpectType SavePass
let rt = pass.renderTarget; // $ExpectType WebGLRenderTarget
pass = new SavePass(new THREE.WebGLRenderTarget(128, 128)); // $ExpectType SavePass
rt = pass.renderTarget; // $ExpectType WebGLRenderTarget

View File

@@ -56,6 +56,7 @@
"test/misc/misc-gpucomputationrender.ts",
"test/postprocessing/postprocessing-ssr.ts",
"test/postprocessing/postprocessing-effectcomposer-pass.ts",
"test/postprocessing/postprocessing-savepass.ts",
"test/renderers/renderers-renderTarget-multiple.ts",
"test/renderers/renderers-renderTarget-texture2DArray.ts",
"test/renderers/webxr/webxr-vr-cube.ts",