diff --git a/examples-testing/changes.patch b/examples-testing/changes.patch index f98454d95..f91c6c28c 100644 --- a/examples-testing/changes.patch +++ b/examples-testing/changes.patch @@ -1142,7 +1142,7 @@ index fdd35d4..1b12050 100644 const link = document.createElement('a'); diff --git a/examples-testing/examples/misc_exporter_gltf.ts b/examples-testing/examples/misc_exporter_gltf.ts -index ceb964b..2b7de4d 100644 +index ceb964b..4a8e2be 100644 --- a/examples-testing/examples/misc_exporter_gltf.ts +++ b/examples-testing/examples/misc_exporter_gltf.ts @@ -6,7 +6,7 @@ import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js'; @@ -1185,7 +1185,7 @@ index ceb964b..2b7de4d 100644 +let camera: THREE.PerspectiveCamera, + object: THREE.Object3D, + object2: THREE.Mesh, -+ material: THREE.MeshBasicMaterial | THREE.MeshStandardMaterial, ++ material: THREE.MeshBasicMaterial | THREE.MeshLambertMaterial | THREE.MeshStandardMaterial, + geometry: THREE.BufferGeometry, + scene1: THREE.Scene, + scene2: THREE.Scene, @@ -12362,7 +12362,7 @@ index c3f0207..c211b8a 100644 if (morph.position.x > 2000) { morph.position.x = -1000 - Math.random() * 500; diff --git a/examples-testing/examples/webgl_shadowmap_pointlight.ts b/examples-testing/examples/webgl_shadowmap_pointlight.ts -index f921519..cffc086 100644 +index f921519..d39eb4e 100644 --- a/examples-testing/examples/webgl_shadowmap_pointlight.ts +++ b/examples-testing/examples/webgl_shadowmap_pointlight.ts @@ -4,8 +4,8 @@ import Stats from 'three/addons/libs/stats.module.js'; @@ -12385,6 +12385,18 @@ index f921519..cffc086 100644 const intensity = 200; const light = new THREE.PointLight(color, intensity, 20); +@@ -27,9 +27,9 @@ function init() { + light.shadow.bias = -0.005; // reduces self-shadowing on double-sided objects + + let geometry = new THREE.SphereGeometry(0.3, 12, 6); +- let material = new THREE.MeshBasicMaterial({ color: color }); ++ let material: THREE.MeshBasicMaterial | THREE.MeshPhongMaterial = new THREE.MeshBasicMaterial({ color: color }); + material.color.multiplyScalar(intensity); +- let sphere = new THREE.Mesh(geometry, material); ++ let sphere = new THREE.Mesh(geometry, material); + light.add(sphere); + + const texture = new THREE.CanvasTexture(generateTexture()); @@ -107,7 +107,7 @@ function generateTexture() { canvas.width = 2; canvas.height = 2; @@ -13941,7 +13953,7 @@ index a09b733..292719d 100644 clock = new THREE.Clock(); diff --git a/examples-testing/examples/webxr_vr_rollercoaster.ts b/examples-testing/examples/webxr_vr_rollercoaster.ts -index b659652..a10b469 100644 +index b659652..06e3224 100644 --- a/examples-testing/examples/webxr_vr_rollercoaster.ts +++ b/examples-testing/examples/webxr_vr_rollercoaster.ts @@ -9,7 +9,7 @@ import { @@ -13949,7 +13961,7 @@ index b659652..a10b469 100644 import { VRButton } from 'three/addons/webxr/VRButton.js'; -let mesh, material, geometry; -+let mesh: THREE.Mesh, material: THREE.MeshBasicMaterial, geometry: SkyGeometry; ++let mesh: THREE.Mesh, material: THREE.Material, geometry: SkyGeometry; const renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setPixelRatio(window.devicePixelRatio); diff --git a/types/three/src/lights/PointLight.d.ts b/types/three/src/lights/PointLight.d.ts index 801918236..47344330b 100644 --- a/types/three/src/lights/PointLight.d.ts +++ b/types/three/src/lights/PointLight.d.ts @@ -29,6 +29,13 @@ export class PointLight extends Light { */ constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number); + /** + * Read-only flag to check if a given object is of type {@link PointLight}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isPointLight: true; + /** * @default 'PointLight' */ diff --git a/types/three/src/materials/LineBasicMaterial.d.ts b/types/three/src/materials/LineBasicMaterial.d.ts index b664a5f82..f52ae2b60 100644 --- a/types/three/src/materials/LineBasicMaterial.d.ts +++ b/types/three/src/materials/LineBasicMaterial.d.ts @@ -13,6 +13,13 @@ export interface LineBasicMaterialParameters extends MaterialParameters { export class LineBasicMaterial extends Material { constructor(parameters?: LineBasicMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link LineBasicMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isLineBasicMaterial: true; + /** * @default 'LineBasicMaterial' */ diff --git a/types/three/src/materials/LineDashedMaterial.d.ts b/types/three/src/materials/LineDashedMaterial.d.ts index bd7b5f6ea..8eec4d4b2 100644 --- a/types/three/src/materials/LineDashedMaterial.d.ts +++ b/types/three/src/materials/LineDashedMaterial.d.ts @@ -9,6 +9,13 @@ export interface LineDashedMaterialParameters extends LineBasicMaterialParameter export class LineDashedMaterial extends LineBasicMaterial { constructor(parameters?: LineDashedMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link LineDashedMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isLineDashedMaterial: true; + /** * @default 'LineDashedMaterial' */ @@ -28,7 +35,6 @@ export class LineDashedMaterial extends LineBasicMaterial { * @default 1 */ gapSize: number; - readonly isLineDashedMaterial: true; setValues(parameters: LineDashedMaterialParameters): void; } diff --git a/types/three/src/materials/Material.d.ts b/types/three/src/materials/Material.d.ts index 6d79f5724..1ca2115bb 100644 --- a/types/three/src/materials/Material.d.ts +++ b/types/three/src/materials/Material.d.ts @@ -69,6 +69,13 @@ export interface MaterialParameters { export class Material extends EventDispatcher<{ dispose: {} }> { constructor(); + /** + * Read-only flag to check if a given object is of type {@link Material}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMaterial: true; + /** * Enables alpha hashed transparency, an alternative to {@link .transparent} or {@link .alphaTest}. The material * will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise, @@ -256,12 +263,6 @@ export class Material extends EventDispatcher<{ dispose: {} }> { */ stencilZPass: StencilOp; - /** - * Used to check whether this or derived classes are materials. Default is true. - * You should not change this, as it used internally for optimisation. - */ - readonly isMaterial: true; - /** * Material name. Default is an empty string. * @default '' diff --git a/types/three/src/materials/MeshBasicMaterial.d.ts b/types/three/src/materials/MeshBasicMaterial.d.ts index f53c20b29..9f533b5e6 100644 --- a/types/three/src/materials/MeshBasicMaterial.d.ts +++ b/types/three/src/materials/MeshBasicMaterial.d.ts @@ -29,6 +29,13 @@ export interface MeshBasicMaterialParameters extends MaterialParameters { export class MeshBasicMaterial extends Material { constructor(parameters?: MeshBasicMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshBasicMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshBasicMaterial: true; + /** * @default 'MeshBasicMaterial' */ diff --git a/types/three/src/materials/MeshDepthMaterial.d.ts b/types/three/src/materials/MeshDepthMaterial.d.ts index 4f5ac0f93..3b531cff4 100644 --- a/types/three/src/materials/MeshDepthMaterial.d.ts +++ b/types/three/src/materials/MeshDepthMaterial.d.ts @@ -15,6 +15,12 @@ export interface MeshDepthMaterialParameters extends MaterialParameters { export class MeshDepthMaterial extends Material { constructor(parameters?: MeshDepthMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshDepthMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshDepthMaterial: true; /** * @default 'MeshDepthMaterial' diff --git a/types/three/src/materials/MeshDistanceMaterial.d.ts b/types/three/src/materials/MeshDistanceMaterial.d.ts index 070ae8644..b83cdb5c2 100644 --- a/types/three/src/materials/MeshDistanceMaterial.d.ts +++ b/types/three/src/materials/MeshDistanceMaterial.d.ts @@ -16,6 +16,13 @@ export interface MeshDistanceMaterialParameters extends MaterialParameters { export class MeshDistanceMaterial extends Material { constructor(parameters?: MeshDistanceMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshDistanceMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshDistanceMaterial: true; + /** * @default 'MeshDistanceMaterial' */ diff --git a/types/three/src/materials/MeshLambertMaterial.d.ts b/types/three/src/materials/MeshLambertMaterial.d.ts index a5f81ba4a..3aacf729e 100644 --- a/types/three/src/materials/MeshLambertMaterial.d.ts +++ b/types/three/src/materials/MeshLambertMaterial.d.ts @@ -38,6 +38,13 @@ export interface MeshLambertMaterialParameters extends MaterialParameters { export class MeshLambertMaterial extends Material { constructor(parameters?: MeshLambertMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshLambertMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshLambertMaterial: true; + /** * @default 'MeshLambertMaterial' */ diff --git a/types/three/src/materials/MeshMatcapMaterial.d.ts b/types/three/src/materials/MeshMatcapMaterial.d.ts index 2031096a1..a114306be 100644 --- a/types/three/src/materials/MeshMatcapMaterial.d.ts +++ b/types/three/src/materials/MeshMatcapMaterial.d.ts @@ -24,6 +24,13 @@ export interface MeshMatcapMaterialParameters extends MaterialParameters { export class MeshMatcapMaterial extends Material { constructor(parameters?: MeshMatcapMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshMatcapMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshMatcapMaterial: true; + /** * @default 'MeshMatcapMaterial' */ diff --git a/types/three/src/materials/MeshNormalMaterial.d.ts b/types/three/src/materials/MeshNormalMaterial.d.ts index 7011049e3..14752eed8 100644 --- a/types/three/src/materials/MeshNormalMaterial.d.ts +++ b/types/three/src/materials/MeshNormalMaterial.d.ts @@ -21,6 +21,13 @@ export interface MeshNormalMaterialParameters extends MaterialParameters { export class MeshNormalMaterial extends Material { constructor(parameters?: MeshNormalMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshNormalMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshNormalMaterial: true; + /** * @default 'MeshNormalMaterial' */ diff --git a/types/three/src/materials/MeshPhongMaterial.d.ts b/types/three/src/materials/MeshPhongMaterial.d.ts index 40c772ab0..072bd8e32 100644 --- a/types/three/src/materials/MeshPhongMaterial.d.ts +++ b/types/three/src/materials/MeshPhongMaterial.d.ts @@ -43,6 +43,13 @@ export interface MeshPhongMaterialParameters extends MaterialParameters { export class MeshPhongMaterial extends Material { constructor(parameters?: MeshPhongMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshPhongMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshPhongMaterial: true; + /** * @default 'MeshNormalMaterial' */ diff --git a/types/three/src/materials/MeshPhysicalMaterial.d.ts b/types/three/src/materials/MeshPhysicalMaterial.d.ts index acacb490a..58fd0125a 100644 --- a/types/three/src/materials/MeshPhysicalMaterial.d.ts +++ b/types/three/src/materials/MeshPhysicalMaterial.d.ts @@ -48,7 +48,12 @@ export interface MeshPhysicalMaterialParameters extends MeshStandardMaterialPara export class MeshPhysicalMaterial extends MeshStandardMaterial { constructor(parameters?: MeshPhysicalMaterialParameters); - isMeshPhysicalMaterial: boolean; + /** + * Read-only flag to check if a given object is of type {@link MeshPhysicalMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshPhysicalMaterial: true; /** * @default 'MeshPhysicalMaterial' diff --git a/types/three/src/materials/MeshStandardMaterial.d.ts b/types/three/src/materials/MeshStandardMaterial.d.ts index e7cc2f311..45cfde647 100644 --- a/types/three/src/materials/MeshStandardMaterial.d.ts +++ b/types/three/src/materials/MeshStandardMaterial.d.ts @@ -38,6 +38,13 @@ export interface MeshStandardMaterialParameters extends MaterialParameters { export class MeshStandardMaterial extends Material { constructor(parameters?: MeshStandardMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshStandardMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshStandardMaterial: true; + /** * @default 'MeshStandardMaterial' */ @@ -200,7 +207,5 @@ export class MeshStandardMaterial extends Material { */ fog: boolean; - isMeshStandardMaterial: boolean; - setValues(parameters: MeshStandardMaterialParameters): void; } diff --git a/types/three/src/materials/MeshToonMaterial.d.ts b/types/three/src/materials/MeshToonMaterial.d.ts index 4cd2a43cb..5c27d509c 100644 --- a/types/three/src/materials/MeshToonMaterial.d.ts +++ b/types/three/src/materials/MeshToonMaterial.d.ts @@ -36,6 +36,13 @@ export interface MeshToonMaterialParameters extends MaterialParameters { export class MeshToonMaterial extends Material { constructor(parameters?: MeshToonMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link MeshToonMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isMeshToonMaterial: true; + /** * @default 'MeshToonMaterial' */ diff --git a/types/three/src/materials/PointsMaterial.d.ts b/types/three/src/materials/PointsMaterial.d.ts index b134cd402..6edaa9208 100644 --- a/types/three/src/materials/PointsMaterial.d.ts +++ b/types/three/src/materials/PointsMaterial.d.ts @@ -14,6 +14,13 @@ export interface PointsMaterialParameters extends MaterialParameters { export class PointsMaterial extends Material { constructor(parameters?: PointsMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link PointsMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isPointsMaterial: true; + /** * @default 'PointsMaterial' */ diff --git a/types/three/src/materials/RawShaderMaterial.d.ts b/types/three/src/materials/RawShaderMaterial.d.ts index c81313e58..dc96c6548 100644 --- a/types/three/src/materials/RawShaderMaterial.d.ts +++ b/types/three/src/materials/RawShaderMaterial.d.ts @@ -2,4 +2,13 @@ import { ShaderMaterialParameters, ShaderMaterial } from './ShaderMaterial.js'; export class RawShaderMaterial extends ShaderMaterial { constructor(parameters?: ShaderMaterialParameters); + + /** + * Read-only flag to check if a given object is of type {@link RawShaderMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isRawShaderMaterial: true; + + override readonly type: 'RawShaderMaterial'; } diff --git a/types/three/src/materials/ShaderMaterial.d.ts b/types/three/src/materials/ShaderMaterial.d.ts index 5c941d8da..311697d00 100644 --- a/types/three/src/materials/ShaderMaterial.d.ts +++ b/types/three/src/materials/ShaderMaterial.d.ts @@ -28,6 +28,13 @@ export interface ShaderMaterialParameters extends MaterialParameters { export class ShaderMaterial extends Material { constructor(parameters?: ShaderMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link ShaderMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isShaderMaterial: true; + /** * @default 'ShaderMaterial' */ @@ -114,8 +121,6 @@ export class ShaderMaterial extends Material { */ glslVersion: GLSLVersion | null; - isShaderMaterial: boolean; - setValues(parameters: ShaderMaterialParameters): void; toJSON(meta: any): any; } diff --git a/types/three/src/materials/ShadowMaterial.d.ts b/types/three/src/materials/ShadowMaterial.d.ts index 8b9175f73..a2e49f5c5 100644 --- a/types/three/src/materials/ShadowMaterial.d.ts +++ b/types/three/src/materials/ShadowMaterial.d.ts @@ -9,6 +9,13 @@ export interface ShadowMaterialParameters extends MaterialParameters { export class ShadowMaterial extends Material { constructor(parameters?: ShadowMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link ShadowMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isShadowMaterial: true; + /** * @default 'ShadowMaterial' */ diff --git a/types/three/src/materials/SpriteMaterial.d.ts b/types/three/src/materials/SpriteMaterial.d.ts index 708d3561e..7eb47eb54 100644 --- a/types/three/src/materials/SpriteMaterial.d.ts +++ b/types/three/src/materials/SpriteMaterial.d.ts @@ -13,6 +13,13 @@ export interface SpriteMaterialParameters extends MaterialParameters { export class SpriteMaterial extends Material { constructor(parameters?: SpriteMaterialParameters); + /** + * Read-only flag to check if a given object is of type {@link SpriteMaterial}. + * @remarks This is a _constant_ value + * @defaultValue `true` + */ + readonly isSpriteMaterial: true; + /** * @default 'SpriteMaterial' */ @@ -54,8 +61,6 @@ export class SpriteMaterial extends Material { */ fog: boolean; - readonly isSpriteMaterial: true; - setValues(parameters: SpriteMaterialParameters): void; copy(source: SpriteMaterial): this; }