Skip to content

Commit 95cdf64

Browse files
committed
example lint
1 parent b4deae6 commit 95cdf64

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

example/SkinWeightsShaderMixin.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { Color, UniformsUtils } from 'three';
22

3-
function cloneShader(shader, uniforms, defines) {
3+
function cloneShader( shader, uniforms, defines ) {
44

5-
const newShader = Object.assign({}, shader);
6-
newShader.uniforms = UniformsUtils.merge([
5+
const newShader = Object.assign( {}, shader );
6+
newShader.uniforms = UniformsUtils.merge( [
77
newShader.uniforms,
88
uniforms
9-
]);
10-
newShader.defines = Object.assign({}, defines);
9+
] );
10+
newShader.defines = Object.assign( {}, defines );
1111

1212
return newShader;
1313

1414
}
1515

16-
export function SkinWeightMixin(shader) {
16+
export function SkinWeightMixin( shader ) {
17+
1718
const defineKeyword = 'ENABLE_SKIN_WEIGHTS';
1819
const newShader = cloneShader(
1920
shader,
@@ -23,7 +24,7 @@ export function SkinWeightMixin(shader) {
2324
skinWeightIndex: { value: - 1 }
2425
},
2526
{
26-
[defineKeyword]: 1,
27+
[ defineKeyword ]: 1,
2728
},
2829
);
2930

@@ -43,20 +44,21 @@ export function SkinWeightMixin(shader) {
4344
#endif
4445
}
4546
`
46-
)
47+
);
4748

4849
newShader.fragmentShader = `
4950
uniform vec3 skinWeightColor;
5051
varying float skinWeightColorRatio;
5152
${newShader.fragmentShader}
5253
`.replace(
53-
/vec4 diffuseColor = vec4\( diffuse, opacity \);/,
54-
v => `${v}
54+
/vec4 diffuseColor = vec4\( diffuse, opacity \);/,
55+
v => `${v}
5556
#ifdef ENABLE_SKIN_WEIGHTS
5657
diffuseColor = vec4( skinWeightColor, smoothstep( 0.1, 0.3, skinWeightColorRatio ) * opacity );
5758
#endif
5859
`,
59-
);
60+
);
6061

6162
return newShader;
63+
6264
}

example/index.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import { TransformControls } from 'three/examples/jsm/controls/TransformControls
2626
import { SkinWeightMixin } from './SkinWeightsShaderMixin.js';
2727

2828
// globals
29-
var stats;
30-
var params = {
29+
let stats;
30+
const params = {
3131

3232
showSkeleton: false,
3333
skin: 0,
@@ -52,17 +52,17 @@ const MODELS = {
5252

5353
};
5454

55-
var camera, scene, renderer, controls;
56-
var directionalLight, ambientLight, ground;
57-
var skeletonHelper, model, skeleton, gui;
58-
var transformControls;
59-
var mouse = new Vector2();
60-
var mouseDown = new Vector2();
61-
var unselectableBones = [];
62-
var movingControls = false;
63-
64-
var SkinWeightShader = SkinWeightMixin( ShaderLib.phong );
65-
var skinWeightsMaterial = new ShaderMaterial( SkinWeightShader );
55+
let camera, scene, renderer, controls;
56+
let directionalLight, ambientLight, ground;
57+
let skeletonHelper, model, skeleton, gui;
58+
let transformControls;
59+
const mouse = new Vector2();
60+
const mouseDown = new Vector2();
61+
const unselectableBones = [];
62+
let movingControls = false;
63+
64+
const SkinWeightShader = SkinWeightMixin( ShaderLib.phong );
65+
const skinWeightsMaterial = new ShaderMaterial( SkinWeightShader );
6666
skinWeightsMaterial.lights = true;
6767
skinWeightsMaterial.skinning = true;
6868
skinWeightsMaterial.transparent = true;
@@ -139,7 +139,7 @@ const raycastBones = ( function () {
139139
.map( ( [ key, value ] ) => ( { weight: value, index: key } ) )
140140
.sort( ( a, b ) => b.weight - a.weight );
141141

142-
let boneIndex = sorted[ 0 ].index;
142+
const boneIndex = sorted[ 0 ].index;
143143
let bone = skeleton.bones[ boneIndex ];
144144
const parentIndex = skeleton.bones.findIndex( b => b === bone.parent );
145145

@@ -404,7 +404,7 @@ function init() {
404404
directionalLight.castShadow = true;
405405
directionalLight.shadow.mapSize.setScalar( 1024 );
406406

407-
var dlShadowCam = directionalLight.shadow.camera;
407+
const dlShadowCam = directionalLight.shadow.camera;
408408
dlShadowCam.left = dlShadowCam.bottom = - 100;
409409
dlShadowCam.top = dlShadowCam.right = 100;
410410
scene.add( directionalLight );
@@ -452,15 +452,15 @@ function init() {
452452

453453
switch ( e.key ) {
454454

455-
case 'w':
456-
transformControls.mode = 'translate';
457-
break;
458-
case 'e':
459-
transformControls.mode = 'rotate';
460-
break;
461-
case 'r':
462-
transformControls.mode = 'scale';
463-
break;
455+
case 'w':
456+
transformControls.mode = 'translate';
457+
break;
458+
case 'e':
459+
transformControls.mode = 'rotate';
460+
break;
461+
case 'r':
462+
transformControls.mode = 'scale';
463+
break;
464464

465465
}
466466

@@ -506,8 +506,8 @@ function rebuildGui() {
506506

507507
function onWindowResize() {
508508

509-
var width = window.innerWidth;
510-
var height = window.innerHeight;
509+
const width = window.innerWidth;
510+
const height = window.innerHeight;
511511

512512
camera.aspect = width / height;
513513
camera.updateProjectionMatrix();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "cd example && parcel serve ./*.html --dist-dir ../dist/ --no-cache --no-hmr",
88
"build": "parcel build --no-content-hash ./example/index.html --public-url ./ --no-cache",
9-
"lint": "eslint ./src/**.js"
9+
"lint": "eslint ./{src,example}/**.js"
1010
},
1111
"repository": {
1212
"type": "git",

0 commit comments

Comments
 (0)