diff --git a/package.json b/package.json index f8c43a6bef77a4691ee1ca4d52c4175bb66432b8..51fb5bbdf7a363671200b44410b3243a44f3e0d9 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "test": "test" }, "eslintConfig": { + "root": true, "parser": "@typescript-eslint/parser", "extends": "mdcs", "plugins": [ @@ -44,6 +45,10 @@ "SwitchCase": 1 } ], + "quotes": [ + "error", + "single" + ], "prefer-const": [ "error", { diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 4ecbbadb0586288da03e3c22759799ada45c9f69..de313b94aa4124786fa5e1657c2c5dc227b8a93a 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -583,7 +583,7 @@ Object.assign( Matrix3.prototype, { flattenToArrayOffset: function ( array, offset ) { - console.warn( "THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + console.warn( 'THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); return this.toArray( array, offset ); }, @@ -628,7 +628,7 @@ Object.assign( Matrix4.prototype, { }, flattenToArrayOffset: function ( array, offset ) { - console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + console.warn( 'THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' ); return this.toArray( array, offset ); }, @@ -1118,8 +1118,8 @@ Object.defineProperty( Curve.prototype, '__arcLengthDivisions', { PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { - console.warn( "THREE.PerspectiveCamera.setLens is deprecated. " + - "Use .setFocalLength and .filmGauge for a photographic setup." ); + console.warn( 'THREE.PerspectiveCamera.setLens is deprecated. ' + + 'Use .setFocalLength and .filmGauge for a photographic setup.' ); if ( filmGauge !== undefined ) this.filmGauge = filmGauge; this.setFocalLength( focalLength ); diff --git a/src/animation/KeyframeTrack.js b/src/animation/KeyframeTrack.js index 06dd293fbfae73a77487d77e661e27e119ba61b1..d9e6916494bdad12c12382f7aeb4c3d4bb19c125 100644 --- a/src/animation/KeyframeTrack.js +++ b/src/animation/KeyframeTrack.js @@ -125,8 +125,8 @@ Object.assign( KeyframeTrack.prototype, { if ( factoryMethod === undefined ) { - const message = "unsupported interpolation for " + - this.ValueTypeName + " keyframe track named " + this.name; + const message = 'unsupported interpolation for ' + + this.ValueTypeName + ' keyframe track named ' + this.name; if ( this.createInterpolant === undefined ) { diff --git a/src/animation/PropertyBinding.js b/src/animation/PropertyBinding.js index 1d3dff9e13b77e888e425927e6171556b9446e30..33e54f0364ac3c1ee5d1ed22287852daa32d8ba2 100644 --- a/src/animation/PropertyBinding.js +++ b/src/animation/PropertyBinding.js @@ -188,7 +188,7 @@ Object.assign( PropertyBinding, { findNode: function ( root, nodeName ) { - if ( ! nodeName || nodeName === "" || nodeName === "." || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { + if ( ! nodeName || nodeName === '' || nodeName === '.' || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { return root; @@ -591,7 +591,7 @@ Object.assign( PropertyBinding.prototype, { // prototype, continued // access a sub element of the property array (only primitives are supported right now) - if ( propertyName === "morphTargetInfluences" ) { + if ( propertyName === 'morphTargetInfluences' ) { // potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. diff --git a/src/constants.js b/src/constants.js index 682b1ef76ec4b84922bad588412266c903cd67ed..f38c49cc74f6f16bd3fb04291442723cce460385 100644 --- a/src/constants.js +++ b/src/constants.js @@ -196,5 +196,5 @@ export const StaticCopyUsage = 35046; export const DynamicCopyUsage = 35050; export const StreamCopyUsage = 35042; -export const GLSL1 = "100"; -export const GLSL3 = "300 es"; +export const GLSL1 = '100'; +export const GLSL3 = '300 es'; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 1e6235c0aa9ea47c4b6570c759a1d2bd122d1fd5..69cb375f86ff8963f56e90c46c95ace7dc79d1c8 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -315,7 +315,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( object === this ) { - console.error( "THREE.Object3D.add: object can't be added as a child of itself.", object ); + console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object ); return this; } @@ -335,7 +335,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), } else { - console.error( "THREE.Object3D.add: object not an instance of THREE.Object3D.", object ); + console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object ); } diff --git a/src/geometries/ExtrudeBufferGeometry.js b/src/geometries/ExtrudeBufferGeometry.js index 333c094b7a7946f5fc9e3aefeaffe41721021d84..74532435dc68d92176d953d635a520157a90a4ab 100644 --- a/src/geometries/ExtrudeBufferGeometry.js +++ b/src/geometries/ExtrudeBufferGeometry.js @@ -175,7 +175,7 @@ class ExtrudeBufferGeometry extends BufferGeometry { function scalePt2( pt, vec, size ) { - if ( ! vec ) console.error( "THREE.ExtrudeGeometry: vec does not exist" ); + if ( ! vec ) console.error( 'THREE.ExtrudeGeometry: vec does not exist' ); return vec.clone().multiplyScalar( size ).add( pt ); diff --git a/src/materials/Material.js b/src/materials/Material.js index e5ea51e94c503f240e172587993c2780708e5b4d..3c7c90b636e1a06c8b0355e6c56649331e9ee752 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -96,7 +96,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( newValue === undefined ) { - console.warn( "THREE.Material: '" + key + "' parameter is undefined." ); + console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' ); continue; } @@ -114,7 +114,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( currentValue === undefined ) { - console.warn( "THREE." + this.type + ": '" + key + "' is not a property of this material." ); + console.warn( 'THREE.' + this.type + ': \'' + key + '\' is not a property of this material.' ); continue; } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 8ff915185ebd610ac6915ca48b53612c2783c4bb..4459972a7c61164fc93ccbae2e51c9524c36072c 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -37,7 +37,7 @@ import { WebGLTextures } from './webgl/WebGLTextures.js'; import { WebGLUniforms } from './webgl/WebGLUniforms.js'; import { WebGLUtils } from './webgl/WebGLUtils.js'; import { WebXRManager } from './webxr/WebXRManager.js'; -import { WebGLMaterials } from "./webgl/WebGLMaterials.js"; +import { WebGLMaterials } from './webgl/WebGLMaterials.js'; function createCanvasElement() { diff --git a/src/renderers/webgl/WebGLBufferRenderer.d.ts b/src/renderers/webgl/WebGLBufferRenderer.d.ts index 8cafa1ac155a98a87ae0c6c172c265182914c9ad..162b8b90af13ddbea0ab669ec39c249b10956889 100644 --- a/src/renderers/webgl/WebGLBufferRenderer.d.ts +++ b/src/renderers/webgl/WebGLBufferRenderer.d.ts @@ -1,7 +1,7 @@ // Renderers / WebGL ///////////////////////////////////////////////////////////////////// -import { WebGLExtensions } from "./WebGLExtensions"; -import { WebGLInfo } from "./WebGLInfo"; -import { WebGLCapabilities } from "./WebGLCapabilities"; +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLInfo } from './WebGLInfo'; +import { WebGLCapabilities } from './WebGLCapabilities'; export class WebGLBufferRenderer { diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js index 105af70eb3d82b6efdb52ad508b72b9e44879cf2..2392c8f4b79b878890ccd310212acd19f40f9f93 100644 --- a/src/renderers/webgl/WebGLProgram.js +++ b/src/renderers/webgl/WebGLProgram.js @@ -257,19 +257,19 @@ function loopReplacer( match, start, end, snippet ) { function generatePrecision( parameters ) { - let precisionstring = "precision " + parameters.precision + " float;\nprecision " + parameters.precision + " int;"; + let precisionstring = 'precision ' + parameters.precision + ' float;\nprecision ' + parameters.precision + ' int;'; - if ( parameters.precision === "highp" ) { + if ( parameters.precision === 'highp' ) { - precisionstring += "\n#define HIGH_PRECISION"; + precisionstring += '\n#define HIGH_PRECISION'; - } else if ( parameters.precision === "mediump" ) { + } else if ( parameters.precision === 'mediump' ) { - precisionstring += "\n#define MEDIUM_PRECISION"; + precisionstring += '\n#define MEDIUM_PRECISION'; - } else if ( parameters.precision === "lowp" ) { + } else if ( parameters.precision === 'lowp' ) { - precisionstring += "\n#define LOW_PRECISION"; + precisionstring += '\n#define LOW_PRECISION'; } @@ -399,7 +399,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) { const program = gl.createProgram(); let prefixVertex, prefixFragment; - let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + "\n" : ''; + let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : ''; if ( parameters.isRawShaderMaterial ) { diff --git a/src/renderers/webgl/WebGLPrograms.js b/src/renderers/webgl/WebGLPrograms.js index e2032a35374a4bc5d124d4ae05729ab48563cea8..08b92ff3f1e4d7be1e6fbd7e50f02d8bb7ea0773 100644 --- a/src/renderers/webgl/WebGLPrograms.js +++ b/src/renderers/webgl/WebGLPrograms.js @@ -34,19 +34,19 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta }; const parameterNames = [ - "precision", "isWebGL2", "supportsVertexTextures", "outputEncoding", "instancing", "instancingColor", - "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "envMapCubeUV", - "lightMap", "lightMapEncoding", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "tangentSpaceNormalMap", "clearcoatMap", "clearcoatRoughnessMap", "clearcoatNormalMap", "displacementMap", "specularMap", - "roughnessMap", "metalnessMap", "gradientMap", - "alphaMap", "combine", "vertexColors", "vertexTangents", "vertexUvs", "uvsVertexOnly", "fog", "useFog", "fogExp2", - "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", - "maxBones", "useVertexTexture", "morphTargets", "morphNormals", - "maxMorphTargets", "maxMorphNormals", "premultipliedAlpha", - "numDirLights", "numPointLights", "numSpotLights", "numHemiLights", "numRectAreaLights", - "numDirLightShadows", "numPointLightShadows", "numSpotLightShadows", - "shadowMapEnabled", "shadowMapType", "toneMapping", 'physicallyCorrectLights', - "alphaTest", "doubleSided", "flipSided", "numClippingPlanes", "numClipIntersection", "depthPacking", "dithering", - "sheen", "transmissionMap" + 'precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', + 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', + 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap', + 'roughnessMap', 'metalnessMap', 'gradientMap', + 'alphaMap', 'combine', 'vertexColors', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', + 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', + 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', + 'maxMorphTargets', 'maxMorphNormals', 'premultipliedAlpha', + 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', + 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', + 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', + 'alphaTest', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', + 'sheen', 'transmissionMap' ]; function getMaxBones( object ) { @@ -99,7 +99,7 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta } else if ( map.isWebGLRenderTarget ) { - console.warn( "THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead." ); + console.warn( 'THREE.WebGLPrograms.getTextureEncodingFromMap: don\'t use render targets as textures. Use their .texture property instead.' ); encoding = map.texture.encoding; } diff --git a/src/renderers/webgl/WebGLShadowMap.d.ts b/src/renderers/webgl/WebGLShadowMap.d.ts index c1a414f706e059d948782473acf87139a210fcaf..d05cebbf8edb87b66b7a13ebe89e16153ba64063 100644 --- a/src/renderers/webgl/WebGLShadowMap.d.ts +++ b/src/renderers/webgl/WebGLShadowMap.d.ts @@ -2,8 +2,8 @@ import { Scene } from './../../scenes/Scene'; import { Camera } from './../../cameras/Camera'; import { WebGLRenderer } from '../WebGLRenderer'; import { ShadowMapType } from '../../constants'; -import { WebGLObjects } from "./WebGLObjects"; -import { Light } from "../../lights/Light"; +import { WebGLObjects } from './WebGLObjects'; +import { Light } from '../../lights/Light'; export class WebGLShadowMap { diff --git a/src/renderers/webgl/WebGLShadowMap.js b/src/renderers/webgl/WebGLShadowMap.js index 29e6615d375e1425a14427f2bbc049f821763661..101e0644d7b129abf2bb2f9af021ed251b0efac6 100644 --- a/src/renderers/webgl/WebGLShadowMap.js +++ b/src/renderers/webgl/WebGLShadowMap.js @@ -53,7 +53,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { const fullScreenTri = new BufferGeometry(); fullScreenTri.setAttribute( - "position", + 'position', new BufferAttribute( new Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ), 3 @@ -139,7 +139,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); - shadow.map.texture.name = light.name + ".shadowMap"; + shadow.map.texture.name = light.name + '.shadowMap'; shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); @@ -152,7 +152,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { const pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat }; shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars ); - shadow.map.texture.name = light.name + ".shadowMap"; + shadow.map.texture.name = light.name + '.shadowMap'; shadow.camera.updateProjectionMatrix(); diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index d1a080fa92bd2086f13c22056567de1dd87f467c..d5a1dfba537b4c6a1b137ca77026481539c59fd6 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -21,7 +21,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, try { useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' - && ( new OffscreenCanvas( 1, 1 ).getContext( "2d" ) ) !== null; + && ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null; } catch ( err ) { @@ -1217,7 +1217,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( warnedTexture2D === false ) { - console.warn( "THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead." ); + console.warn( 'THREE.WebGLTextures.safeSetTexture2D: don\'t use render targets as textures. Use their .texture property instead.' ); warnedTexture2D = true; } @@ -1236,7 +1236,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( warnedTextureCube === false ) { - console.warn( "THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead." ); + console.warn( 'THREE.WebGLTextures.safeSetTextureCube: don\'t use cube render targets as textures. Use their .texture property instead.' ); warnedTextureCube = true; } diff --git a/src/renderers/webxr/WebXRController.js b/src/renderers/webxr/WebXRController.js index 310c966b0ada2d18f8aa6c6bfd76577107051e56..0073ab24c447914ec2054892ff722c573e39fb27 100644 --- a/src/renderers/webxr/WebXRController.js +++ b/src/renderers/webxr/WebXRController.js @@ -171,7 +171,7 @@ Object.assign( WebXRController.prototype, { hand.inputState.pinching = false; this.dispatchEvent( { - type: "pinchend", + type: 'pinchend', handedness: inputSource.handedness, target: this } ); @@ -180,7 +180,7 @@ Object.assign( WebXRController.prototype, { hand.inputState.pinching = true; this.dispatchEvent( { - type: "pinchstart", + type: 'pinchstart', handedness: inputSource.handedness, target: this } ); diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 9f0b1cf4cea8c57ec52d5f2a0af9409fe3d9cc5f..555b9090758c8b93fea68573b828e4574355394c 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -326,7 +326,7 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { } ); -Object.defineProperty( Texture.prototype, "needsUpdate", { +Object.defineProperty( Texture.prototype, 'needsUpdate', { set: function ( value ) {